|
CPP-TOOLBOX
|
Namespaces | |
| namespace | directory_modifiction_callback_system |
| namespace | main |
Functions | |
| bool | path_exists (const std::string &path) |
| Check if a filesystem path exists. | |
| std::string | normalize_path_for_os (const std::string &path) |
| Normalize a path string to match the current operating system's conventions. | |
| std::string | get_path_delimiter () |
| Get the directory delimiter for the current operating system. | |
| std::filesystem::path | expand_tilde (const std::filesystem::path &path) |
| Expand a leading tilde (~) to the user's home directory. | |
| std::vector< std::filesystem::path > | rec_get_all_files (const std::string &base_dir, const std::vector< std::string > &ignore_dirs, int limit=1000) |
| Recursively get all files from a base directory. | |
| std::filesystem::path | get_directory_from_filepath (const std::filesystem::path &filepath) |
| Extract the directory component from a full file path. | |
| bool | has_extension (const std::filesystem::path &file_path, const std::string &extension) |
| Check if a file path has a specific extension. | |
| std::string | get_containing_directory (const std::string &filepath) |
| Get the containing directory as a string. | |
| std::string | get_filename_from_path (const std::string &path_str) |
| Extract the filename from a full path string. | |
| std::filesystem::path | get_parent_directory (const std::filesystem::path ¤t_dir) |
| Get the parent directory of a given path. | |
| std::filesystem::path | get_home_directory () |
| Get the home directory of the current user. | |
| std::vector< std::filesystem::path > | list_files_and_directories (const std::filesystem::path &path, bool include_hidden=false) |
| List files and directories in a given path. | |
| std::vector< std::filesystem::path > | list_files_in_directory (const std::filesystem::path &path) |
| List only files in a given directory (non-recursive). | |
| std::vector< std::filesystem::path > | list_files_matching_regex (const std::filesystem::path &path, const std::string &pattern_str) |
| List files matching a regular expression pattern. | |
| bool | file_exists_in_same_dir (const std::filesystem::path &file_path, const std::filesystem::path &target_file_name) |
| Check if a target file exists in the same directory as another file. | |
| bool | create_directory (const std::filesystem::path &dir_path) |
| Create a new directory. | |
| bool | create_file_with_content (const std::filesystem::path &file_path, const std::string &content) |
| Create a new file and write content to it. | |
| bool | create_file_with_content_if_different (const std::filesystem::path &file_path, const std::string &content) |
| Create or update a file only if the new content differs from the current one. | |
| std::string | get_directory_of_file (const std::string &file_path) |
| Get the directory containing a given file. | |
| std::filesystem::path | get_relative_path (const std::filesystem::path &source, const std::filesystem::path &target) |
| Get the relative path from a source to a target. | |
| bool fs_utils::create_directory | ( | const std::filesystem::path & | dir_path | ) |
Create a new directory.
| dir_path | Path of the directory to create. |
| bool fs_utils::create_file_with_content | ( | const std::filesystem::path & | file_path, |
| const std::string & | content ) |
Create a new file and write content to it.
Ensures the parent directory exists before writing. If the directory cannot be created or the file cannot be opened for writing, the function returns false.
| file_path | Path of the file to create. |
| content | Content to write into the file. |
| bool fs_utils::create_file_with_content_if_different | ( | const std::filesystem::path & | file_path, |
| const std::string & | content ) |
Create or update a file only if the new content differs from the current one.
If the target file already exists, its contents are read and compared with the new content. The file is rewritten only if the content differs. Otherwise, no write operation is performed.
Internally calls create_file_with_content() for the actual writing and directory creation.
| file_path | Path of the file to create or update. |
| content | Content to write into the file. |
| std::filesystem::path fs_utils::expand_tilde | ( | const std::filesystem::path & | path | ) |
Expand a leading tilde (~) to the user's home directory.
| path | Path potentially starting with "~". |
| bool fs_utils::file_exists_in_same_dir | ( | const std::filesystem::path & | file_path, |
| const std::filesystem::path & | target_file_name ) |
Check if a target file exists in the same directory as another file.
| file_path | Path to a reference file. |
| target_file_name | Name of the target file. |
| std::string fs_utils::get_containing_directory | ( | const std::string & | filepath | ) |
Get the containing directory as a string.
| filepath | Full file path. |
| std::filesystem::path fs_utils::get_directory_from_filepath | ( | const std::filesystem::path & | filepath | ) |
Extract the directory component from a full file path.
| filepath | Full file path. |
| std::string fs_utils::get_directory_of_file | ( | const std::string & | file_path | ) |
Get the directory containing a given file.
| file_path | File path. |
| std::string fs_utils::get_filename_from_path | ( | const std::string & | path_str | ) |
Extract the filename from a full path string.
| path_str | Input path string. |
| std::filesystem::path fs_utils::get_home_directory | ( | ) |
Get the home directory of the current user.
| std::filesystem::path fs_utils::get_parent_directory | ( | const std::filesystem::path & | current_dir | ) |
Get the parent directory of a given path.
| current_dir | Input path. |
| std::string fs_utils::get_path_delimiter | ( | ) |
Get the directory delimiter for the current operating system.
| std::filesystem::path fs_utils::get_relative_path | ( | const std::filesystem::path & | source, |
| const std::filesystem::path & | target ) |
Get the relative path from a source to a target.
| source | Base path. |
| target | Target path. |
| bool fs_utils::has_extension | ( | const std::filesystem::path & | file_path, |
| const std::string & | extension ) |
Check if a file path has a specific extension.
| file_path | Path to the file. |
| extension | Extension to check (with or without dot). |
| std::vector< std::filesystem::path > fs_utils::list_files_and_directories | ( | const std::filesystem::path & | path, |
| bool | include_hidden = false ) |
List files and directories in a given path.
| path | Directory to list. |
| include_hidden | Whether to include hidden files (default: false). |
| std::vector< std::filesystem::path > fs_utils::list_files_in_directory | ( | const std::filesystem::path & | path | ) |
List only files in a given directory (non-recursive).
| path | Directory to list. |
| std::vector< std::filesystem::path > fs_utils::list_files_matching_regex | ( | const std::filesystem::path & | path, |
| const std::string & | pattern_str ) |
List files matching a regular expression pattern.
| path | Directory to search. |
| pattern_str | Regular expression pattern as a string. |
| std::string fs_utils::normalize_path_for_os | ( | const std::string & | path | ) |
Normalize a path string to match the current operating system's conventions.
Converts delimiters and resolves inconsistencies.
| path | Input path string. |
| bool fs_utils::path_exists | ( | const std::string & | path | ) |
Check if a filesystem path exists.
| path | Path string to check. |
| std::vector< std::filesystem::path > fs_utils::rec_get_all_files | ( | const std::string & | base_dir, |
| const std::vector< std::string > & | ignore_dirs, | ||
| int | limit = 1000 ) |
Recursively get all files from a base directory.
| base_dir | Directory to search. |
| ignore_dirs | Directories to exclude. |
| limit | Maximum number of files to return (default: 1000). |