Mantis App v0.2.8
Loading...
Searching...
No Matches
fileunit.h
Go to the documentation of this file.
1
6#ifndef FILEUNIT_H
7#define FILEUNIT_H
8
9#include <optional>
10#include <string>
11
12namespace mantis
13{
27 {
28 public:
29 FileUnit() = default;
30
36 void createDir(const std::string& table) const;
43 void renameDir(const std::string& old_name, const std::string& new_name) const;
49 void deleteDir(const std::string& table) const;
50
58 std::string dirPath(const std::string& table, bool create_if_missing = false) const;
66 std::string filePath(const std::string& table, const std::string& filename) const;
76 std::optional<std::string> getFilePath(const std::string& table, const std::string& filename) const;
84 bool removeFile(const std::string& table, const std::string& filename) const;
85 };
86} // mantis
87
88#endif //FILEUNIT_H
Handle file management for record type files.
Definition fileunit.h:27
void deleteDir(const std::string &table) const
Delete table directory and its contents.
Definition fileunit.cpp:39
std::string dirPath(const std::string &table, bool create_if_missing=false) const
Fetch directory path string for a given table.
Definition fileunit.cpp:65
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.
Definition fileunit.cpp:45
FileUnit()=default
void createDir(const std::string &table) const
Create a directory matching passed in table name.
Definition fileunit.cpp:17
bool removeFile(const std::string &table, const std::string &filename) const
Remove existing file given the table and filename.
Definition fileunit.cpp:80
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.
Definition fileunit.cpp:75
void renameDir(const std::string &old_name, const std::string &new_name) const
Rename existing directory if found or create it if not found.
Definition fileunit.cpp:27
router.h
Definition app.h:31