Changed config file path
Config file is now stored under ~/.config in Linux, and %AppData%\Roaming in Windows. Custom prefix has been changed to %AppData%\Local\Facecam2D in Windows, instead of the improper %AppData%\Facecam2D. MacOS paths remain unchanged.
This commit is contained in:
parent
378bcf7f16
commit
e5a1cdd6da
|
@ -7,7 +7,7 @@
|
||||||
#include <tomlcpp.hpp>
|
#include <tomlcpp.hpp>
|
||||||
|
|
||||||
bool configFileOpen(struct optData* data) {
|
bool configFileOpen(struct optData* data) {
|
||||||
auto configFile = toml::parseFile(prefixCustom + "config.toml");
|
auto configFile = toml::parseFile(prefixConfig + "config.toml");
|
||||||
if (!configFile.table) {
|
if (!configFile.table) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,6 @@ ConfigurationFrame::ConfigurationFrame() : wxFrame(NULL, wxID_ANY, "Configure "
|
||||||
bottomButtonSizer->Add(applyButton, 0, wxALL, 5);
|
bottomButtonSizer->Add(applyButton, 0, wxALL, 5);
|
||||||
|
|
||||||
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
sizer->Add(placeholderText, 0, wxALL | wxALIGN_LEFT, 10);
|
|
||||||
sizer->Add(useHaarCheckBox, 0, wxALL | wxALIGN_LEFT, 5);
|
sizer->Add(useHaarCheckBox, 0, wxALL | wxALIGN_LEFT, 5);
|
||||||
sizer->Add(modelNameChoice, 0, wxALL | wxALIGN_LEFT, 5);
|
sizer->Add(modelNameChoice, 0, wxALL | wxALIGN_LEFT, 5);
|
||||||
sizer->AddStretchSpacer(1);
|
sizer->AddStretchSpacer(1);
|
||||||
|
@ -77,7 +76,7 @@ ConfigurationFrame::ConfigurationFrame() : wxFrame(NULL, wxID_ANY, "Configure "
|
||||||
void ConfigurationFrame::OnApply(wxCommandEvent& event) {
|
void ConfigurationFrame::OnApply(wxCommandEvent& event) {
|
||||||
// write options to config file
|
// write options to config file
|
||||||
std::ofstream configFile;
|
std::ofstream configFile;
|
||||||
configFile.open(prefixCustom + "config.toml");
|
configFile.open(prefixConfig + "config.toml");
|
||||||
configFile << "use_haar = " << (useHaarCheckBox->GetValue() ? "true" : "false") << std::endl;
|
configFile << "use_haar = " << (useHaarCheckBox->GetValue() ? "true" : "false") << std::endl;
|
||||||
// janky edge case lmao
|
// janky edge case lmao
|
||||||
// if user did not select any model, don't write the line in the config file!
|
// if user did not select any model, don't write the line in the config file!
|
||||||
|
|
|
@ -9,18 +9,23 @@
|
||||||
#define READABLE(p) access(p.c_str(),R_OK)==0
|
#define READABLE(p) access(p.c_str(),R_OK)==0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string prefixCustom;
|
std::string prefixConfig; // directory to store config.toml in
|
||||||
std::string prefixDefault;
|
std::string prefixCustom; // directory for user-accessible models and cvdata
|
||||||
|
std::string prefixDefault; // directory for pre-installed models and cvdata
|
||||||
|
|
||||||
void initPrefixes() {
|
void initPrefixes() {
|
||||||
#if defined (__gnu_linux__)
|
#if defined (__gnu_linux__)
|
||||||
|
prefixConfig = getenv("HOME") + std::string("/.config/facecam2d/");
|
||||||
prefixCustom = getenv("HOME") + std::string("/.local/share/facecam2d/");
|
prefixCustom = getenv("HOME") + std::string("/.local/share/facecam2d/");
|
||||||
prefixDefault = "/usr/share/facecam2d/";
|
prefixDefault = "/usr/share/facecam2d/";
|
||||||
#elif defined (__APPLE__)
|
#elif defined (__APPLE__)
|
||||||
|
// config and supporting files are both stored in Library on MacOS
|
||||||
|
prefixConfig = getenv("HOME") + std::string("/Library/Facecam2D/");
|
||||||
prefixCustom = getenv("HOME") + std::string("/Library/Facecam2D/");
|
prefixCustom = getenv("HOME") + std::string("/Library/Facecam2D/");
|
||||||
prefixDefault = "/Applications/Facecam2D.app/";
|
prefixDefault = "/Applications/Facecam2D.app/";
|
||||||
#elif defined (_WIN32)
|
#elif defined (_WIN32)
|
||||||
prefixCustom = getenv("AppData") + std::string("\\Facecam2D\\");
|
prefixConfig = getenv("AppData") + std::string("\\Roaming\\Facecam2D\\");
|
||||||
|
prefixCustom = getenv("AppData") + std::string("\\Local\\Facecam2D\\");
|
||||||
prefixDefault = getenv("ProgramFiles") + std::string("\\Facecam2D\\");
|
prefixDefault = getenv("ProgramFiles") + std::string("\\Facecam2D\\");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
extern std::string prefixConfig;
|
||||||
extern std::string prefixCustom;
|
extern std::string prefixCustom;
|
||||||
extern std::string prefixDefault;
|
extern std::string prefixDefault;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue