From 85c6498504684ac1975f13974c2b161043beecfc Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 16 Jul 2010 23:12:25 +0200 Subject: [PATCH] Changed: #1023 Use a standard application path for writing files --- code/ryzom/client/src/client_cfg.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index 87d4f038c..2bfec308e 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -1966,7 +1966,23 @@ void CClientConfig::serial(class NLMISC::IStream &f) throw(NLMISC::EStream) void CClientConfig::init(const string &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 ()); +#endif + } // if the config file will be modified, it calls automatically the function setValuesOnFileChange() ClientCfg.ConfigFile.setCallback (CClientConfig::setValuesOnFileChange);