Skip to content

Commit fbbd1ad

Browse files
authored
remove fs_portability (#149)
1 parent 399e96e commit fbbd1ad

9 files changed

Lines changed: 25 additions & 50 deletions

File tree

include/fmi4cpp/fmi2/fmu.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44

55
#include <fmi4cpp/fmi2/cs_fmu.hpp>
66
#include <fmi4cpp/fmi2/me_fmu.hpp>
7-
#include <fmi4cpp/fmi2/xml/cs_model_description.hpp>
87
#include <fmi4cpp/fmi2/xml/me_model_description.hpp>
98
#include <fmi4cpp/fmu_base.hpp>
10-
#include <fmi4cpp/fs_portability.hpp>
119

10+
#include <filesystem>
1211
#include <memory>
1312
#include <string>
1413

@@ -26,7 +25,7 @@ class fmu : public virtual fmu_provider<model_description, cs_fmu, me_fmu>
2625
std::shared_ptr<const fmi4cpp::fmi2::model_description> modelDescription_;
2726

2827
public:
29-
explicit fmu(const fs::path& fmuPath);
28+
explicit fmu(const std::filesystem::path& fmuPath);
3029

3130
[[nodiscard]] std::string get_model_description_xml() const;
3231
[[nodiscard]] std::shared_ptr<const fmi4cpp::fmi2::model_description> get_model_description() const override;

include/fmi4cpp/fmu_resource.hpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
#ifndef FMI4CPP_FMURESOURCE_HPP
33
#define FMI4CPP_FMURESOURCE_HPP
44

5-
#include <fmi4cpp/fs_portability.hpp>
6-
5+
#include <filesystem>
76
#include <string>
87

98
namespace fmi4cpp
@@ -13,10 +12,10 @@ class fmu_resource
1312
{
1413

1514
private:
16-
const fs::path path_;
15+
std::filesystem::path path_;
1716

1817
public:
19-
explicit fmu_resource(fs::path path);
18+
explicit fmu_resource(std::filesystem::path path);
2019

2120
[[nodiscard]] std::string resource_path() const;
2221

include/fmi4cpp/fs_portability.hpp

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ set(publicHeaders
1414
"fmi4cpp/fmu_variable_accessor.hpp"
1515

1616
"fmi4cpp/dll_handle.hpp"
17-
"fmi4cpp/fs_portability.hpp"
1817

1918
"fmi4cpp/fmi2/fmi2.hpp"
2019
"fmi4cpp/fmi2/fmu.hpp"
@@ -111,7 +110,7 @@ target_link_libraries(fmi4cpp
111110
if(WIN32)
112111
target_link_libraries(fmi4cpp PRIVATE "Bcrypt")
113112
elseif(UNIX)
114-
target_link_libraries(fmi4cpp PRIVATE stdc++fs dl)
113+
target_link_libraries(fmi4cpp PRIVATE dl)
115114
endif()
116115

117116

src/fmi4cpp/fmi2/fmi2_library.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
#include <fmi4cpp/fmi2/fmi2_library.hpp>
3-
#include <fmi4cpp/fs_portability.hpp>
43
#include <fmi4cpp/library_helper.hpp>
54
#include <fmi4cpp/mlog.hpp>
65
#include <fmi4cpp/tools/os_util.hpp>
@@ -59,7 +58,7 @@ fmi2_library::fmi2_library(const std::string& modelIdentifier, const std::shared
5958
{
6059
const std::string libName = resource->absolute_library_path(modelIdentifier);
6160

62-
MLOG_DEBUG("Loading shared library '" + fs::path(libName).stem().string() + get_shared_library_extension() + "'");
61+
MLOG_DEBUG("Loading shared library '" + std::filesystem::path(libName).stem().string() + get_shared_library_extension() + "'");
6362

6463
handle_ = load_library(libName);
6564

src/fmi4cpp/fmi2/fmu.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
using namespace fmi4cpp;
1212
using namespace fmi4cpp::fmi2;
1313

14-
fmu::fmu(const fs::path& fmuPath)
14+
fmu::fmu(const std::filesystem::path& fmuPath)
1515
{
1616

1717
if (!exists(fmuPath)) {
@@ -21,7 +21,7 @@ fmu::fmu(const fs::path& fmuPath)
2121
}
2222

2323
const std::string fmuName = fmuPath.stem().string();
24-
fs::path tmpPath(fs::temp_directory_path() /= fs::path("fmi4cpp_" + fmuName + "_" + generate_simple_id(8)));
24+
std::filesystem::path tmpPath(std::filesystem::temp_directory_path() /= std::filesystem::path("fmi4cpp_" + fmuName + "_" + generate_simple_id(8)));
2525

2626
if (!create_directories(tmpPath)) {
2727
const auto err = "Failed to create temporary directory '" + tmpPath.string() + "' !";

src/fmi4cpp/fmu_resource.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
using namespace fmi4cpp;
1111

12-
fmu_resource::fmu_resource(fs::path path)
12+
fmu_resource::fmu_resource(std::filesystem::path path)
1313
: path_(std::move(path))
1414
{}
1515

@@ -37,7 +37,7 @@ std::string fmu_resource::get_model_description_xml() const
3737
fmu_resource::~fmu_resource()
3838
{
3939
std::error_code success;
40-
fs::remove_all(path_, success);
40+
remove_all(path_, success);
4141

4242
if (!success) {
4343
MLOG_DEBUG("Deleted temporal folder '" + path_.string() + "'");

src/fmi4cpp/library_helper.hpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33
#define FMI4CPP_LIBRARYHELPER_HPP
44

55
#include <fmi4cpp/dll_handle.hpp>
6-
#include <fmi4cpp/fs_portability.hpp>
6+
7+
#include <filesystem>
78
#include <sstream>
89

9-
namespace
10+
namespace fmi4cpp
1011
{
1112

12-
DLL_HANDLE load_library(const std::string& libName)
13+
inline DLL_HANDLE load_library(const std::string& libName)
1314
{
1415
std::string dllDirectory;
1516

1617
#ifdef _WIN32
17-
fmi4cpp::fs::path path(libName);
18+
std::filesystem::path path(libName);
1819
if (path.has_parent_path()) {
1920
dllDirectory = path.parent_path().string();
2021
}
@@ -48,7 +49,7 @@ T load_function(DLL_HANDLE handle, const char* function_name)
4849
#endif
4950
}
5051

51-
bool free_library(DLL_HANDLE handle)
52+
inline bool free_library(DLL_HANDLE handle)
5253
{
5354
#ifdef WIN32
5455
return static_cast<bool>(FreeLibrary(handle));
@@ -57,7 +58,7 @@ bool free_library(DLL_HANDLE handle)
5758
#endif
5859
}
5960

60-
std::string getLastError()
61+
inline std::string getLastError()
6162
{
6263
#ifdef WIN32
6364
std::ostringstream os;

src/fmi4cpp/tools/unzipper.hpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@
22
#ifndef FMI4CPP_UNZIPPER_HPP
33
#define FMI4CPP_UNZIPPER_HPP
44

5-
#include <fmi4cpp/fs_portability.hpp>
6-
75
#include <zip.h>
86

7+
#include <filesystem>
98
#include <fstream>
10-
#include <iostream>
11-
#include <sstream>
129
#include <string>
1310

14-
namespace
11+
namespace fmi4cpp
1512
{
1613

17-
bool unzip(const fmi4cpp::fs::path& zip_file, const fmi4cpp::fs::path& tmp_path)
14+
inline bool unzip(const std::filesystem::path& zip_file, const std::filesystem::path& tmp_path)
1815
{
1916
int* err = nullptr;
2017
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)
3431
for (int i = 0; i < zip_get_num_entries(za, 0); i++) {
3532
if (zip_stat_index(za, i, 0, &sb) == 0) {
3633

37-
const fmi4cpp::fs::path newFile = tmp_path / sb.name;
34+
const std::filesystem::path newFile = tmp_path / sb.name;
3835

3936
if (sb.size == 0) {
40-
fmi4cpp::fs::create_directories(newFile);
37+
create_directories(newFile);
4138
} else {
4239
const auto containingDirectory = newFile.parent_path();
43-
if (!fmi4cpp::fs::exists(containingDirectory) && !fmi4cpp::fs::create_directories(containingDirectory)) {
40+
if (!exists(containingDirectory) && !create_directories(containingDirectory)) {
4441
return false;
4542
}
4643
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)
6764
return true;
6865
}
6966

70-
} // namespace
67+
} // namespace fmi4cpp
7168

7269
#endif // FMI4CPP_UNZIPPER_HPP

0 commit comments

Comments
 (0)