Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting from boost to std::filesystem #753

Closed
Nelson-numerical-software opened this issue Oct 10, 2022 · 2 comments · Fixed by #764
Closed

Converting from boost to std::filesystem #753

Nelson-numerical-software opened this issue Oct 10, 2022 · 2 comments · Fixed by #764
Projects
Milestone

Comments

@Nelson-numerical-software
Copy link
Collaborator

Nelson uses boost because C++17 was not available
Now we can switch boost::filesystem to std::filesystem

222 references to boost::filesystem
some will be not removed for example with it is used with boost ipc features

@Nelson-numerical-software
Copy link
Collaborator Author

@Nelson-numerical-software
Copy link
Collaborator Author

ugly workaround on gcc use character_encoding functions

 #include <filesystem>
 #include "IsDirectory.hpp"
 #include "Error.hpp"
+#include "characters_encoding.hpp"
 //=============================================================================
 namespace Nelson {
 //=============================================================================
 bool
 IsDirectory(const std::wstring& str)
 {
-    std::filesystem::path data_dir(str);
+    std::string s = wstring_to_utf8(str);
+    std::filesystem::path data_dir(s);
     bool bRes = false;
     try {
-        bRes = std::filesystem::is_directory(data_dir);
+        
+      bRes = std::filesystem::is_directory(data_dir);
     } catch (const std::filesystem::filesystem_error& e) {
         if (e.code() == std::errc::permission_denied) {
             Error(_W("Permission denied."));
diff --git a/modules/files_folders_functions/src/cpp/MakeDirectory.cpp b/modules/files_folders_functions/src/cpp/MakeDirectory.cpp
index 2c5d5be84..63ec78abd 100644
--- a/modules/files_folders_functions/src/cpp/MakeDirectory.cpp
+++ b/modules/files_folders_functions/src/cpp/MakeDirectory.cpp
@@ -33,7 +33,8 @@ MakeDirectory(const std::wstring& newDir, std::wstring& message)
         message = _W("Directory already exists.");
     } else {
         try {
-            bOK = std::filesystem::create_directories(newDir);
+            std::string s = wstring_to_utf8(newDir);
+            bOK = std::filesystem::create_directories(s);
         } catch (const std::filesystem::filesystem_error& e) {
             std::error_code error_code = e.code();

major rework for a ugly bug of gcc ...

@Nelson-numerical-software Nelson-numerical-software linked a pull request Oct 16, 2022 that will close this issue
Nelson-numerical-software added a commit that referenced this issue Oct 28, 2022
…ctions factorized (#764)

* reworks normalizePath
* factorize isdir, isfile
* FileSystemWrapper to replace easily boost::filesystem::path
* easily switch between std::filesystem and boost::filesystem (default std::filesystem)
@Nelson-numerical-software Nelson-numerical-software moved this from TO DO to Done in Nelson 2022 Oct 29, 2022
@Nelson-numerical-software Nelson-numerical-software moved this from Done to DONE (Nelson 0.6.10) in Nelson 2022 Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Nelson 2022
DONE (Nelson 0.6.10)
1 participant