Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-11 08:28:26

0001 /*=============================================================================
0002     Boost.Wave: A Standard compliant C++ preprocessor library
0003 
0004     http://www.boost.org/
0005 
0006     Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost
0007     Software License, Version 1.0. (See accompanying file
0008     LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
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 #include <boost/filesystem/directory.hpp>
0020 
0021 namespace boost { namespace wave { namespace util
0022 {
0023 ///////////////////////////////////////////////////////////////////////////////
0024 // filesystem wrappers allowing to handle different Boost versions
0025 #if !defined(BOOST_FILESYSTEM_NO_DEPRECATED)
0026 // interface wrappers for older Boost versions
0027     inline boost::filesystem::path initial_path()
0028     {
0029         return boost::filesystem::initial_path();
0030     }
0031 
0032     inline boost::filesystem::path current_path()
0033     {
0034         return boost::filesystem::current_path();
0035     }
0036 
0037     template <typename String>
0038     inline boost::filesystem::path create_path(String const& p)
0039     {
0040 #if BOOST_FILESYSTEM_VERSION >= 3
0041         return boost::filesystem::path(p);
0042 #else
0043         return boost::filesystem::path(p, boost::filesystem::native);
0044 #endif
0045     }
0046 
0047     inline std::string leaf(boost::filesystem::path const& p)
0048     {
0049 #if BOOST_FILESYSTEM_VERSION >= 3
0050 #if BOOST_VERSION >= 108400
0051         return p.filename().string();
0052 #else
0053         return p.leaf().string();
0054 #endif
0055 #else
0056         return p.leaf();
0057 #endif
0058     }
0059 
0060     inline boost::filesystem::path branch_path(boost::filesystem::path const& p)
0061     {
0062 #if BOOST_FILESYSTEM_VERSION >= 3 && BOOST_VERSION >= 108400
0063         return p.parent_path();
0064 #else
0065         return p.branch_path();
0066 #endif
0067     }
0068 
0069     inline boost::filesystem::path normalize(boost::filesystem::path& p)
0070     {
0071 #if BOOST_FILESYSTEM_VERSION >= 3 && BOOST_VERSION >= 108400
0072         return p.lexically_normal().make_preferred();
0073 #else
0074         return p.normalize().make_preferred();
0075 #endif
0076     }
0077 
0078     inline std::string native_file_string(boost::filesystem::path const& p)
0079     {
0080 #if BOOST_FILESYSTEM_VERSION >= 3
0081         return p.string();
0082 #else
0083         return p.native_file_string();
0084 #endif
0085     }
0086 
0087     inline boost::filesystem::path complete_path(
0088         boost::filesystem::path const& p)
0089     {
0090 #if BOOST_FILESYSTEM_VERSION >= 3
0091 #if BOOST_VERSION >= 108400
0092         return boost::filesystem::absolute(p, initial_path());
0093 #elif BOOST_VERSION >= 105000
0094         return boost::filesystem::complete(p, initial_path());
0095 #else
0096         return boost::filesystem3::complete(p, initial_path());
0097 #endif
0098 #else
0099         return boost::filesystem::complete(p, initial_path());
0100 #endif
0101     }
0102 
0103     inline boost::filesystem::path complete_path(
0104         boost::filesystem::path const& p, boost::filesystem::path const& base)
0105     {
0106 #if BOOST_FILESYSTEM_VERSION >= 3
0107 #if BOOST_VERSION >= 108400
0108         return boost::filesystem::absolute(p, base);
0109 #elif BOOST_VERSION >= 105000
0110         return boost::filesystem::complete(p, base);
0111 #else
0112         return boost::filesystem3::complete(p, base);
0113 #endif
0114 #else
0115         return boost::filesystem::complete(p, base);
0116 #endif
0117     }
0118 
0119 #else
0120 
0121 // interface wrappers if deprecated functions do not exist
0122     inline boost::filesystem::path initial_path()
0123     {
0124 #if BOOST_FILESYSTEM_VERSION >= 3
0125 #if BOOST_VERSION >= 105000
0126         return boost::filesystem::detail::initial_path();
0127 #else
0128         return boost::filesystem3::detail::initial_path();
0129 #endif
0130 #else
0131         return boost::filesystem::initial_path<boost::filesystem::path>();
0132 #endif
0133     }
0134 
0135     inline boost::filesystem::path current_path()
0136     {
0137 #if BOOST_FILESYSTEM_VERSION >= 3
0138 #if BOOST_VERSION >= 105000
0139         return boost::filesystem::current_path();
0140 #else
0141         return boost::filesystem3::current_path();
0142 #endif
0143 #else
0144         return boost::filesystem::current_path<boost::filesystem::path>();
0145 #endif
0146     }
0147 
0148     template <typename String>
0149     inline boost::filesystem::path create_path(String const& p)
0150     {
0151         return boost::filesystem::path(p);
0152     }
0153 
0154     inline std::string leaf(boost::filesystem::path const& p)
0155     {
0156 #if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3
0157         return p.filename().string();
0158 #else
0159         return p.filename();
0160 #endif
0161     }
0162 
0163     inline boost::filesystem::path branch_path(boost::filesystem::path const& p)
0164     {
0165         return p.parent_path();
0166     }
0167 
0168     inline boost::filesystem::path normalize(boost::filesystem::path& p)
0169     {
0170         return p; // function doesn't exist anymore
0171     }
0172 
0173     inline std::string native_file_string(boost::filesystem::path const& p)
0174     {
0175 #if BOOST_VERSION >= 104600
0176         return p.string();
0177 #else
0178         return p.file_string();
0179 #endif
0180     }
0181 
0182     inline boost::filesystem::path complete_path(
0183         boost::filesystem::path const& p)
0184     {
0185 #if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3
0186         return boost::filesystem::absolute(p, initial_path());
0187 #else
0188         return boost::filesystem::complete(p, initial_path());
0189 #endif
0190     }
0191 
0192     inline boost::filesystem::path complete_path(
0193         boost::filesystem::path const& p, boost::filesystem::path const& base)
0194     {
0195 #if BOOST_VERSION >= 104600 && BOOST_FILESYSTEM_VERSION >= 3
0196         return boost::filesystem::absolute(p, base);
0197 #else
0198         return boost::filesystem::complete(p, base);
0199 #endif
0200     }
0201 #endif
0202 
0203     // starting withBoost V1.50 create_directories throws if given an empty path
0204     inline bool create_directories(boost::filesystem::path const& p)
0205     {
0206         if (p.string().empty())
0207             return true;
0208         return boost::filesystem::create_directories(p);
0209     }
0210 
0211     // starting with Boost 1.85 no_push was renamed to disable_recursion_pending for consistency
0212     // with std::filesystem (deprecated some point before that)
0213     inline void no_push(boost::filesystem::recursive_directory_iterator & it)
0214     {
0215 #if BOOST_VERSION >= 108400 && BOOST_FILESYSTEM_VERSION >= 3
0216         it.disable_recursion_pending();
0217 #else
0218         it.no_push();
0219 #endif
0220     }
0221 }}}
0222 
0223 #endif