diff --git a/include/fmi4cpp/fmi2/fmu.hpp b/include/fmi4cpp/fmi2/fmu.hpp index 7526486..128f488 100644 --- a/include/fmi4cpp/fmi2/fmu.hpp +++ b/include/fmi4cpp/fmi2/fmu.hpp @@ -4,11 +4,10 @@ #include #include -#include #include #include -#include +#include #include #include @@ -26,7 +25,7 @@ class fmu : public virtual fmu_provider std::shared_ptr modelDescription_; public: - explicit fmu(const fs::path& fmuPath); + explicit fmu(const std::filesystem::path& fmuPath); [[nodiscard]] std::string get_model_description_xml() const; [[nodiscard]] std::shared_ptr get_model_description() const override; diff --git a/include/fmi4cpp/fmu_resource.hpp b/include/fmi4cpp/fmu_resource.hpp index b96a184..9351d4e 100644 --- a/include/fmi4cpp/fmu_resource.hpp +++ b/include/fmi4cpp/fmu_resource.hpp @@ -2,8 +2,7 @@ #ifndef FMI4CPP_FMURESOURCE_HPP #define FMI4CPP_FMURESOURCE_HPP -#include - +#include #include namespace fmi4cpp @@ -13,10 +12,10 @@ class fmu_resource { private: - const fs::path path_; + std::filesystem::path path_; public: - explicit fmu_resource(fs::path path); + explicit fmu_resource(std::filesystem::path path); [[nodiscard]] std::string resource_path() const; diff --git a/include/fmi4cpp/fs_portability.hpp b/include/fmi4cpp/fs_portability.hpp deleted file mode 100644 index da152f6..0000000 --- a/include/fmi4cpp/fs_portability.hpp +++ /dev/null @@ -1,19 +0,0 @@ - -#ifndef FMI4CPP_FS_PORTABILITY_HPP -#define FMI4CPP_FS_PORTABILITY_HPP - -#if __has_include() -# include -namespace fmi4cpp -{ -namespace fs = std::filesystem; -} -#else -# include -namespace fmi4cpp -{ -namespace fs = std::experimental::filesystem; -} -#endif - -#endif //FMI4CPP_FS_PORTABILITY_HPP diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cbe2918..86e74a9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,7 +14,6 @@ set(publicHeaders "fmi4cpp/fmu_variable_accessor.hpp" "fmi4cpp/dll_handle.hpp" - "fmi4cpp/fs_portability.hpp" "fmi4cpp/fmi2/fmi2.hpp" "fmi4cpp/fmi2/fmu.hpp" @@ -111,7 +110,7 @@ target_link_libraries(fmi4cpp if(WIN32) target_link_libraries(fmi4cpp PRIVATE "Bcrypt") elseif(UNIX) - target_link_libraries(fmi4cpp PRIVATE stdc++fs dl) + target_link_libraries(fmi4cpp PRIVATE dl) endif() diff --git a/src/fmi4cpp/fmi2/fmi2_library.cpp b/src/fmi4cpp/fmi2/fmi2_library.cpp index eadd59b..62dc382 100644 --- a/src/fmi4cpp/fmi2/fmi2_library.cpp +++ b/src/fmi4cpp/fmi2/fmi2_library.cpp @@ -1,6 +1,5 @@ #include -#include #include #include #include @@ -59,7 +58,7 @@ fmi2_library::fmi2_library(const std::string& modelIdentifier, const std::shared { const std::string libName = resource->absolute_library_path(modelIdentifier); - MLOG_DEBUG("Loading shared library '" + fs::path(libName).stem().string() + get_shared_library_extension() + "'"); + MLOG_DEBUG("Loading shared library '" + std::filesystem::path(libName).stem().string() + get_shared_library_extension() + "'"); handle_ = load_library(libName); diff --git a/src/fmi4cpp/fmi2/fmu.cpp b/src/fmi4cpp/fmi2/fmu.cpp index ae4ed46..e95d9b1 100644 --- a/src/fmi4cpp/fmi2/fmu.cpp +++ b/src/fmi4cpp/fmi2/fmu.cpp @@ -11,7 +11,7 @@ using namespace fmi4cpp; using namespace fmi4cpp::fmi2; -fmu::fmu(const fs::path& fmuPath) +fmu::fmu(const std::filesystem::path& fmuPath) { if (!exists(fmuPath)) { @@ -21,7 +21,7 @@ fmu::fmu(const fs::path& fmuPath) } const std::string fmuName = fmuPath.stem().string(); - fs::path tmpPath(fs::temp_directory_path() /= fs::path("fmi4cpp_" + fmuName + "_" + generate_simple_id(8))); + std::filesystem::path tmpPath(std::filesystem::temp_directory_path() /= std::filesystem::path("fmi4cpp_" + fmuName + "_" + generate_simple_id(8))); if (!create_directories(tmpPath)) { const auto err = "Failed to create temporary directory '" + tmpPath.string() + "' !"; diff --git a/src/fmi4cpp/fmu_resource.cpp b/src/fmi4cpp/fmu_resource.cpp index d6b23ea..42654a2 100644 --- a/src/fmi4cpp/fmu_resource.cpp +++ b/src/fmi4cpp/fmu_resource.cpp @@ -9,7 +9,7 @@ using namespace fmi4cpp; -fmu_resource::fmu_resource(fs::path path) +fmu_resource::fmu_resource(std::filesystem::path path) : path_(std::move(path)) {} @@ -37,7 +37,7 @@ std::string fmu_resource::get_model_description_xml() const fmu_resource::~fmu_resource() { std::error_code success; - fs::remove_all(path_, success); + remove_all(path_, success); if (!success) { MLOG_DEBUG("Deleted temporal folder '" + path_.string() + "'"); diff --git a/src/fmi4cpp/library_helper.hpp b/src/fmi4cpp/library_helper.hpp index dd6ee5e..e695c7c 100644 --- a/src/fmi4cpp/library_helper.hpp +++ b/src/fmi4cpp/library_helper.hpp @@ -3,18 +3,19 @@ #define FMI4CPP_LIBRARYHELPER_HPP #include -#include + +#include #include -namespace +namespace fmi4cpp { -DLL_HANDLE load_library(const std::string& libName) +inline DLL_HANDLE load_library(const std::string& libName) { std::string dllDirectory; #ifdef _WIN32 - fmi4cpp::fs::path path(libName); + std::filesystem::path path(libName); if (path.has_parent_path()) { dllDirectory = path.parent_path().string(); } @@ -48,7 +49,7 @@ T load_function(DLL_HANDLE handle, const char* function_name) #endif } -bool free_library(DLL_HANDLE handle) +inline bool free_library(DLL_HANDLE handle) { #ifdef WIN32 return static_cast(FreeLibrary(handle)); @@ -57,7 +58,7 @@ bool free_library(DLL_HANDLE handle) #endif } -std::string getLastError() +inline std::string getLastError() { #ifdef WIN32 std::ostringstream os; diff --git a/src/fmi4cpp/tools/unzipper.hpp b/src/fmi4cpp/tools/unzipper.hpp index 3d33788..77d467e 100644 --- a/src/fmi4cpp/tools/unzipper.hpp +++ b/src/fmi4cpp/tools/unzipper.hpp @@ -2,19 +2,16 @@ #ifndef FMI4CPP_UNZIPPER_HPP #define FMI4CPP_UNZIPPER_HPP -#include - #include +#include #include -#include -#include #include -namespace +namespace fmi4cpp { -bool unzip(const fmi4cpp::fs::path& zip_file, const fmi4cpp::fs::path& tmp_path) +inline bool unzip(const std::filesystem::path& zip_file, const std::filesystem::path& tmp_path) { int* err = nullptr; zip* za = zip_open(absolute(zip_file).string().c_str(), 0, err); @@ -34,13 +31,13 @@ bool unzip(const fmi4cpp::fs::path& zip_file, const fmi4cpp::fs::path& tmp_path) for (int i = 0; i < zip_get_num_entries(za, 0); i++) { if (zip_stat_index(za, i, 0, &sb) == 0) { - const fmi4cpp::fs::path newFile = tmp_path / sb.name; + const std::filesystem::path newFile = tmp_path / sb.name; if (sb.size == 0) { - fmi4cpp::fs::create_directories(newFile); + create_directories(newFile); } else { const auto containingDirectory = newFile.parent_path(); - if (!fmi4cpp::fs::exists(containingDirectory) && !fmi4cpp::fs::create_directories(containingDirectory)) { + if (!exists(containingDirectory) && !create_directories(containingDirectory)) { return false; } zf = zip_fopen_index(za, i, 0); @@ -67,6 +64,6 @@ bool unzip(const fmi4cpp::fs::path& zip_file, const fmi4cpp::fs::path& tmp_path) return true; } -} // namespace +} // namespace fmi4cpp #endif // FMI4CPP_UNZIPPER_HPP