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 <limits.h>
#include <sys/stat.h>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <dirent.h>
#include <sys/types.h>
#include <unistd.h>
#include "rcpputils/split.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::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...
 

Detailed Description

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

If std::filesystem is not available the necessary functions are emulated. Note: Once std::filesystem is supported on all ROS2 platforms, this class can be deprecated in favor of the built-in functionality.

Macro Definition Documentation

◆ RCPPUTILS_IMPL_OS_DIRSEP

#define RCPPUTILS_IMPL_OS_DIRSEP   '/'

A definition for this platforms string path separator