OMSimulatorLib
The OMSimulator project is a FMI-based co-simulation environment that supports ordinary (i.e., non-delayed) and TLM connections.
OMSFileSystem.h
Go to the documentation of this file.
1 #ifndef _OMS_FILESYSTEM_H_
2 
3 #if !defined(WITHOUT_FS) && defined(__has_include)
4 #if __has_include(<filesystem>)
5 #include <filesystem>
6 #if __cpp_lib_filesystem >= 201703
7 namespace filesystem = std::filesystem;
8 #define OMC_STD_FS 1
9 #endif
10 #endif
11 #if !defined(OMC_STD_FS) && __has_include(<experimental/filesystem>)
12 #include <experimental/filesystem>
13 namespace filesystem = std::experimental::filesystem::v1;
14 #define OMC_STD_FS 1
15 #endif
16 #endif
17 
18 #if OMC_STD_FS == 1
19 static inline filesystem::path oms_temp_directory_path(void) {
20  return filesystem::temp_directory_path();
21 }
22 static inline filesystem::path oms_canonical(filesystem::path p) {
23  return filesystem::canonical(p);
24 }
25 
26 #else
27 #include <string>
28 #include <boost/version.hpp>
29 // boost version < 1.57 has issues linking boost::filesystem::copy_file
30 // https://svn.boost.org/trac10/ticket/6124
31 #if (BOOST_VERSION < 105700)
32 #define BOOST_NO_CXX11_SCOPED_ENUMS
33 #endif // #if (BOOST_VERSION < 105700)
34 #include <boost/filesystem.hpp>
35 #if (BOOST_VERSION < 105700)
36 #undef BOOST_NO_CXX11_SCOPED_ENUMS
37 #endif // #if (BOOST_VERSION < 105700)
38 
39 #if (BOOST_VERSION >= 105300)
40 #include <boost/lockfree/queue.hpp>
41 #endif
42 
43 #include <boost/filesystem.hpp>
44 namespace filesystem = boost::filesystem;
45 
46 #if (BOOST_VERSION >= 104600) // no temp_directory_path in boost < 1.46
47 static inline filesystem::path oms_temp_directory_path(void) {
48  return filesystem::temp_directory_path();
49 }
50 static inline filesystem::path oms_canonical(filesystem::path p) {
51  return filesystem::canonical(p);
52 }
53 #else
54 filesystem::path oms_temp_directory_path(void);
55 filesystem::path oms_canonical(filesystem::path p);
56 #endif
57 
58 #endif
59 
60 void oms_copy_file(const filesystem::path &from, const filesystem::path &to);
61 filesystem::path oms_unique_path(const std::string& prefix);
62 
63 #endif
filesystem::path oms_canonical(filesystem::path p)
Definition: OMSFileSystem.cpp:80
filesystem::path oms_unique_path(const std::string &prefix)
Definition: OMSFileSystem.cpp:87
void oms_copy_file(const filesystem::path &from, const filesystem::path &to)
Definition: OMSFileSystem.cpp:100
filesystem::path oms_temp_directory_path(void)
Definition: OMSFileSystem.cpp:53