Skip to content

Commit 627bab4

Browse files
JeodCKiritoDv
authored andcommitted
Fix special characters in path #126
1 parent b2facde commit 627bab4

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/port/GameExtractor.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ std::unordered_map<std::string, std::string> mGameList = {
3333
{ "9bef1128717f958171a4afac3ed78ee2bb4e86ce", "Super Mario 64 (US)" },
3434
};
3535

36+
static std::filesystem::path Utf8ToFsPath(const std::string& utf8) {
37+
return std::filesystem::path(reinterpret_cast<const char8_t*>(utf8.c_str()));
38+
}
39+
3640
bool GameExtractor::RunStandalone(std::string rom) {
3741
// Store both path and already-read data
3842
std::string romPath;
@@ -117,12 +121,13 @@ bool GameExtractor::SelectGameFromUI() {
117121

118122
// Load file if it is not already open
119123
if (romData.empty()) {
120-
if (!std::filesystem::exists(romPath)) {
124+
const std::filesystem::path romFsPath = Utf8ToFsPath(romPath);
125+
if (!std::filesystem::exists(romFsPath)) {
121126
SPDLOG_ERROR("Failed to find ROM at path: {}", romPath);
122127
return false;
123128
}
124129

125-
std::ifstream inFile(romPath, std::ios::binary);
130+
std::ifstream inFile(romFsPath, std::ios::binary);
126131
if (!inFile.is_open()) {
127132
return false;
128133
}

0 commit comments

Comments
 (0)