rcpputils
master
C++ API providing common utilities and data structures.
|
Go to the documentation of this file.
39 #ifndef RCPPUTILS__FILESYSTEM_HELPER_HPP_
40 #define RCPPUTILS__FILESYSTEM_HELPER_HPP_
53 # define RCPPUTILS_IMPL_OS_DIRSEP '\\'
55 # define RCPPUTILS_IMPL_OS_DIRSEP '/'
65 #undef RCPPUTILS_IMPL_OS_DIRSEP
349 #endif // RCPPUTILS__FILESYSTEM_HELPER_HPP_
path create_temp_directory(const std::string &base_name, const path &parent_path=temp_directory_path())
Construct a uniquely named temporary directory, in "parent", with format base_nameXXXXXX.
bool exists() const
Check if this path exists.
bool is_regular_file(const path &p) noexcept
Check if the path is a regular file.
bool remove(const path &p)
Remove the file or directory at the path p.
path temp_directory_path()
Get a path to a location in the temporary directory, if it's available.
uint64_t file_size(const path &p)
Get the file size of the path.
Definition: asserts.hpp:37
#define RCPPUTILS_IMPL_OS_DIRSEP
Definition: filesystem_helper.hpp:55
path current_path()
Return current working directory.
path filename() const
Get the last element in this path.
path parent_path() const
Get the parent directory of this path.
std::vector< std::string >::const_iterator cend() const
bool empty() const
Check if the path is empty.
bool operator==(const path &a, const path &b)
Compare two paths for equality.
bool is_absolute() const
Check if the path is an absolute path.
path remove_extension(const path &file_path, int n_times=1)
Remove extension(s) from a path.
uint64_t file_size() const
Return the size of the file in bytes.
bool is_directory(const path &p) noexcept
Check if the path is a directory.
std::string string() const
Get the path delimited using this system's path separator.
Drop-in replacement for std::filesystem::path.
Definition: filesystem_helper.hpp:74
std::vector< std::string >::const_iterator cbegin() const
Const iterator to first element of this path.
path extension() const
Get a relative path to the component including and following the last '.'.
bool exists(const path &path_to_check)
Check if a path exists.
Macros for controlling visibilty of exported iterfaces.
bool create_directories(const path &p)
Create a directory with the given path p.
bool is_directory() const noexcept
Check if the path exists and it is a directory.
path operator/(const std::string &other) const
Concatenate a path and a string into a single path.
std::ostream & operator<<(std::ostream &os, const path &p)
Convert the path to a string for ostream usage, such as in logging or string formatting.
bool operator!=(const path &a, const path &b)
#define RCPPUTILS_PUBLIC
Declares symbols and functions will be visible for export.
Definition: visibility_control.hpp:81
path()=default
Constructs an empty path.
bool remove_all(const path &p)
Remove the directory at the path p and its content.
path & operator/=(const std::string &other)
Append a string component to this path.
bool is_regular_file() const noexcept
Check if the path is a regular file.