File indexing completed on 2025-01-18 09:53:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #if !defined(BOOST_WAVE_FILESYSTEM_COMPATIBILITY_MAR_09_2009_0142PM)
0012 #define BOOST_WAVE_FILESYSTEM_COMPATIBILITY_MAR_09_2009_0142PM
0013
0014 #include <string>
0015
0016 #include <boost/version.hpp>
0017 #include <boost/filesystem/path.hpp>
0018 #include <boost/filesystem/operations.hpp>
0019
0020 namespace boost { namespace wave { namespace util
0021 {
0022
0023
0024 #if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
0025
0026 inline boost::filesystem::path initial_path()
0027 {
0028 return boost::filesystem::initial_path();
0029 }
0030
0031 inline boost::filesystem::path current_path()
0032 {
0033 return boost::filesystem::current_path();
0034 }
0035
0036 template <typename String>
0037 inline boost::filesystem::path create_path(String const& p)
0038 {
0039 #if BOOST_FILESYSTEM_VERSION >= 3
0040 return boost::filesystem::path(p);
0041 #else
0042 return boost::filesystem::path(p, boost::filesystem::native);
0043 #endif
0044 }
0045
0046 inline std::string leaf(boost::filesystem::path const& p)
0047 {
0048 #if BOOST_FILESYSTEM_VERSION >= 3
0049 #if BOOST_VERSION >= 108400
0050 return p.filename().string();
0051 #else
0052 return p.leaf().string();
0053 #endif
0054 #else
0055 return p.leaf();
0056 #endif
0057 }
0058
0059 inline boost::filesystem::path branch_path(boost::filesystem::path const& p)
0060 {
0061 #if BOOST_FILESYSTEM_VERSION >= 3 && BOOST_VERSION >= 108400
0062 return p.parent_path();
0063 #else
0064 return p.branch_path();
0065 #endif
0066 }
0067
0068 inline boost::filesystem::path normalize(boost::filesystem::path& p)
0069 {
0070 #if BOOST_FILESYSTEM_VERSION >= 3 && BOOST_VERSION >= 108400
0071 return p.lexically_normal().make_preferred();
0072 #else
0073 return p.normalize().make_preferred();
0074 #endif
0075 }
0076
0077 inline std::string native_file_string(boost::filesystem::path const& p)
0078 {
0079 #if BOOST_FILESYSTEM_VERSION >= 3
0080 return p.string();
0081 #else
0082 return p.native_file_string();
0083 #endif
0084 }
0085
0086 inline boost::filesystem::path complete_path(
0087 boost::filesystem::path const& p)
0088 {
0089 #if BOOST_FILESYSTEM_VERSION >= 3
0090 #if BOOST_VERSION >= 108400
0091 return boost::filesystem::absolute(p, initial_path());
0092 #elif BOOST_VERSION >= 105000
0093 return boost::filesystem::complete(p, initial_path());
0094 #else
0095 return boost::filesystem3::complete(p, initial_path());
0096 #endif
0097 #else
0098 return boost::filesystem::complete(p, initial_path());
0099 #endif
0100 }
0101
0102 inline boost::filesystem::path complete_path(
0103 boost::filesystem::path const& p, boost::filesystem::path const& base)
0104 {
0105 #if BOOST_FILESYSTEM_VERSION >= 3
0106 #if BOOST_VERSION >= 108400
0107 return boost::filesystem::absolute(p, base);
0108 #elif BOOST_VERSION >= 105000
0109 return boost::filesystem::complete(p, base);
0110 #else
0111 return boost::filesystem3::complete(p, base);
0112 #endif
0113 #else
0114 return boost::filesystem::complete(p, base);
0115 #endif
0116 }
0117
0118 #else
0119
0120
0121 inline boost::filesystem::path initial_path()
0122 {
0123 #if BOOST_FILESYSTEM_VERSION >= 3
0124 #if BOOST_VERSION >= 105000
0125 return boost::filesystem::detail::initial_path();
0126 #else
0127 return boost::filesystem3::detail::initial_path();
0128 #endif
0129 #else
0130 return boost::filesystem::initial_path<boost::filesystem::path>();
0131 #endif
0132 }
0133
0134 inline boost::filesystem::path current_path()
0135 {
0136 #if BOOST_FILESYSTEM_VERSION >= 3
0137 #if BOOST_VERSION >= 105000
0138 return boost::filesystem::current_path();
0139 #else
0140 return boost::filesystem3::current_path();
0141 #endif
0142 #else
0143 return boost::filesystem::current_path<boost::filesystem::path>();
0144 #endif
0145 }
0146
0147 template <typename String>
0148 inline boost::filesystem::path create_path(String const& p)
0149 {
0150 return boost::filesystem::path(p);
0151 }
0152
0153 inline std::string leaf(boost::filesystem::path const& p)
0154 {
0155 #if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3
0156 return p.filename().string();
0157 #else
0158 return p.filename();
0159 #endif
0160 }
0161
0162 inline boost::filesystem::path branch_path(boost::filesystem::path const& p)
0163 {
0164 return p.parent_path();
0165 }
0166
0167 inline boost::filesystem::path normalize(boost::filesystem::path& p)
0168 {
0169 return p;
0170 }
0171
0172 inline std::string native_file_string(boost::filesystem::path const& p)
0173 {
0174 #if BOOST_VERSION >= 104600
0175 return p.string();
0176 #else
0177 return p.file_string();
0178 #endif
0179 }
0180
0181 inline boost::filesystem::path complete_path(
0182 boost::filesystem::path const& p)
0183 {
0184 #if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3
0185 return boost::filesystem::absolute(p, initial_path());
0186 #else
0187 return boost::filesystem::complete(p, initial_path());
0188 #endif
0189 }
0190
0191 inline boost::filesystem::path complete_path(
0192 boost::filesystem::path const& p, boost::filesystem::path const& base)
0193 {
0194 #if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3
0195 return boost::filesystem::absolute(p, base);
0196 #else
0197 return boost::filesystem::complete(p, base);
0198 #endif
0199 }
0200 #endif
0201
0202
0203 inline bool create_directories(boost::filesystem::path const& p)
0204 {
0205 if (p.string().empty())
0206 return true;
0207 return boost::filesystem::create_directories(p);
0208 }
0209 }}}
0210
0211 #endif