MCPcopy Create free account
hub / github.com/Stewmath/GameYob / readConfigFile

Function readConfigFile

arm9/source/inputhelper.cpp:366–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

364}
365
366bool readConfigFile() {
367 FILE* file = fopen("/gameyobds.ini", "r");
368 char line[100];
369 void (*configParser)(const char*) = generalParseConfig;
370
371 if (file == NULL)
372 goto end;
373
374 while (!feof(file)) {
375 fgets(line, 100, file);
376 char c=0;
377 while (*line != '\0' && ((c = line[strlen(line)-1]) == ' ' || c == '\n' || c == '\r'))
378 line[strlen(line)-1] = '\0';
379 if (line[0] == '[') {
380 char* endBrace;
381 if ((endBrace = strrchr(line, ']')) != 0) {
382 *endBrace = '\0';
383 const char* section = line+1;
384 if (strcasecmp(section, "general") == 0) {
385 configParser = generalParseConfig;
386 }
387 else if (strcasecmp(section, "console") == 0) {
388 configParser = menuParseConfig;
389 }
390 else if (strcasecmp(section, "controls") == 0) {
391 configParser = controlsParseConfig;
392 }
393 }
394 }
395 else
396 configParser(line);
397 }
398 fclose(file);
399end:
400 if (keyConfigs.empty())
401 keyConfigs.push_back(defaultKeyConfig);
402 if (selectedKeyConfig >= keyConfigs.size())
403 selectedKeyConfig = 0;
404 loadKeyConfig();
405
406 return file != NULL;
407}
408
409void writeConfigFile() {
410 FILE* file = fopen("/gameyobds.ini", "w");

Callers 1

mainFunction · 0.85

Calls 1

loadKeyConfigFunction · 0.85

Tested by

no test coverage detected