diff --git a/Source/Core/Common/DirectIOFile.cpp b/Source/Core/Common/DirectIOFile.cpp index d5e805529de..d72e98fa3bb 100644 --- a/Source/Core/Common/DirectIOFile.cpp +++ b/Source/Core/Common/DirectIOFile.cpp @@ -121,29 +121,20 @@ bool DirectIOFile::Open(const std::string& path, AccessMode access_mode, OpenMod else if (access_mode == AccessMode::Write) open_mode_str = "w"; - // FYI: File::Exists can be slow on Android. - Common::Lazy file_exists{[&] { return Exists(path); }}; + if (open_mode == OpenMode::Truncate) + open_mode_str += 't'; - // A few features are emulated in a non-atomic manner. - if (open_mode == OpenMode::Existing) + if (open_mode == OpenMode::Create) { - if (access_mode != AccessMode::Read && !*file_exists) - return false; - } - else - { - if (open_mode == OpenMode::Truncate) - open_mode_str += 't'; - else if (open_mode == OpenMode::Create && *file_exists) - return false; - - // Modes other than `Existing` may create a file, but "r" won't do that automatically. - if (access_mode == AccessMode::Read && !*file_exists) - CreateEmptyFile(path); + ASSERT_MSG(COMMON, false, "DirectIOFile doesn't support creating SAF files"); + return false; } m_fd = OpenAndroidContent(path, open_mode_str); + if (!IsOpen() && (open_mode == OpenMode::Always || open_mode == OpenMode::Truncate)) + ASSERT_MSG(COMMON, Exists(path), "DirectIOFile doesn't support creating SAF files"); + return IsOpen(); } #endif