Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #ifndef SAGA_SAGA_PATH_LEAF_HPP
00007 #define SAGA_SAGA_PATH_LEAF_HPP
00008
00009 #include <string>
00010 #include <boost/version.hpp>
00011 #include <boost/filesystem/path.hpp>
00012
00013 namespace saga { namespace detail
00014 {
00015 inline SAGA_EXPORT std::string leaf(boost::filesystem::path const& p)
00016 {
00017 #if BOOST_FILESYSTEM_VERSION == 3
00018 return p.filename().string();
00019 #else
00020 #if BOOST_VERSION >= 103600
00021 return p.empty() ? std::string() : *--p.end();
00022 #else
00023 return p.leaf();
00024 #endif
00025 #endif
00026 }
00027
00028 inline SAGA_EXPORT std::string parent(boost::filesystem::path const& p)
00029 {
00030 #if BOOST_VERSION >= 103600
00031 return p.parent_path().string();
00032 #else
00033 return p.branch_path().string();
00034 #endif
00035 }
00036
00037
00038
00039 inline void remove_trailing_dot(boost::filesystem::path& p)
00040 {
00041
00042 std::string str = p.string();
00043 if (str[str.size()-1] == '.')
00044 p = boost::filesystem::path(str.substr(0, str.size()-1));
00045
00046 }
00047
00048 }}
00049
00050 #endif
00051