summaryrefslogtreecommitdiff
path: root/Source/Core/Common/DirectIOFile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/Common/DirectIOFile.cpp')
-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