MCPcopy Create free account
hub / github.com/TASEmulators/fceux / loadInputSettingsFromFile

Function loadInputSettingsFromFile

src/drivers/Qt/input.cpp:2466–2591  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2464}
2465
2466int loadInputSettingsFromFile(const char *filename)
2467{
2468 QDir dir;
2469 std::string path;
2470 const char *baseDir = FCEUI_GetBaseDirectory();
2471 char base[512], line[256];
2472 char id[128], val[128];
2473 int i, j;
2474
2475 path = std::string(baseDir) + "/input/presets/";
2476
2477 dir.mkpath(QString::fromStdString(path));
2478
2479 if (filename != NULL)
2480 {
2481 getFileBaseName(filename, base, NULL);
2482
2483 path += std::string(base) + ".pre";
2484 }
2485 else
2486 {
2487 const char *romFile = getRomFile();
2488
2489 if (romFile == NULL)
2490 {
2491 return -1;
2492 }
2493 getFileBaseName(romFile, base, NULL);
2494
2495 path += std::string(base) + ".pre";
2496 }
2497
2498 FILE *fp = fopen(path.c_str(), "r");
2499
2500 if (fp == NULL)
2501 {
2502 return -1;
2503 }
2504
2505 while (fgets(line, sizeof(line) - 1, fp) != 0)
2506 {
2507 i = 0;
2508 while (line[i] != 0)
2509 {
2510 if (line[i] == '#')
2511 {
2512 line[i] = 0;
2513 break;
2514 }
2515 i++;
2516 }
2517
2518 i = 0;
2519 while (isspace(line[i]))
2520 i++;
2521
2522 j = 0;
2523 while (isalnum(line[i]) || (line[i] == '_'))

Callers 2

LoadGameFunction · 0.85
openLoadPresetFileMethod · 0.85

Calls 7

FCEUI_GetBaseDirectoryFunction · 0.85
getFileBaseNameFunction · 0.85
isspaceClass · 0.85
stdPortInputDecodeFunction · 0.85
expPortInputDecodeFunction · 0.85
boolDecodeFunction · 0.85
getRomFileFunction · 0.70

Tested by

no test coverage detected