common: open Windows host paths beyond MAX_PATH #2305
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!2305
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2305"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Oskie5802 on GitHub · 2026-11-16 21:07 UTC · original
Oskie5802:windows-long-paths→main· +92 −15 · 2 files · 1 commits · openGame:
A Game About Digging A Hole (PPSA30552). Related report: #2296 (Demon's Souls, PPSA01341).
Problem
On Windows, when the game folder is nested deeply enough that some game files end up 260 or more characters from the drive root, those files cannot be opened. Shallow files such as eboot.bin still load, so the game starts and then fails on its own missing-file path.
With PPSA30552 in a folder whose path is 238 characters long, the pak files (digginggame/content/paks/digginggame-ps5.*, 284 characters in total) are not found and the game stops with:
GEngineLoop.PreInit Failed!Cause
The Win32 calls in
sysWindowsFileIO.cpp(CreateFileW,GetFileAttributesExW,FindFirstFileW,CreateDirectoryW,DeleteFileW,MoveFileW) were given plain paths. Plain paths are limited to MAX_PATH unless long paths are enabled both in the registry and in the application manifest, and the emulator has no such manifest.Fix
Paths of 248 characters or more (the lower limit that applies to directories) are passed in extended-length form (
\\?\C:\...,\\?\UNC\server\share\...). Win32 does not parse such paths, so they are first made absolute and normalized with GetFullPathNameW; guest paths are appended to the game folder with mixed separators. Shorter paths are passed through unchanged, so nothing changes for existing setups.This works regardless of the ```registry setting, which is off by default.
About #2296
The report attributes the failure to the EN DASH in the folder name. I could not reproduce that: PPSA30552 behaves the same from a short folder named
Digging Hole – BP 4.xx – appas from an ASCII folder (same log, same number of file errors). What does reproduce the reported pattern (early files load, deep asset files do not, an ASCII junction fixes it) is path length: the folder name in the report is long, the failing file is 105 characters below it, and the junction used as the control also shortens the path.I do not own Demon's Souls, so I have not confirmed that this is the whole story for that report. It would help if the reporter could say how long the full path of the dump folder is, or retest with this change.
Testing
PPSA30552 from a 238-character folder: before,
GEngineLoop.PreInit Failed!after, the paks open and the run is identical to the one from a short path.PPSA30552 from a short path and from a short path with non-ASCII characters: unchanged.
New case in
archive_file_tests(runs in the Windows CI list): create, stat, enumerate, read, rename and delete below a directory more than 300 characters deep. It fails on main at "create a directory beyond MAX_PATH" and passes with the change.Tested on Windows 11, AMD Radeon RX 6600.
Not covered
KernelFtruncateandKernelRmdirin kernel/fileSystem.cpp callstd::filesystemdirectly and still use plain paths. They act on save data rather than on game files; left for a separate change.kernel_file_system_testsdoes not start on Windows on currentmain(exit 0xC0000028 before any output), which is why the regression case is inarchive_file_tests.sysWindowsFileIO.cpp that this change does not otherwise touch.AI use
The investigation and the code were done with Claude Fable 5.2. I reviewed the changes and
tested them on my own hardware as described, this description are writted by human - Me :) and corrected by AI
Fixes #2296
@coderabbitai[bot] on GitHub · 2026-11-16 21:13 UTC · original · edited 2026-11-17 13:43 UTC
No actionable comments were generated in the recent review.
Walkthrough
On Windows,
HostPathconverts eligible long paths to extended-length paths. File opening, attribute lookup, directory creation, deletion, enumeration, and renaming now use this conversion. A new test exercises filesystem operations on a nested host path of at least 300 characters.Suggested reviewers:
nmzik,aspeniniChange: Bug fix
Merge Risk:
Minimal · up to
7dd0cThis change lets Windows file operations open deeply nested paths beyond MAX_PATH, and shorter paths behave as before. No concrete merge-blocking risk was identified.
Pre-merge checks:
4
#2296), the root cause (Win32 MAX_PATH limit on plain paths in sysWindowsFileIO.cpp), the fix (extended-length paths for 248+ characters…Full details: Title check
Explanation
The title names the main change: Windows host file access for paths longer than MAX_PATH. The raw summary confirms that HostPath now converts long paths to extended-length form, and the objectives describe the same fix.
Full details: Description check
Explanation
The description names the game (PPSA30552), the related report (
#2296), the root cause (Win32 MAX_PATH limit on plain paths in sysWindowsFileIO.cpp), the fix (extended-length paths for 248+ characters), the testing performed, and the uncovered call sites. It is specific and directly related to the changeset, so it passes the lenient check.Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
717c32c6-d60e-4962-afbb-898d5b819393Reviewing files that changed from the base of the PR and between
d45b0865d8and7dd0c1c6ce.src/common/platform/sysWindowsFileIO.cpptests/ArchiveFileTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
@LaizyWaizy on GitHub · 2026-11-19 02:30 UTC · original
Hey! I tested this PR on Windows 10 and wanted to share what I found.
First off, your fix works! I tested both regular and Unicode folder names with paths over 300 characters. They failed on the original build but worked with your PR. Short paths also continued working normally.
I did find one remaining issue with relative paths.
I tested a 230-character working directory with a 79-character relative filename, making the full path 310 characters. Both the original build and your PR failed with Windows error 3 (ERROR_PATH_NOT_FOUND).
However, using the full absolute path worked with your PR, and using the extended path format (\?) also worked.
From what I found, HostPath seems to check the relative path's length before converting it to an absolute path. That might explain why it misses this case.
This isn't a regression caused by your PR, just an edge case that still exists.
I haven't tested Demon's Souls itself, so I can't confirm whether issue #2296 is completely fixed.
I used AI assistance to help investigate and create the tests, but reviewed and ran them locally.
Thanks for working on this! Just wanted to share the results in case they're helpful.
@LaizyWaizy on GitHub · 2026-11-19 03:19 UTC · original
Quick update! I finished testing and pushed a fix for the relative long-path issue I mentioned earlier.
The change resolves relative paths before checking their full length. The original 230/79/310-character regression now passes, along with the existing archive tests and the additional Windows path cases I tested.
I kept the changes to two files and based the branch on your PR.
Here's the branch:
https://github.com/LaizyWaizy/KytyPS5/tree/fix/windows-relative-long-paths
I used AI assistance during development and testing, and reviewed the final changes locally.
If you're interested, feel free to take a look! I'd be happy to coordinate on incorporating it into your PR.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.