mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-08-09 00:52:25 -04:00
Duplicate default config to new config files
This commit is contained in:
parent
13139c7dbf
commit
ddedc984b0
@ -199,11 +199,11 @@ void AppConfig::setConfigName(std::string configName) {
|
|||||||
this->configName = configName;
|
this->configName = configName;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AppConfig::getConfigFileName() {
|
std::string AppConfig::getConfigFileName(bool ignoreName) {
|
||||||
std::string cfgFileDir = getConfigDir();
|
std::string cfgFileDir = getConfigDir();
|
||||||
|
|
||||||
wxFileName cfgFile;
|
wxFileName cfgFile;
|
||||||
if (configName.length()) {
|
if (configName.length() && !ignoreName) {
|
||||||
std::string tempFn("config-");
|
std::string tempFn("config-");
|
||||||
tempFn.append(configName);
|
tempFn.append(configName);
|
||||||
tempFn.append(".xml");
|
tempFn.append(".xml");
|
||||||
@ -261,8 +261,24 @@ bool AppConfig::load() {
|
|||||||
wxFileName cfgFile = wxFileName(cfgFileName);
|
wxFileName cfgFile = wxFileName(cfgFileName);
|
||||||
|
|
||||||
if (!cfgFile.Exists()) {
|
if (!cfgFile.Exists()) {
|
||||||
|
if (configName.length()) {
|
||||||
|
wxFileName baseConfig = wxFileName(getConfigFileName(true));
|
||||||
|
if (baseConfig.Exists()) {
|
||||||
|
std::string baseConfigFileName = baseConfig.GetFullPath(wxPATH_NATIVE).ToStdString();
|
||||||
|
std::cout << "Creating new configuration file '" << cfgFileName << "' by copying '" << baseConfigFileName << "'..";
|
||||||
|
wxCopyFile(baseConfigFileName, cfgFileName);
|
||||||
|
if (!cfgFile.Exists()) {
|
||||||
|
std::cout << "failed." << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
std::cout << "ok." << std::endl;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (cfgFile.IsFileReadable()) {
|
if (cfgFile.IsFileReadable()) {
|
||||||
std::cout << "Loading:: configuration file '" << cfgFileName << "'" << std::endl;
|
std::cout << "Loading:: configuration file '" << cfgFileName << "'" << std::endl;
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
long long getSnap();
|
long long getSnap();
|
||||||
|
|
||||||
void setConfigName(std::string configName);
|
void setConfigName(std::string configName);
|
||||||
std::string getConfigFileName();
|
std::string getConfigFileName(bool ignoreName=false);
|
||||||
bool save();
|
bool save();
|
||||||
bool load();
|
bool load();
|
||||||
bool reset();
|
bool reset();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user