[PR #3099] [MERGED] Filesystem: Fixes for posix_rename and write #3223

Closed
opened 2026-02-27 22:02:54 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/3099
Author: @StevenMiller123
Created: 6/15/2025
Status: Merged
Merged: 6/15/2025
Merged by: @georgemoralis

Base: mainHead: not-so-save-fixes


📝 Commits (7)

📊 Changes

2 files changed (+21 additions, -1 deletions)

View changed files

📝 src/common/io_file.h (+3 -1)
📝 src/core/libraries/kernel/file_system.cpp (+18 -0)

📄 Description

On some platforms, WriteRaw doesn't write all the data to the file immediately, resulting in write returning more bytes than what we actually wrote to the file stream. To fix this, I've added an std::fflush call to WriteRaw, which ensures all buffered data is written before the function call returns.

Additionally, our posix_rename function was only copying files, instead of renaming this. On closer inspection, it seems like this was done to prevent "shared access" errors on Windows devices, which could occur if the file to rename was already open. To work around this, I've added code to close the source file, delete it, then open the "renamed" copy.

These two fixes solve the savedata errors in DRAGON BALL XENOVERSE (CUSA01341) and DRAGON BALL XENOVERSE 2 (CUSA05350).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/3099 **Author:** [@StevenMiller123](https://github.com/StevenMiller123) **Created:** 6/15/2025 **Status:** ✅ Merged **Merged:** 6/15/2025 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `not-so-save-fixes` --- ### 📝 Commits (7) - [`ae638c0`](https://github.com/shadps4-emu/shadPS4/commit/ae638c04c3f894a861a84ecdfb9618d3cefe8a09) Fix rename - [`ea92214`](https://github.com/shadps4-emu/shadPS4/commit/ea92214ff572c8dd32b1bbc10cf1e68e287133c4) sceKernelWrite hack - [`77c11da`](https://github.com/shadps4-emu/shadPS4/commit/77c11dabbedea932082fd523f82c831d4b558ae5) hack fix - [`bfbe1d4`](https://github.com/shadps4-emu/shadPS4/commit/bfbe1d49088d8dca54bf05fb1521e2dcf8b94803) Improved "hack" - [`4c881f6`](https://github.com/shadps4-emu/shadPS4/commit/4c881f6e4018996039b15417b9bf641b338091bd) Fix rename for Windows users - [`db19ea1`](https://github.com/shadps4-emu/shadPS4/commit/db19ea1622e9972611d3a2c95ca6f6ceb8cb08a4) A real fix for the sceKernelWrite issue - [`ec70160`](https://github.com/shadps4-emu/shadPS4/commit/ec701609362e07f1d70e99c79e48632d7ef2580f) Move fflush call to WriteRaw ### 📊 Changes **2 files changed** (+21 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/common/io_file.h` (+3 -1) 📝 `src/core/libraries/kernel/file_system.cpp` (+18 -0) </details> ### 📄 Description On some platforms, `WriteRaw` doesn't write all the data to the file immediately, resulting in `write` returning more bytes than what we actually wrote to the file stream. To fix this, I've added an `std::fflush` call to `WriteRaw`, which ensures all buffered data is written before the function call returns. Additionally, our `posix_rename` function was only copying files, instead of renaming this. On closer inspection, it seems like this was done to prevent "shared access" errors on Windows devices, which could occur if the file to rename was already open. To work around this, I've added code to close the source file, delete it, then open the "renamed" copy. These two fixes solve the savedata errors in DRAGON BALL XENOVERSE (CUSA01341) and DRAGON BALL XENOVERSE 2 (CUSA05350). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:02:54 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shadPS4#3223
No description provided.