Fix create flag handling in open (#3255)

If the create flag is specified, but the file already exists, then the file should open successfully, regardless of permissions.
This fixes a crash seen in Phantasy Star Online 2 New Genesis (CUSA29813)
This commit is contained in:
Stephen Miller 2025-07-16 04:30:20 -05:00 committed by GitHub
parent 499451bb80
commit aeab525a7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -118,6 +118,7 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
return -1;
}
if (!exists) {
if (read_only) {
// Can't create files in a read only directory
h->DeleteHandle(handle);
@ -126,6 +127,7 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
}
// Create a file if it doesn't exist
Common::FS::IOFile out(file->m_host_name, Common::FS::FileAccessMode::Write);
}
} else if (!exists) {
// If we're not creating a file, and it doesn't exist, return ENOENT
h->DeleteHandle(handle);