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_VERSION >= 103600
00018 return p.empty() ? std::string() : *--p.end();
00019 #else
00020 return p.leaf();
00021 #endif
00022 }
00023
00024 inline SAGA_EXPORT std::string parent(boost::filesystem::path const& p)
00025 {
00026 #if BOOST_VERSION >= 103600
00027 return p.parent_path().string();
00028 #else
00029 return p.branch_path().string();
00030 #endif
00031 }
00032
00033 #if BOOST_VERSION == 104400
00034
00035
00036 inline void remove_trailing_dot(boost::filesystem::path& p)
00037 {
00038 std::string str = p.string();
00039 if (str[str.size()-1] == '.')
00040 p = boost::filesystem::path(str.substr(0, str.size()-1));
00041 }
00042 #endif
00043
00044 }}
00045
00046 #endif
00047