Facilitates file I/O, path normalization, and directory operations in a cross-platform manner. Its classes and functions simplify reading, writing, creating, or deleting files and directories, handling discrepancies in path formats, symbolic links, and OS-specific peculiarities.
More...
|
| class | path |
| |
| class | stdout_redirector |
| | Class for redirecting stdout to a file and subsequently resetting it to the system's default state. More...
|
| |
|
| std::string | read_file (std::filesystem::path file_path) |
| | Reads the given file as std::string. Throws cbeam::error::runtime_error in case of errors.
|
| |
| void | write_file (const std::filesystem::path &file_path, const std::string &content) |
| | Creates or overwrites the given file with the given content. Throws cbeam::error::runtime_error in case of errors.
|
| |
| void | touch (const std::filesystem::path &p) |
| | create a file under the given path, if it does not exist yet; otherwise, the file content is left unchanges, but its modification time is updated, analogous to bash touch
|
| |
| std::filesystem::path | unique_temp_file (const std::string &extension={}) |
| |
| std::filesystem::path | unique_temp_dir () |
| | get unique and non-existing temp directory
|
| |
| std::filesystem::path | create_unique_temp_file (const std::string &extension={}) |
| |
| std::filesystem::path | create_unique_temp_dir () |
| | create unique temp directory, analogous to bash mktemp -d
|
| |
| std::filesystem::path | get_home_dir () |
| | Retrieves the path to the user's home directory, based on the operating system.
|
| |
| std::filesystem::path | get_user_data_dir () |
| | Retrieves the path for storing user-specific application data.
|
| |
| std::filesystem::path | get_user_cache_dir () |
| | Retrieves the path for storing user-specific cache data.
|
| |
Facilitates file I/O, path normalization, and directory operations in a cross-platform manner. Its classes and functions simplify reading, writing, creating, or deleting files and directories, handling discrepancies in path formats, symbolic links, and OS-specific peculiarities.
◆ create_unique_temp_dir()
| std::filesystem::path cbeam::filesystem::create_unique_temp_dir |
( |
| ) |
|
|
inline |
create unique temp directory, analogous to bash mktemp -d
◆ create_unique_temp_file()
| std::filesystem::path cbeam::filesystem::create_unique_temp_file |
( |
const std::string & | extension = {} | ) |
|
|
inline |
create unique temp file, analogous to bash mktemp
- Parameters
-
| extension | optional file extension |
- Returns
- the full path to a new empty file
◆ get_home_dir()
| std::filesystem::path cbeam::filesystem::get_home_dir |
( |
| ) |
|
|
inline |
Retrieves the path to the user's home directory, based on the operating system.
On Windows, it uses SHGetKnownFolderPath(FOLDERID_Profile). On Linux or Darwin, it uses getpwuid(getuid()).
- Returns
- A
std::filesystem::path corresponding to the user's home folder.
- Exceptions
-
◆ get_user_cache_dir()
| std::filesystem::path cbeam::filesystem::get_user_cache_dir |
( |
| ) |
|
|
inline |
Retrieves the path for storing user-specific cache data.
On Windows, this is typically LocalAppData%. On Linux, it returns ~/.cache. On macOS, it returns ~/Library/Caches.
- Returns
- A
std::filesystem::path corresponding to the user-specific cache folder.
- Exceptions
-
◆ get_user_data_dir()
| std::filesystem::path cbeam::filesystem::get_user_data_dir |
( |
| ) |
|
|
inline |
Retrieves the path for storing user-specific application data.
On Windows, this is typically AppData%. On Linux, it returns ~/.local/share. On macOS, it returns ~/Library/Application Support.
- Returns
- A
std::filesystem::path corresponding to the user-specific application data folder.
- Exceptions
-
◆ read_file()
| std::string cbeam::filesystem::read_file |
( |
std::filesystem::path | file_path | ) |
|
|
inline |
◆ touch()
| void cbeam::filesystem::touch |
( |
const std::filesystem::path & | p | ) |
|
|
inline |
create a file under the given path, if it does not exist yet; otherwise, the file content is left unchanges, but its modification time is updated, analogous to bash touch
◆ unique_temp_dir()
| std::filesystem::path cbeam::filesystem::unique_temp_dir |
( |
| ) |
|
|
inline |
get unique and non-existing temp directory
◆ unique_temp_file()
| std::filesystem::path cbeam::filesystem::unique_temp_file |
( |
const std::string & | extension = {} | ) |
|
|
inline |
get path to non-existing unique temp file
- Parameters
-
| extension | optional file extension |
- Returns
- the full path to a non-existing file
◆ write_file()
| void cbeam::filesystem::write_file |
( |
const std::filesystem::path & | file_path, |
|
|
const std::string & | content ) |
|
inline |