Functions | |
std::string | getHomeDirectory () |
Gets the home directory of the current user. | |
bool | checkCommandExists (const std::string &command) |
Checks if a command exists in the system. | |
std::vector< struct timespec > | getAccessChangeModifyTimeOfFile (const std::string &file) |
Gets the access, change, and modify times of a file. | |
bool | touchFile (const std::string &file, std::optional< struct timespec > targetTimeOrNow) |
Updates the access and modification times of a file. | |
std::string | getFileOwner (const std::string &filePath) |
Gets the owner of a file. | |
std::vector< uint8_t > | readContentFromFile (const std::string &file) |
Reads the content of a file into a vector of bytes. | |
std::string | readContentFromFileAsString (const std::string &file) |
Reads the content of a file into a string. | |
std::vector< std::string > | readContentFromFileLineByLine (const std::string &filePath) |
Reads the content of a file line by line. | |
void | writeContent2File (const std::string &file, const uint8_t *buffer, size_t bufferLength) |
Writes a buffer of bytes to a file. | |
void | writeContent2File (const std::string &file, const std::string &content) |
Writes a string to a file. | |
bool | removeFile (const std::string &filePath) |
Removes a file. | |
std::vector< fs::path > | listFilesWithExtension (fs::path folderPath, std::string prefix="", std::string surfix="") |
Lists files in a directory with a specific prefix and suffix. | |
std::vector< fs::path > | listFilesRecursivelyWithExtension (fs::path folderPath, std::string prefix="", std::string surfix="") |
Recursively lists files in a directory with a specific prefix and suffix. | |
template<typename ParseType > | |
ParseType | readValueFromFilePath (const std::string &path) |
Reads a value from a file path. | |
template<typename ParseType > | |
int | writeValue2FilePath (const std::string &path, const ParseType &value, const std::string &formatStr="{}") |
Writes a value to a file path. | |
bool SystemTools::File::checkCommandExists | ( | const std::string & | command | ) |
Checks if a command exists in the system.
command | The command to check. |
std::vector< struct timespec > SystemTools::File::getAccessChangeModifyTimeOfFile | ( | const std::string & | file | ) |
Gets the access, change, and modify times of a file.
file | The file path. |
std::string SystemTools::File::getFileOwner | ( | const std::string & | filePath | ) |
Gets the owner of a file.
filePath | The file path. |
std::string SystemTools::File::getHomeDirectory | ( | ) |
Gets the home directory of the current user.
std::vector< fs::path > SystemTools::File::listFilesRecursivelyWithExtension | ( | fs::path | folderPath, |
std::string | prefix = "" , |
||
std::string | surfix = "" |
||
) |
Recursively lists files in a directory with a specific prefix and suffix.
folderPath | The directory path. |
prefix | The prefix to match. |
surfix | The suffix to match. |
std::vector< fs::path > SystemTools::File::listFilesWithExtension | ( | fs::path | folderPath, |
std::string | prefix = "" , |
||
std::string | surfix = "" |
||
) |
Lists files in a directory with a specific prefix and suffix.
folderPath | The directory path. |
prefix | The prefix to match. |
surfix | The suffix to match. |
std::vector< uint8_t > SystemTools::File::readContentFromFile | ( | const std::string & | file | ) |
Reads the content of a file into a vector of bytes.
file | The file path. |
std::string SystemTools::File::readContentFromFileAsString | ( | const std::string & | file | ) |
Reads the content of a file into a string.
file | The file path. |
std::vector< std::string > SystemTools::File::readContentFromFileLineByLine | ( | const std::string & | filePath | ) |
Reads the content of a file line by line.
filePath | The file path. |
ParseType SystemTools::File::readValueFromFilePath | ( | const std::string & | path | ) |
Reads a value from a file path.
ParseType | The type to parse the value as. |
path | The file path. |
Definition at line 218 of file SystemTools.hxx.
bool SystemTools::File::removeFile | ( | const std::string & | filePath | ) |
Removes a file.
filePath | The file path. |
bool SystemTools::File::touchFile | ( | const std::string & | file, |
std::optional< struct timespec > | targetTimeOrNow | ||
) |
Updates the access and modification times of a file.
file | The file path. |
targetTimeOrNow | Optional target time, or use current time if not specified. |
void SystemTools::File::writeContent2File | ( | const std::string & | file, |
const std::string & | content | ||
) |
Writes a string to a file.
file | The file path. |
content | The string content to write. |
void SystemTools::File::writeContent2File | ( | const std::string & | file, |
const uint8_t * | buffer, | ||
size_t | bufferLength | ||
) |
Writes a buffer of bytes to a file.
file | The file path. |
buffer | The buffer to write. |
bufferLength | The length of the buffer. |
int SystemTools::File::writeValue2FilePath | ( | const std::string & | path, |
const ParseType & | value, | ||
const std::string & | formatStr = "{}" |
||
) |
Writes a value to a file path.
ParseType | The type of the value. |
path | The file path. |
value | The value to write. |
formatStr | The format string for the value. |
Definition at line 244 of file SystemTools.hxx.