mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-26 02:20:54 +00:00
Changed: #1023 Use a standard application path for writing files
This commit is contained in:
parent
6b705c278a
commit
85c6498504
1 changed files with 16 additions and 0 deletions
|
@ -1966,7 +1966,23 @@ void CClientConfig::serial(class NLMISC::IStream &f) throw(NLMISC::EStream)
|
||||||
void CClientConfig::init(const string &configFileName)
|
void CClientConfig::init(const string &configFileName)
|
||||||
{
|
{
|
||||||
if(!CFile::fileExists(configFileName))
|
if(!CFile::fileExists(configFileName))
|
||||||
|
{
|
||||||
|
#if defined(NL_ETC_PREFIX) && defined(NL_SHARE_PREFIX)
|
||||||
|
nlwarning("CFG::init: creating '%s' with default values", configFileName.c_str ());
|
||||||
|
|
||||||
|
// create the basic .cfg that link the default one
|
||||||
|
FILE *fp = fopen(configFileName.c_str(), "w");
|
||||||
|
if (fp == NULL)
|
||||||
|
{
|
||||||
|
nlerror ("CFG::init: Can't create config file '%s'", configFileName.c_str());
|
||||||
|
}
|
||||||
|
fprintf(fp, "RootConfigFilename = \"%s/client_default.cfg\";\n", NL_ETC_PREFIX);
|
||||||
|
fprintf(fp, "DataPath = { \"%s/data\" };\n", NL_SHARE_PREFIX);
|
||||||
|
fclose(fp);
|
||||||
|
#else
|
||||||
nlwarning("CFG::init: '%s' Not Found !!!", configFileName.c_str ());
|
nlwarning("CFG::init: '%s' Not Found !!!", configFileName.c_str ());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// if the config file will be modified, it calls automatically the function setValuesOnFileChange()
|
// if the config file will be modified, it calls automatically the function setValuesOnFileChange()
|
||||||
ClientCfg.ConfigFile.setCallback (CClientConfig::setValuesOnFileChange);
|
ClientCfg.ConfigFile.setCallback (CClientConfig::setValuesOnFileChange);
|
||||||
|
|
Loading…
Reference in a new issue