[FS] Add app data folder, add path safety checks

This commit is contained in:
wheremyfoodat 2023-01-16 01:06:43 +02:00
parent c16bf5c8aa
commit b1f2be98fa
6 changed files with 77 additions and 12 deletions

View file

@ -19,6 +19,7 @@
class IOFile {
FILE* handle = nullptr;
static inline std::filesystem::path appData = ""; // Directory for holding app data. AppData on Windows
public:
bool isOpen() {
@ -81,4 +82,11 @@ public:
bool rewind() {
return seek(0, SEEK_SET);
}
static void setAppDataDir(const char* dir) {
if (!dir) Helpers::panic("Failed to set app data directory");
appData = std::filesystem::path(dir);
}
static std::filesystem::path getAppData() { return IOFile::appData; }
};