[Crypto] Slightly more robust error handling

This commit is contained in:
wheremyfoodat 2023-06-27 01:12:17 +03:00
parent 0494ca0064
commit 3cf8427670
5 changed files with 41 additions and 34 deletions

View file

@ -137,15 +137,17 @@ bool Emulator::loadROM(const std::filesystem::path& path) {
char* appData = SDL_GetPrefPath(nullptr, "Alber");
const std::filesystem::path appDataPath = std::filesystem::path(appData);
const std::filesystem::path dataPath = appDataPath / path.filename().stem();
const std::filesystem::path aesKeysPath = appDataPath / "sysdata" / "aes_keys.txt";
const std::filesystem::path aesKeysPath = appDataPath / "sysdata" / "aes_keys.txt";
IOFile::setAppDataDir(dataPath);
SDL_free(appData);
if (std::filesystem::exists(aesKeysPath)) {
// 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
// avoid the call throwing exceptions
std::error_code ec;
if (std::filesystem::exists(aesKeysPath, ec) && !ec) {
aesEngine.loadKeys(aesKeysPath);
}
SDL_free(appData);
kernel.initializeFS();
auto extension = path.extension();