Skip to content

Commit afa2bbf

Browse files
authored
Merge pull request #314 from hydra-emu/wrage-4
Fix android app data path
2 parents e57256a + ab83fc1 commit afa2bbf

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/emulator.cpp

+11-3
Original file line numberDiff line numberDiff line change
@@ -449,25 +449,33 @@ bool Emulator::loadROM(const std::filesystem::path& path) {
449449
memory.loadedCXI = std::nullopt;
450450
memory.loaded3DSX = std::nullopt;
451451

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)
453453
// 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
454454
// %APPDATA%/Alber/PenguinDemo/SaveData on Windows, and so on. We do this because games save data in their own filesystem on the cart.
455455
// If the portable build setting is enabled, then those saves go in the executable directory instead
456-
char* appData;
457456
std::filesystem::path appDataPath;
458457

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;
459466
if (!config.usePortableBuild) {
460467
appData = SDL_GetPrefPath(nullptr, "Alber");
461468
appDataPath = std::filesystem::path(appData);
462469
} else {
463470
appData = SDL_GetBasePath();
464471
appDataPath = std::filesystem::path(appData) / "Emulator Files";
465472
}
473+
SDL_free(appData);
474+
#endif
466475

467476
const std::filesystem::path dataPath = appDataPath / path.filename().stem();
468477
const std::filesystem::path aesKeysPath = appDataPath / "sysdata" / "aes_keys.txt";
469478
IOFile::setAppDataDir(dataPath);
470-
SDL_free(appData);
471479

472480
// 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
473481
// avoid the call throwing exceptions

third_party/cryptopp/CMakeLists.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,8 @@ find_package(Threads)
443443
target_link_libraries(cryptopp PRIVATE ${CMAKE_THREAD_LIBS_INIT})
444444

445445
if(ANDROID)
446-
include(AndroidNdkModules)
447-
android_ndk_import_module_cpufeatures()
446+
include_directories(${ANDROID_NDK}/sources/android/cpufeatures)
447+
add_library(cpufeatures ${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c)
448+
target_link_libraries(cpufeatures dl)
448449
target_link_libraries(cryptopp PRIVATE cpufeatures)
449450
endif()

0 commit comments

Comments
 (0)