CONFIGFILE::CONFIGFILE(const string & fn, bool nook)
: param_val(StringCaseCmp),
fileName(fn),
- error(0)
+ error(0),
+ changed(false)
{
ifstream f(fileName.c_str());
void CONFIGFILE::WriteString(const string & param, const string &val)
{
param_val[param] = val;
+changed = true;
}
//---------------------------------------------------------------------------
int CONFIGFILE::ReadTime(const string & param, time_t * val, time_t defaultVal) const
string s;
x2str(val, s);
param_val[param] = s;
+changed = true;
}
//---------------------------------------------------------------------------
int CONFIGFILE::ReadDouble(const string & param, double * val, double defaultVal) const
char s[30];
snprintf(s, 30, "%f", val);
param_val[param] = s;
+changed = true;
}
//---------------------------------------------------------------------------
int CONFIGFILE::Flush(const std::string & path) const
//---------------------------------------------------------------------------
int CONFIGFILE::Flush() const
{
+if (!changed)
+ return 0;
+
std::string pid;
x2str(getpid(), pid);
if (rename((fileName + "." + pid).c_str(), fileName.c_str()))
return -1;
+changed = false;
+
return 0;
}
//---------------------------------------------------------------------------