diff --git a/src/common/io_file.cpp b/src/common/io_file.cpp index eeacbc393..6fa9062a7 100644 --- a/src/common/io_file.cpp +++ b/src/common/io_file.cpp @@ -330,7 +330,7 @@ bool IOFile::Commit() const { return commit_result; } -bool IOFile::SetSize(const char* host_path, u64 size) const { +bool IOFile::SetSize(u64 size) const { if (!IsOpen()) { return false; } @@ -340,7 +340,7 @@ bool IOFile::SetSize(const char* host_path, u64 size) const { #ifdef _WIN32 const auto set_size_result = _chsize_s(fileno(file), static_cast(size)) == 0; #else - const auto set_size_result = truncate(host_path, static_cast(size)) == 0; + const auto set_size_result = ftruncate(fileno(file), static_cast(size)) == 0; #endif if (!set_size_result) { diff --git a/src/common/io_file.h b/src/common/io_file.h index 87174969d..45787a092 100644 --- a/src/common/io_file.h +++ b/src/common/io_file.h @@ -114,7 +114,7 @@ public: bool Flush() const; bool Commit() const; - bool SetSize(const char* host_path, u64 size) const; + bool SetSize(u64 size) const; u64 GetSize() const; bool Seek(s64 offset, SeekOrigin origin = SeekOrigin::SetOrigin) const; diff --git a/src/core/libraries/kernel/file_system.cpp b/src/core/libraries/kernel/file_system.cpp index 67433c793..cb1fd14a2 100644 --- a/src/core/libraries/kernel/file_system.cpp +++ b/src/core/libraries/kernel/file_system.cpp @@ -181,7 +181,7 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) { return -1; } } else { - // Start by opening as read-write so we can truncate on all platforms. + // Start by opening as read-write so we can truncate regardless of flags. // Since open starts by closing the file, this won't interfere with later open calls. e = file->f.Open(file->m_host_name, Common::FS::FileAccessMode::ReadWrite); @@ -194,7 +194,7 @@ s32 PS4_SYSV_ABI open(const char* raw_path, s32 flags, u16 mode) { return -1; } else if (truncate && e == 0) { // If the file was opened successfully and truncate was enabled, reduce size to 0 - file->f.SetSize(file->m_host_name.string().c_str(), 0); + file->f.SetSize(0); } if (read) { @@ -705,7 +705,7 @@ s32 PS4_SYSV_ABI posix_ftruncate(s32 fd, s64 length) { return -1; } - file->f.SetSize(file->m_host_name.string().c_str(), length); + file->f.SetSize(length); return ORBIS_OK; }