rcpputils  master
C++ API providing common utilities and data structures.
Classes | Namespaces | Macros | Functions
filesystem_helper.hpp File Reference

Cross-platform filesystem helper functions and additional emulation of std::filesystem. More...

#include <string>
#include <vector>
#include "rcpputils/visibility_control.hpp"
Include dependency graph for filesystem_helper.hpp:

Go to the source code of this file.

Classes

class  rcpputils::fs::path
 Drop-in replacement for std::filesystem::path. More...
 

Namespaces

 rcpputils
 
 rcpputils::fs
 

Macros

#define RCPPUTILS_IMPL_OS_DIRSEP   '/'
 

Functions

bool rcpputils::fs::is_regular_file (const path &p) noexcept
 Check if the path is a regular file. More...
 
bool rcpputils::fs::is_directory (const path &p) noexcept
 Check if the path is a directory. More...
 
uint64_t rcpputils::fs::file_size (const path &p)
 Get the file size of the path. More...
 
bool rcpputils::fs::exists (const path &path_to_check)
 Check if a path exists. More...
 
path rcpputils::fs::temp_directory_path ()
 Get a path to a location in the temporary directory, if it's available. More...
 
path rcpputils::fs::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. More...
 
path rcpputils::fs::current_path ()
 Return current working directory. More...
 
bool rcpputils::fs::create_directories (const path &p)
 Create a directory with the given path p. More...
 
bool rcpputils::fs::remove (const path &p)
 Remove the file or directory at the path p. More...
 
bool rcpputils::fs::remove_all (const path &p)
 Remove the directory at the path p and its content. More...
 
path rcpputils::fs::remove_extension (const path &file_path, int n_times=1)
 Remove extension(s) from a path. More...
 
bool rcpputils::fs::operator== (const path &a, const path &b)
 Compare two paths for equality. More...
 
bool rcpputils::fs::operator!= (const path &a, const path &b)
 
std::ostreamrcpputils::fs::operator<< (std::ostream &os, const path &p)
 Convert the path to a string for ostream usage, such as in logging or string formatting. More...
 

Detailed Description

Cross-platform filesystem helper functions and additional emulation of std::filesystem.

Note: Once std::filesystem is supported on all ROS2 platforms, this class can be deprecated/removed in favor of the built-in functionality.

Macro Definition Documentation

◆ RCPPUTILS_IMPL_OS_DIRSEP

#define RCPPUTILS_IMPL_OS_DIRSEP   '/'