refactoredCPPNeuronMesher
|
Utility functions for file system operations. More...
#include <string>
#include <vector>
Go to the source code of this file.
Functions | |
std::string | getExecutableDir () |
Gets the directory containing the current executable. More... | |
void | checkFolder (std::string &folderPath) |
Ensures a directory exists, creating it if necessary. More... | |
void | deleteFolder (const std::string &path) |
Recursively deletes a directory and all its contents. More... | |
std::vector< std::string > | listFilesInDirectory (const std::string &path) |
Lists all regular files in a directory. More... | |
Utility functions for file system operations.
This header provides cross-platform utility functions for common file system operations used throughout the CPPNeuronMesher project. These utilities handle path manipulation, directory creation, and file listing.
void checkFolder | ( | std::string & | folderPath | ) |
Ensures a directory exists, creating it if necessary.
[in,out] | folderPath | Path to the directory to check/create |
This function checks if the specified directory exists and creates it (including any necessary parent directories) if it doesn't exist. The folderPath parameter is modified to contain an absolute path.
std::runtime_error | if the directory cannot be created |
Ensures a directory exists, creating it if necessary.
[in,out] | folderPath | Path to the folder to check/create |
This function checks if the specified folder exists. If it doesn't exist, it attempts to create the folder and all necessary parent directories. Status messages are printed to standard output/error streams.
void deleteFolder | ( | const std::string & | path | ) |
Recursively deletes a directory and all its contents.
[in] | path | Path to the directory to delete |
This function removes the specified directory and all files and subdirectories it contains. If the path does not exist, the function does nothing.
std::runtime_error | if the directory cannot be deleted |
[in] | path | Path to the directory to be deleted |
This function attempts to delete the specified directory and all its contents recursively. It uses std::filesystem::remove_all() for the operation. Status messages are printed to standard output/error streams.
std::string getExecutableDir | ( | ) |
Gets the directory containing the current executable.
This function retrieves the full path to the directory containing the currently running executable. The path is returned with a trailing directory separator.
Gets the directory containing the current executable.
This function determines the directory containing the currently running executable by resolving the symbolic link at "/proc/self/exe" and returning its parent directory.
std::vector<std::string> listFilesInDirectory | ( | const std::string & | path | ) |
Lists all regular files in a directory.
[in] | path | Path to the directory to scan |
This function returns a list of all regular files (not directories) in the specified directory. The returned filenames do not include the directory path.
std::runtime_error | if the directory cannot be accessed |
Lists all regular files in a directory.
[in] | path | Path to the directory to scan |
This function scans the specified directory and returns a list of all regular files it contains. The function only includes files (not directories) in the results.