@@ -449,25 +449,33 @@ bool Emulator::loadROM(const std::filesystem::path& path) {
449
449
memory.loadedCXI = std::nullopt;
450
450
memory.loaded3DSX = std::nullopt;
451
451
452
- // Get path for saving files (AppData on Windows, /home/user/.local/share/ApplcationName on Linux, etc)
452
+ // Get path for saving files (AppData on Windows, /home/user/.local/share/ApplicationName on Linux, etc)
453
453
// Inside that path, we be use a game-specific folder as well. Eg if we were loading a ROM called PenguinDemo.3ds, the savedata would be in
454
454
// %APPDATA%/Alber/PenguinDemo/SaveData on Windows, and so on. We do this because games save data in their own filesystem on the cart.
455
455
// If the portable build setting is enabled, then those saves go in the executable directory instead
456
- char * appData;
457
456
std::filesystem::path appDataPath;
458
457
458
+ #ifdef __ANDROID__
459
+ // SDL_GetPrefPath fails to get the path due to no JNI environment
460
+ std::ifstream cmdline (" /proc/self/cmdline" );
461
+ std::string applicationName;
462
+ std::getline (cmdline, applicationName, ' \0 ' );
463
+ appDataPath = std::filesystem::path (" /data" ) / " data" / applicationName / " files" ;
464
+ #else
465
+ char * appData;
459
466
if (!config.usePortableBuild ) {
460
467
appData = SDL_GetPrefPath (nullptr , " Alber" );
461
468
appDataPath = std::filesystem::path (appData);
462
469
} else {
463
470
appData = SDL_GetBasePath ();
464
471
appDataPath = std::filesystem::path (appData) / " Emulator Files" ;
465
472
}
473
+ SDL_free (appData);
474
+ #endif
466
475
467
476
const std::filesystem::path dataPath = appDataPath / path.filename ().stem ();
468
477
const std::filesystem::path aesKeysPath = appDataPath / " sysdata" / " aes_keys.txt" ;
469
478
IOFile::setAppDataDir (dataPath);
470
- SDL_free (appData);
471
479
472
480
// Open the text file containing our AES keys if it exists. We use the std::filesystem::exists overload that takes an error code param to
473
481
// avoid the call throwing exceptions
0 commit comments