BoosterSeat
0.1
A C++ library that includes common utilities that are used in other projects.
|
Namespaces | |
units | |
Functions | |
void | appendToFile (const std::string &file_path, const std::string &content, const bool new_line_after=true) |
Append a string to a file. More... | |
void | copyFile (const std::string &source_path, const std::string &destination_path, bool overwrite=false) |
Move a file from one location to another. More... | |
void | createDirectory (const std::string &directory_path) |
Create a Directory at the specified path. More... | |
void | createFile (const std::string &file_path) |
Create a File. More... | |
void | deleteFile (const std::string &file_path) |
Delete a file. More... | |
bool | doesDirectoryExist (const std::string &directory_path) |
Returns a boolean indicating whether or not the directory exists. More... | |
bool | doesFileExist (const std::string &file_path) |
Returns a boolean indicating whether or not the file exists. If it's a directory an exception will be thrown. More... | |
double | getDirectorySize (const std::string &directory_path, units::Size unit=units::Size::BYTES) |
Get the size of a directory. Only includes regular files. More... | |
std::string | getFileName (const std::string &file_path) |
Get the File Name from a path. Does not need to exist. More... | |
double | getFileSize (const std::string &file_path, units::Size size_unit=units::Size::BYTES) |
Get the size of a file. More... | |
uintmax_t | getFileSizeBytes (const std::string &file_path) |
Get the size of a file. More... | |
bool | hasReadPermission (const std::string &path) |
If a program has read permissions to a file or directory, it will return true. Otherwise, it will return false. More... | |
bool | hasWritePermission (const std::string &path) |
If a program has write permissions to a file or directory, it will return true. Otherwise, it will return false. More... | |
void | moveFile (const std::string &source_path, const std::string &destination_path, bool overwrite=false) |
Move a file from one location to another. More... | |
void | overwriteFile (const std::string &file_path, const std::string &content) |
Overwrite a files with a string. More... | |
bool bst::filesystem::doesFileExist | ( | const std::string & | file_path | ) |
Returns a boolean indicating whether or not the file exists. If it's a directory an exception will be thrown.
file_path | The path to the file. |
BoosterSeatException | - If the path is a directory. error. |
Referenced by TEST().
void bst::filesystem::createFile | ( | const std::string & | file_path | ) |
Create a File.
file_path | The path to the file. |
BoosterSeatException | - If the file already exists or cannot be created. |
Referenced by TEST().
void bst::filesystem::appendToFile | ( | const std::string & | file_path, |
const std::string & | content, | ||
const bool | new_line_after = true |
||
) |
Append a string to a file.
file_path | - The path to the file. |
content | - A string to append to the file. |
new_line_after | - default true - If true, a new line will be added after the data. |
BoosterSeatException | - If the file already exists, the program does not have write permissions, or the file cannot be opened. |
Referenced by TEST().
void bst::filesystem::overwriteFile | ( | const std::string & | file_path, |
const std::string & | content | ||
) |
Overwrite a files with a string.
file_path | - The path to the file. |
content | - A string to overwrite the file with. |
BoosterSeatException | - If the file already exists, the program does not have write permissions, or the file cannot be opened. |
Referenced by TEST().
double bst::filesystem::getFileSize | ( | const std::string & | file_path, |
units::Size | size_unit = units::Size::BYTES |
||
) |
Get the size of a file.
file_path | - The path to the file |
unit | - The unit to return the size in. (default: bytes) |
BoosterSeatException | - If the path is not a regular file, the size cannot be determined, or the file does not exist. |
Referenced by TEST().
uintmax_t bst::filesystem::getFileSizeBytes | ( | const std::string & | file_path | ) |
Get the size of a file.
file_path | - The path to the file |
unit | - The unit to return the size in. (default: bytes) |
BoosterSeatException | - If the path is not a regular file, the size cannot be determined, or the file does not exist. |
Referenced by TEST().
void bst::filesystem::deleteFile | ( | const std::string & | file_path | ) |
Delete a file.
file_path | - The path to the file. |
BoosterSeatException | - If the file does not exist, the program does not have write permissions, or the file cannot be deleted. |
Referenced by TEST().
bool bst::filesystem::doesDirectoryExist | ( | const std::string & | directory_path | ) |
Returns a boolean indicating whether or not the directory exists.
directory_path | - The path to the directory. |
BoosterSeatException | - If the path is a file, or the program does not have permissions to read the size of the directory. |
Referenced by TEST().
void bst::filesystem::createDirectory | ( | const std::string & | directory_path | ) |
Create a Directory at the specified path.
directory_path | - The path to the directory, including the directory name. (e.g. /home/user/MyNewDirectory) |
BoosterSeatException | - If the directory already exists, the program does not have write permissions, or the directory cannot be created. |
Referenced by TEST().
double bst::filesystem::getDirectorySize | ( | const std::string & | directory_path, |
units::Size | unit = units::Size::BYTES |
||
) |
Get the size of a directory. Only includes regular files.
directory_path | - The path to the directory |
unit | - The unit to return the size in. (default: bytes) |
recursive | - If true, the size of all subdirectories will be included. |
BoosterSeatException | - If the path is not a directory, the size cannot be determined, or the directory does not exist. |
Referenced by TEST().
bool bst::filesystem::hasWritePermission | ( | const std::string & | path | ) |
If a program has write permissions to a file or directory, it will return true. Otherwise, it will return false.
path | - The path to the file or directory. |
Referenced by TEST().
bool bst::filesystem::hasReadPermission | ( | const std::string & | path | ) |
If a program has read permissions to a file or directory, it will return true. Otherwise, it will return false.
path | - The path to the file or directory. |
Referenced by TEST().
void bst::filesystem::moveFile | ( | const std::string & | source_path, |
const std::string & | destination_path, | ||
bool | overwrite = false |
||
) |
Move a file from one location to another.
source_path | - The path to the file to move. |
destination_path | - The path to move the file to. |
Referenced by TEST().
void bst::filesystem::copyFile | ( | const std::string & | source_path, |
const std::string & | destination_path, | ||
bool | overwrite = false |
||
) |
Move a file from one location to another.
source_path | - The path to the file to move. |
destination_path | - The path to move the file to. |
overwrite | - If true , the destination file will be overwritten if it exists. |
BoosterSeatException | - If the source file does not exist. |
BoosterSeatException | - If the destination file already exists and overwrite is false. |
Referenced by TEST().
std::string bst::filesystem::getFileName | ( | const std::string & | file_path | ) |
Get the File Name from a path. Does not need to exist.
file_path | - The path to the file. |
Referenced by TEST().