Make .local and .config directories on startup

Directories for the config file and custom data will be created when
Facecam2D starts.
This commit is contained in:
Epicalert 2021-07-03 00:19:14 +08:00
parent 07ccce90d3
commit b9c9cb3de4
No known key found for this signature in database
GPG key ID: CAA46F858D0979BD
4 changed files with 13 additions and 0 deletions

View file

@ -30,6 +30,8 @@ wxIMPLEMENT_APP(ConfigurationApp);
bool ConfigurationApp::OnInit() { bool ConfigurationApp::OnInit() {
initPrefixes(); initPrefixes();
makePaths();
// TODO: put config file creation here // TODO: put config file creation here

View file

@ -13,6 +13,7 @@ int main (int argc, char** argv) {
std::cout << PROJECT_NAME " is starting..." << std::endl; std::cout << PROJECT_NAME " is starting..." << std::endl;
initPrefixes(); initPrefixes();
makePaths();
// load config file and apply it // load config file and apply it
configFileOpen(&optData); configFileOpen(&optData);

View file

@ -1,6 +1,7 @@
#include <unistd.h> #include <unistd.h>
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
#include <filesystem>
#include <paths.hpp> #include <paths.hpp>
#ifdef _WIN32 #ifdef _WIN32
@ -30,6 +31,13 @@ void initPrefixes() {
#endif #endif
} }
void makePaths() {
std::filesystem::create_directories(prefixConfig);
std::filesystem::create_directories(prefixCustom + "models/");
std::filesystem::create_directories(prefixCustom + "cvdata/");
}
std::string resolvePath(const char* path) { std::string resolvePath(const char* path) {
std::string customString = prefixCustom + path; std::string customString = prefixCustom + path;
std::string defaultString = prefixDefault + path; std::string defaultString = prefixDefault + path;

View file

@ -9,6 +9,8 @@ extern std::string prefixDefault;
void initPrefixes(); void initPrefixes();
void makePaths();
std::string resolvePath(const char* path); std::string resolvePath(const char* path);
#endif #endif