67 FILE *configFile = fopen(configPath.c_str(),
"r");
68 if (configFile ==
nullptr)
70 configFile = fopen(configPath.c_str(),
"wb");
71 logger->
log(
"Creating new server config: " + configPath);
72 if (configFile !=
nullptr)
74 fputs(
"<?xml version=\"1.0\"?>\n", configFile);
75 fputs(
"<configuration>\n", configFile);
76 fputs(
"</configuration>\n", configFile);
79 if (configFile !=
nullptr)
86 logger->
log(
"serverConfigPath: " + configPath);
108 #if (defined __APPLE__)
110 #elif (defined ANDROID)
112 #elif (defined WIN32)
132 defaultUpdateHost.clear();
137 std::string configPath;
149 FILE *configFile = fopen(configPath.c_str(),
"r");
150 if (configFile ==
nullptr)
152 configFile = fopen(configPath.c_str(),
"wb");
154 if (configFile !=
nullptr)
156 fputs(
"<?xml version=\"1.0\"?>\n", configFile);
157 fputs(
"<configuration>\n", configFile);
158 fputs(
"</configuration>\n", configFile);
161 if (configFile ==
nullptr)
175 logger->
log(
"configuration file: " + configPath);
185 logger->
log(
"Config %s not exists, backup skipped.",
196 name).append(
".tmp");
202 "Probably no free space on disk.");
208 name).append(
".bak");
209 const int maxFileIndex = 5;
211 for (
int f = maxFileIndex; f > 1; f --)
213 const std::string fileName1 = confName +
toString(f - 1);
214 const std::string fileName2 = confName +
toString(f);
217 const std::string fileName4 = confName +
toString(1);
221 #ifdef __native_client__
245 #elif !defined(ANDROID)
257 std::string particleFont;
258 std::string helpFont;
259 std::string secureFont;
261 std::string japanFont;
262 std::string chinaFont;
265 bool enableMapReduce;
321 #if defined(__APPLE__)
367 #define unassignKey(key, value) \
368 if (config.getStringValue(prefix + (key)) == (value)) \
369 config.setValue(key, "-1");
427 const std::string prefix = std::string(
"sdl2");
430 const std::string prefix = std::string();
441 const std::string prefix = std::string(
"sdl2");
444 const std::string prefix = std::string();
#define reportAlways(...)
static void initServerConfig(const std::string &serverName)
static void backupConfig(const std::string &name)
static void storeSafeParameters()
static void checkConfigVersion()
static void initConfiguration()
std::string getValue(const std::string &key, const std::string &deflt) const
void deleteKey(const std::string &key)
bool getBoolValue(const std::string &key) const
std::string getStringValue(const std::string &key) const
void setValue(const std::string &key, const std::string &value)
void init(const std::string &filename, const UseVirtFs useResManager, const SkipError skipError)
int getIntValue(const std::string &key) const
void log(const char *const log_text,...)
void log1(const char *const log_text)
void safeError(const std::string &error_text) __attribute__((noreturn))
void error(const std::string &error_text) __attribute__((noreturn))
std::string serverConfigDir
#define unassignKey(key, value)
static void setDefaultOption(const char *const name, const bool def)
Configuration serverConfig
void setConfigDefaults(Configuration &cfg)
int mkdir_r(const char *const pathname)
Create a directory, making leading components first if necessary.
std::string toString(T const &value)
converts any type to a string
bool loadTextFileLocal(const std::string &fileName, StringVect &lines)
int renameFile(const std::string &pFrom, const std::string &pTo)
int copyFile(const std::string &pFrom, const std::string &pTo)
bool existsLocal(const std::string &path)
bool remove(const std::string &filename)
bool checkPath(const std::string &path)
RenderType intToRenderType(const int mode)
const bool SkipError_false
std::string strprintf(const char *const format,...)
std::string pathJoin(std::string str1, const std::string &str2)
std::vector< std::string > StringVect
const bool UseVirtFs_false