Improved "hack"

This commit is contained in:
Stephen Miller 2025-06-14 08:56:23 -05:00
parent 77c11dabbe
commit bfbe1d4908

View File

@ -293,13 +293,17 @@ s64 PS4_SYSV_ABI write(s32 fd, const void* buf, size_t nbytes) {
} }
return result; return result;
} }
auto file_size_before = file->f.GetSize();
auto written_bytes = file->f.WriteRaw<u8>(buf, nbytes); // Due to a quirk with std::fwrite
auto file_size = file->f.GetSize(); // we need to validate the returned bytes, and make sure the file size is correct.
if (file_size != file_size_before + written_bytes) { auto expected_file_size = file->f.GetSize();
file->f.SetSize(written_bytes); auto bytes_written = file->f.WriteRaw<u8>(buf, nbytes);
expected_file_size += bytes_written;
auto actual_file_size = file->f.GetSize();
if (expected_file_size != actual_file_size) {
file->f.SetSize(expected_file_size);
} }
return written_bytes; return bytes_written;
} }
s64 PS4_SYSV_ABI posix_write(s32 fd, const void* buf, size_t nbytes) { s64 PS4_SYSV_ABI posix_write(s32 fd, const void* buf, size_t nbytes) {