mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-12-16 04:09:39 +00:00
Merge pull request #14142 from JosJuice/directiofile-cant-create-saf
Common: Treat DirectIOFile as unable to create SAF files
This commit is contained in:
commit
490615c72a
@ -121,29 +121,20 @@ bool DirectIOFile::Open(const std::string& path, AccessMode access_mode, OpenMod
|
|||||||
else if (access_mode == AccessMode::Write)
|
else if (access_mode == AccessMode::Write)
|
||||||
open_mode_str = "w";
|
open_mode_str = "w";
|
||||||
|
|
||||||
// FYI: File::Exists can be slow on Android.
|
if (open_mode == OpenMode::Truncate)
|
||||||
Common::Lazy<bool> file_exists{[&] { return Exists(path); }};
|
open_mode_str += 't';
|
||||||
|
|
||||||
// A few features are emulated in a non-atomic manner.
|
if (open_mode == OpenMode::Create)
|
||||||
if (open_mode == OpenMode::Existing)
|
|
||||||
{
|
{
|
||||||
if (access_mode != AccessMode::Read && !*file_exists)
|
ASSERT_MSG(COMMON, false, "DirectIOFile doesn't support creating SAF files");
|
||||||
return false;
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_fd = OpenAndroidContent(path, open_mode_str);
|
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();
|
return IsOpen();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user