Save corruption on Windows if file has specal characters like : in it #141

Open
opened 2026-11-26 09:12:08 +00:00 by github-bot · 2 comments
Owner

@⁠annahana on GitHub · 2026-07-31 17:29 UTC · original

Arcade Spirits: The New Challengers tries to create a file
named
rg_ac_Arcade Spirits: The New Challengers_0.dat

the game itself does not validate if the file is created on saving. what is no a problem as long as the game runs and it is in RAM. but on closing and starting fresh the game looks for that file and crashs on access violation

we need a virtuall save managmant or a index outseid of the savefolder where the real name of such a file is saved and its equel name how it was named on windows without the special characters.

Linux and MacOS should be fine because there Specal characters are allowed in file names

**@⁠annahana** on GitHub · 2026-07-31 17:29 UTC · [original](https://github.com/KytyPS5/KytyPS5/issues/141) Arcade Spirits: The New Challengers tries to create a file named rg_ac_Arcade Spirits: The New Challengers_0.dat the game itself does not validate if the file is created on saving. what is no a problem as long as the game runs and it is in RAM. but on closing and starting fresh the game looks for that file and crashs on access violation we need a virtuall save managmant or a index outseid of the savefolder where the real name of such a file is saved and its equel name how it was named on windows without the special characters. Linux and MacOS should be fine because there Specal characters are allowed in file names
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:12:08 +00:00
Author
Owner

@⁠annahana on GitHub · 2026-07-31 19:53 UTC · original · edited 2026-07-31 19:55 UTC

The guest OS is FreeBSD-based and allows filenames that are not valid on Windows.

Example:
/savedata0/rg_ac_Arcade Spirits: The New Challengers_0.dat

Currently KernelOpen() maps guest paths directly to host paths through GetRealFilename() without any filename translation.

On Windows this results in host paths containing characters such as:

":"
"*"
"?"
"
"<"
">"
"|"

which are invalid and can cause file creation/open failures.

Proposed Solution
Introduce a deterministic path-segment encoding for Windows hosts.

Example:
Guest:
Arcade Spirits: The New Challengers.dat

Host:
Arcade Spirits%3A The New Challengers.dat

Encoding table:

"% -> %25"
": -> %3A"
"* -> %2A"
"? -> %3F"
" -> %22
"< -> %3C"
"> -> %3E"
"| -> %7C"

This avoids collisions that would occur with simple replacement schemes such as:

": -> _"

where

foo:bar
foo_bar

would become identical host filenames.

Apply encoding inside:

MountPoints::GetRealFilename()
MountPoints::GetRealDirectory()

before returning the final host path.

Example helper:

static std::string EncodeHostPathSegment(std::string_view input)
{
#ifdef KYTY_PLATFORM_WINDOWS
std::string out;
for (unsigned char ch : input)
{
switch (ch)
{
case '%': out += "%25"; break;
case ':': out += "%3A"; break;
case '*': out += "%2A"; break;
case '?': out += "%3F"; break;
case '"': out += "%22"; break;
case '<': out += "%3C"; break;
case '>': out += "%3E"; break;
case '|': out += "%7C"; break;
default: out += static_cast(ch); break;
}
}
return out;
#else
return std::string(input);
#endif
}

Example

Guest request:

open("/savedata0/foo:bar?.dat")

Host path:
_SaveData/.../foo%3Abar%3F.dat

Subsequent reads, writes, stats, renames and deletes resolve to the same encoded path and continue to work transparently.

my Motivation is that

Several PS4/PS5 titles use filenames containing characters that are legal on the guest filesystem but illegal on Windows. A deterministic percent-encoding preserves the original guest filename while remaining compatible with NTFS and avoiding filename collisions.

**@⁠annahana** on GitHub · 2026-07-31 19:53 UTC · [original](https://github.com/KytyPS5/KytyPS5/issues/141#issuecomment-5146890542) · edited 2026-07-31 19:55 UTC The guest OS is FreeBSD-based and allows filenames that are not valid on Windows. Example: /savedata0/rg_ac_Arcade Spirits: The New Challengers_0.dat Currently KernelOpen() maps guest paths directly to host paths through GetRealFilename() without any filename translation. On Windows this results in host paths containing characters such as: ":" "*" "?" " "<" ">" "|" which are invalid and can cause file creation/open failures. Proposed Solution Introduce a deterministic path-segment encoding for Windows hosts. Example: Guest: Arcade Spirits: The New Challengers.dat Host: Arcade Spirits%3A The New Challengers.dat Encoding table: "% -> %25" ": -> %3A" "* -> %2A" "? -> %3F" " -> %22 "< -> %3C" "> -> %3E" "| -> %7C" This avoids collisions that would occur with simple replacement schemes such as: ": -> _" where foo:bar foo_bar would become identical host filenames. Apply encoding inside: MountPoints::GetRealFilename() MountPoints::GetRealDirectory() before returning the final host path. Example helper: static std::string EncodeHostPathSegment(std::string_view input) { #ifdef KYTY_PLATFORM_WINDOWS std::string out; for (unsigned char ch : input) { switch (ch) { case '%': out += "%25"; break; case ':': out += "%3A"; break; case '*': out += "%2A"; break; case '?': out += "%3F"; break; case '"': out += "%22"; break; case '<': out += "%3C"; break; case '>': out += "%3E"; break; case '|': out += "%7C"; break; default: out += static_cast<char>(ch); break; } } return out; #else return std::string(input); #endif } Example Guest request: open("/savedata0/foo:bar?.dat") Host path: _SaveData/.../foo%3Abar%3F.dat Subsequent reads, writes, stats, renames and deletes resolve to the same encoded path and continue to work transparently. my Motivation is that Several PS4/PS5 titles use filenames containing characters that are legal on the guest filesystem but illegal on Windows. A deterministic percent-encoding preserves the original guest filename while remaining compatible with NTFS and avoiding filename collisions.
Author
Owner

@⁠Nmzik on GitHub · 2026-07-31 22:35 UTC · original

@⁠annahana Good idea, I'll take a look

**@⁠Nmzik** on GitHub · 2026-07-31 22:35 UTC · [original](https://github.com/KytyPS5/KytyPS5/issues/141#issuecomment-5148037731) @⁠annahana Good idea, I'll take a look
This discussion has been locked. Commenting is limited to contributors.
No milestone
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
github/KytyPS5--KytyPS5#141
No description provided.