![]() |
Mantis App v0.2.8
|
Handle file management for record type files. More...
#include <fileunit.h>
Public Member Functions | |
FileUnit ()=default | |
void | createDir (const std::string &table) const |
Create a directory matching passed in table name. | |
void | renameDir (const std::string &old_name, const std::string &new_name) const |
Rename existing directory if found or create it if not found. | |
void | deleteDir (const std::string &table) const |
Delete table directory and its contents. | |
std::string | dirPath (const std::string &table, bool create_if_missing=false) const |
Fetch directory path string for a given table. | |
std::string | filePath (const std::string &table, const std::string &filename) const |
Fetch absolute path to where file is or would be for a given table and filename. | |
std::optional< std::string > | getFilePath (const std::string &table, const std::string &filename) const |
Fetch filename absolute path only if the file exists, else, return empty response. | |
bool | removeFile (const std::string &table, const std::string &filename) const |
Remove existing file given the table and filename. | |
Handle file management for record type files.
These files are the usual file assets stored in either file
or files
filed type. The idea here being, the file is stored on disk and the name saved to the database.
The class should handle:
|
default |
void mantis::FileUnit::createDir | ( | const std::string & | table | ) | const |
Create a directory matching passed in table
name.
table | Table name to created directory for |
void mantis::FileUnit::deleteDir | ( | const std::string & | table | ) | const |
Delete table directory and its contents.
table | Table name |
std::string mantis::FileUnit::dirPath | ( | const std::string & | table, |
bool | create_if_missing = false |
||
) | const |
Fetch directory path string for a given table.
table | Table name |
create_if_missing | Bool status to know whether to create directory if missing |
std::string mantis::FileUnit::filePath | ( | const std::string & | table, |
const std::string & | filename | ||
) | const |
Fetch absolute path to where file is or would be for a given table and filename.
table | Table name |
filename | File name |
std::optional< std::string > mantis::FileUnit::getFilePath | ( | const std::string & | table, |
const std::string & | filename | ||
) | const |
Fetch filename absolute path only if the file exists, else, return empty response.
table | Table name |
filename | FIle name |
bool mantis::FileUnit::removeFile | ( | const std::string & | table, |
const std::string & | filename | ||
) | const |
Remove existing file given the table and filename.
table | Table name |
filename | File name |
void mantis::FileUnit::renameDir | ( | const std::string & | old_name, |
const std::string & | new_name | ||
) | const |
Rename existing directory if found or create it if not found.
old_name | Old table name |
new_name | New table name |