mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-22 10:04:39 +00:00
Only perform early read-write open when truncating is needed (#2874)
Should stop some fs error spam when games open files from /app0, as this open call would fail from reduced permissions.
This commit is contained in:
parent
eb09c4ccce
commit
0ba9ea6a3b
@ -181,10 +181,6 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
// Start by opening as read-write so we can truncate regardless of flags.
|
||||
// Since open starts by closing the file, this won't interfere with later open calls.
|
||||
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::ReadWrite);
|
||||
|
||||
file->type = Core::FileSys::FileType::Regular;
|
||||
|
||||
if (truncate && read_only) {
|
||||
@ -192,9 +188,14 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
|
||||
h->DeleteHandle(handle);
|
||||
*__Error() = POSIX_EROFS;
|
||||
return -1;
|
||||
} else if (truncate && e == 0) {
|
||||
// If the file was opened successfully and truncate was enabled, reduce size to 0
|
||||
file->f.SetSize(0);
|
||||
} else if (truncate) {
|
||||
// Open the file as read-write so we can truncate regardless of flags.
|
||||
// Since open starts by closing the file, this won't interfere with later open calls.
|
||||
e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::ReadWrite);
|
||||
if (e == 0) {
|
||||
// If the file was opened successfully, reduce size to 0
|
||||
file->f.SetSize(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (read) {
|
||||
|
Loading…
Reference in New Issue
Block a user