mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-23 18:45:36 +00:00
Improved "hack"
This commit is contained in:
parent
77c11dabbe
commit
bfbe1d4908
@ -293,13 +293,17 @@ s64 PS4_SYSV_ABI write(s32 fd, const void* buf, size_t nbytes) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
auto file_size_before = file->f.GetSize();
|
||||
auto written_bytes = file->f.WriteRaw<u8>(buf, nbytes);
|
||||
auto file_size = file->f.GetSize();
|
||||
if (file_size != file_size_before + written_bytes) {
|
||||
file->f.SetSize(written_bytes);
|
||||
|
||||
// Due to a quirk with std::fwrite
|
||||
// we need to validate the returned bytes, and make sure the file size is correct.
|
||||
auto expected_file_size = file->f.GetSize();
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user