mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-30 22:14:56 +00:00
Fix truncates
Host ftruncate consistently fails on EINVAL, I'll need to test if this issue affected Windows too.
This commit is contained in:
parent
4069a74016
commit
06a2c5cb27
@ -330,7 +330,7 @@ bool IOFile::Commit() const {
|
||||
return commit_result;
|
||||
}
|
||||
|
||||
bool IOFile::SetSize(u64 size) const {
|
||||
bool IOFile::SetSize(const char* host_path, u64 size) const {
|
||||
if (!IsOpen()) {
|
||||
return false;
|
||||
}
|
||||
@ -340,7 +340,7 @@ bool IOFile::SetSize(u64 size) const {
|
||||
#ifdef _WIN32
|
||||
const auto set_size_result = _chsize_s(fileno(file), static_cast<s64>(size)) == 0;
|
||||
#else
|
||||
const auto set_size_result = ftruncate(fileno(file), static_cast<s64>(size)) == 0;
|
||||
const auto set_size_result = truncate(host_path, static_cast<s64>(size)) == 0;
|
||||
#endif
|
||||
|
||||
if (!set_size_result) {
|
||||
|
@ -114,7 +114,7 @@ public:
|
||||
bool Flush() const;
|
||||
bool Commit() const;
|
||||
|
||||
bool SetSize(u64 size) const;
|
||||
bool SetSize(const char* host_path, u64 size) const;
|
||||
u64 GetSize() const;
|
||||
|
||||
bool Seek(s64 offset, SeekOrigin origin = SeekOrigin::SetOrigin) const;
|
||||
|
@ -187,7 +187,7 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) {
|
||||
|
||||
if (truncate && e == 0) {
|
||||
// If the file was opened successfully and truncate was enabled, reduce size to 0
|
||||
file->f.SetSize(0);
|
||||
file->f.SetSize(file->m_host_name.c_str(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -683,7 +683,7 @@ s32 PS4_SYSV_ABI posix_ftruncate(s32 fd, s64 length) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
file->f.SetSize(length);
|
||||
file->f.SetSize(file->m_host_name.c_str(), length);
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user