5 #ifndef BOOST_FILESYSTEM_H_ 6 #define BOOST_FILESYSTEM_H_ 9 #define BOOST_NO_CXX11_SCOPED_ENUMS 10 #include <boost/filesystem.hpp> 11 #undef BOOST_NO_CXX11_SCOPED_ENUMS 12 #include <boost/format.hpp> 19 namespace fs = boost::filesystem;
27 std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
28 std::time_t nowTimeT = std::chrono::system_clock::to_time_t(now);
29 struct std::tm* ptm = std::localtime(&nowTimeT);
31 std::strftime(buffer, 128,
"%Y-%m-%d-%H-%M-%S-", ptm);
32 std::chrono::milliseconds ms =
33 std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch());
34 std::stringstream timeSS;
35 timeSS << _prefix <<
"_" << buffer << boost::format(
"%03i") % (ms.count() % 1000);
49 if (!fs::exists(_root))
54 fs::recursive_directory_iterator it(_root);
55 fs::recursive_directory_iterator endit;
58 if (fs::is_regular_file(*it) && it->path().extension() == _ext)
60 _ret.push_back(it->path());
76 std::string path(_path);
77 MiscCommon::trim_right<std::string>(&path,
'/');
87 inline bool is_file(
const std::string& _pathname)
89 bool is_valid =
false;
96 catch (
const fs::filesystem_error& _ex)
111 bool is_valid =
false;
117 catch (
const fs::filesystem_error& _ex)
std::string get_temp_dir(const std::string &_prefix)
Definition: BOOST_FILESYSTEM.h:25
bool is_directory(const std::string &_pathname)
the is_directory() function checks whether the pathname represents a directory or not
Definition: BOOST_FILESYSTEM.h:109
bool is_file(const std::string &_pathname)
The is_file() function checks whether the pathname represents a file or not.
Definition: BOOST_FILESYSTEM.h:87
void get_files_by_extension(const fs::path &_root, const std::string &_ext, std::vector< fs::path > &_ret)
The function return a list of files in the deirectory with specified extension.
Definition: BOOST_FILESYSTEM.h:47
Miscellaneous functions and helpers are located here.
Definition: BOOST_FILESYSTEM.h:21
std::string normalize_path(const std::string &_path)
The normalize_path() function removes '/' characters at the end of the of the input pathname.
Definition: BOOST_FILESYSTEM.h:74