MantisBase v0.3.4
Loading...
Searching...
No Matches
files.h
Go to the documentation of this file.
1
9#ifndef MANTIS_FILES_H
10#define MANTIS_FILES_H
11
12#include <optional>
13#include <string>
14#include <vector>
15#include "../utils/utils.h"
16
17namespace mb
18{
49 class Files
50 {
51 public:
61 static void createDir(const std::string& entity_name);
62
73 static void renameDir(const std::string& old_entity_name, const std::string& new_entity_name);
74
80 static void deleteDir(const std::string& entity_name);
81
93 static std::string dirPath(const std::string& entity_name, bool create_if_missing = false);
94
106 static std::string filePath(const std::string& entity_name, const std::string& filename);
107
119 static std::optional<std::string> getFilePath(const std::string& entity_name, const std::string& filename);
120
128 static bool removeFile(const std::string& entity_name, const std::string& filename);
129
136 static void removeFiles(const std::string& entity_name, const std::vector<std::string>& files);
137
145 static bool fileExists(const std::string& entity_name, const std::string& filename);
146
157 static fs::path getCanonicalPath(const fs::path& path);
158
168 static bool isCanonicalPath(const fs::path& path);
169
177 static fs::path filesBaseDir();
178 };
179} // mb
180
181#endif // MANTIS_FILES_H
File management for entity file assets.
Definition files.h:50
static bool isCanonicalPath(const fs::path &path)
Check if a path is canonical and within the files base directory.
Definition files.cpp:198
static void removeFiles(const std::string &entity_name, const std::vector< std::string > &files)
Remove multiple files from an entity's directory.
Definition files.cpp:136
static void createDir(const std::string &entity_name)
Create a directory for the given entity.
Definition files.cpp:16
static bool removeFile(const std::string &entity_name, const std::string &filename)
Remove a file from an entity's directory.
Definition files.cpp:119
static std::optional< std::string > getFilePath(const std::string &entity_name, const std::string &filename)
Get file path only if the file exists.
Definition files.cpp:63
static std::string dirPath(const std::string &entity_name, bool create_if_missing=false)
Get the directory path for an entity.
Definition files.cpp:77
static fs::path getCanonicalPath(const fs::path &path)
Get canonical path and verify it's within the files base directory.
Definition files.cpp:153
static bool fileExists(const std::string &entity_name, const std::string &filename)
Check if a file exists in an entity's directory.
Definition files.cpp:143
static std::string filePath(const std::string &entity_name, const std::string &filename)
Get the absolute file path for an entity and filename.
Definition files.cpp:103
static void renameDir(const std::string &old_entity_name, const std::string &new_entity_name)
Rename an entity directory.
Definition files.cpp:33
static fs::path filesBaseDir()
Get the base directory for all entity files.
Definition files.cpp:241
static void deleteDir(const std::string &entity_name)
Delete an entity directory and all its contents.
Definition files.cpp:57
router.h
Definition auth.h:15