forked from sony/nmos-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilesystem.h
89 lines (67 loc) · 2.38 KB
/
filesystem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifndef BST_FILESYSTEM_H
#define BST_FILESYSTEM_H
// Provide bst::filesystem::path, etc. using either std:: or boost:: symbols
#if !defined(BST_FILESYSTEM_STD) && !defined(BST_FILESYSTEM_STD_EXPERIMENTAL) && !defined(BST_FILESYSTEM_MICROSOFT_TR2) && !defined(BST_FILESYSTEM_BOOST)
#if defined(__GNUC__)
#if __GNUC__ > 5 || (__GNUC__ == 5 && __GNUC_MINOR__ >= 3)
#define BST_FILESYSTEM_STD_EXPERIMENTAL
#else
#define BST_FILESYSTEM_BOOST
#endif
#elif defined(_MSC_VER)
#if _MSC_VER >= 1910
// From VS2017, /std:c++17 switch is introduced, but this is only indicated in __cplusplus if /Zc:__cplusplus is also specified
#if __cplusplus >= 201703L
#define BST_FILESYSTEM_STD
#else
#define BST_FILESYSTEM_STD_EXPERIMENTAL
#if _MSC_VER >= 1920
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
#endif
#endif
#elif _MSC_VER >= 1900
// VS2015
#define BST_FILESYSTEM_STD_EXPERIMENTAL
#else
// Earlier
#define BST_FILESYSTEM_MICROSOFT_TR2
#endif
#else
// Default to C++17
#define BST_FILESYSTEM_STD
#endif
#endif
#if defined(BST_FILESYSTEM_STD)
#include <filesystem>
namespace bst_filesystem = std::filesystem;
#elif defined(BST_FILESYSTEM_STD_EXPERIMENTAL)
#include <experimental/filesystem>
namespace bst_filesystem = std::experimental::filesystem;
#elif defined(BST_FILESYSTEM_MICROSOFT_TR2)
#include <filesystem>
namespace bst_filesystem = std::tr2::sys;
#elif defined(BST_FILESYSTEM_BOOST)
#include <boost/filesystem.hpp>
namespace bst_filesystem = boost::filesystem;
#endif
namespace bst
{
namespace filesystem
{
// Subset of symbols that can be used across all the possible implementations
// Note that with older implementations, e.g. Microsoft TR2 (and Boost.Filesystem v2), path does not have constructors and string() member functions that convert between the source/string character type and the native encoding
using bst_filesystem::path;
using bst_filesystem::filesystem_error;
using bst_filesystem::directory_entry;
using bst_filesystem::directory_iterator;
using bst_filesystem::recursive_directory_iterator;
using bst_filesystem::exists;
using bst_filesystem::is_regular_file;
using bst_filesystem::is_directory;
using bst_filesystem::file_size;
using bst_filesystem::create_directory;
using bst_filesystem::remove_all;
using bst_filesystem::temp_directory_path;
}
}
#endif