26 #include <boost/filesystem/operations.hpp> 27 #include <boost/filesystem/path.hpp> 28 #include <boost/version.hpp> 41 #define BOOST_MAJOR_VERSION BOOST_VERSION / 100000 42 #define BOOST_MINOR_VERSION BOOST_VERSION / 100 % 1000 44 #if (BOOST_MAJOR_VERSION >= 1 && BOOST_MINOR_VERSION >= 44 && defined(BOOST_FILESYSTEM_VERSION)) 45 #if (BOOST_FILESYSTEM_VERSION == 2) 49 #define USE_NON_DEPRECATED_BOOST_FILESYSTEM_V2 50 #elif (BOOST_FILESYSTEM_VERSION == 3) 54 #define USE_BOOST_FILESYSTEM_V3 56 #elif (BOOST_MAJOR_VERSION >= 1 && BOOST_MINOR_VERSION >= 46) 60 #define USE_BOOST_FILESYSTEM_V3 61 #elif (BOOST_MAJOR_VERSION >= 1 && BOOST_MINOR_VERSION >= 36) 65 #define USE_NON_DEPRECATED_BOOST_FILESYSTEM_V2 72 #if defined(USE_BOOST_FILESYSTEM_V3) || defined(USE_NON_DEPRECATED_BOOST_FILESYSTEM_V2) 73 return path.has_parent_path();
75 return path.has_branch_path();
80 #if defined(USE_BOOST_FILESYSTEM_V3) || defined(USE_NON_DEPRECATED_BOOST_FILESYSTEM_V2) 81 return path.parent_path();
83 return path.branch_path();
88 #if defined(USE_BOOST_FILESYSTEM_V3) 93 return path.filename().string();
94 #elif defined(USE_NON_DEPRECATED_BOOST_FILESYSTEM_V2) 98 return path.filename();
108 bfs::directory_iterator badIter;
111 if (iter == badIter) {
115 #if defined(USE_BOOST_FILESYSTEM_V3) 120 return iter->path().filename().string();
121 #elif defined(USE_NON_DEPRECATED_BOOST_FILESYSTEM_V2) 125 return iter->path().filename();
136 #if defined(USE_BOOST_FILESYSTEM_V3) 141 return (*pathIter).string();
155 #if defined(USE_BOOST_FILESYSTEM_V3) 156 return bfs::absolute(path);
158 return bfs::complete(path);
176 if (extension.empty() || extension ==
".") {
189 #if defined(USE_BOOST_FILESYSTEM_V3) 190 return path.extension().string();
192 return bfs::extension(path);
197 return GetStem(bfs::path(path));
201 #if defined(USE_BOOST_FILESYSTEM_V3) 207 return path.stem().string();
std::string GetFilenameFromPath(const bfs::path &path)
Helper function to retrieve the filename from a boost filesystem path filename is just the name of th...
std::string GetFilenameFromDirectoryIterator(const bfs::directory_iterator &iter)
Helper function to retrieve a filename string from a directory iterator.
bool HasParentPath(const bfs::path &path)
Helper function to determine if a path object has a parent path.
bfs::path GetParentPath(const bfs::path &path)
Helper function to retrieve a parent path object from a path object.
std::string GetPathIteratorAsString(const bfs::path::iterator &pathIter)
Helper function to retrieve the path iterator in a string representation.
bfs::path GetAbsolutePath(const std::string &path)
Helper function to retrieve an absolute path from a given relative path.
bool HasExtension(const std::string &path)
Helper function to check if a filename has an extension.
std::string GetStem(const std::string &path)
Helper function to retrieve the filename minus any extension.
std::string GetExtension(const std::string &path)
Helper function to retrieve the extension.