Merge pull request #15379 from unknownbrackets/io-truncate

Android: Correct truncation behavior
This commit is contained in:
Henrik Rydgård 2022-02-07 08:50:48 +01:00 committed by GitHub
commit dfb10382e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -201,8 +201,10 @@ bool DirectoryFileHandle::Open(const Path &basePath, std::string &fileName, File
flags |= File::OPEN_APPEND;
if (access & FILEACCESS_CREATE)
flags |= File::OPEN_CREATE;
// Important: don't pass TRUNCATE here, the PSP truncates weirdly. See #579.
// See above about truncate behavior. Just add READ to preserve data here.
if (access & FILEACCESS_TRUNCATE)
flags |= File::OPEN_TRUNCATE;
flags |= File::OPEN_READ;
int fd = File::OpenFD(fullName, (File::OpenFlag)flags);
// Try to detect reads/writes to PSP/GAME to avoid them in replays.