summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2025-11-23 09:50:44 +0100
committerGitHub <noreply@github.com>2025-11-23 09:50:44 +0100
commit490615c72ade1a41c6382fd5d21d96c424317e2c (patch)
tree8e88d2f2adbcb6dcb1faac28e6680200f1a69bc6
parent151d295b2c09569ffecdb8f56c73f66128dc3b61 (diff)
parent9883235c0c67185d9cdc9e739be8ef25532378a8 (diff)
Merge pull request #14142 from JosJuice/directiofile-cant-create-saf
Common: Treat DirectIOFile as unable to create SAF files
-rw-r--r--Source/Core/Common/DirectIOFile.cpp25
1 files changed, 8 insertions, 17 deletions
diff --git a/Source/Core/Common/DirectIOFile.cpp b/Source/Core/Common/DirectIOFile.cpp
index d5e805529d..d72e98fa3b 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<bool> 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