common: open Windows host paths beyond MAX_PATH #2305

Open
github-bot wants to merge 1 commit from github-bot/gh-2305 into main AGit
Owner

@⁠Oskie5802 on GitHub · 2026-11-16 21:07 UTC · original
Oskie5802:windows-long-paths → main · +92 −15 · 2 files · 1 commits · open

Game:

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 – app as 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

  • KernelFtruncate and KernelRmdir in kernel/fileSystem.cpp call std::filesystem directly and still use plain paths. They act on save data rather than on game files; left for a separate change.
  • kernel_file_system_tests does not start on Windows on current main (exit 0xC0000028 before any output), which is why the regression case is in archive_file_tests.
  • The pre-commit clang-format hook re-aligned a few lines in 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

**@⁠Oskie5802** on GitHub · 2026-11-16 21:07 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2305) `Oskie5802:windows-long-paths` → `main` · +92 −15 · 2 files · 1 commits · open ### Game: 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 – app` as 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 - `KernelFtruncate `and `KernelRmdir `in kernel/fileSystem.cpp call `std::filesystem` directly and still use plain paths. They act on save data rather than on game files; left for a separate change. - `kernel_file_system_tests` does not start on Windows on current `main `(exit 0xC0000028 before any output), which is why the regression case is in `archive_file_tests`. - The pre-commit clang-format hook re-aligned a few lines in `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
A Game About Digging A Hole (PPSA30552) fails with "GEngineLoop.PreInit
Failed!" when its folder is nested deeply enough that the pak files end
up 260 or more characters from the drive root; Demon's Souls (PPSA01341)
reports hundreds of unresolved asset files in the same situation (#2296).
Shallow files such as eboot.bin still load, so the game starts and then
fails on its own missing-file path.

The Win32 calls in the host file layer were given plain paths, which are
limited to MAX_PATH unless long paths are enabled both system-wide and
in the application manifest. Pass paths of 248 characters or more (the
lower limit that applies to directories) in extended-length form
instead. Such paths are not parsed by Win32, so make them absolute and
normalized with GetFullPathNameW first; guest paths are appended to the
game folder with mixed separators.

Shorter paths are passed through unchanged.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:18:26 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-16 21:13 UTC · original · edited 2026-11-17 13:43 UTC

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

On Windows, HostPath converts 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, aspenini

Change: Bug fix

Merge Risk: Minimal · up to 7dd0c

This 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: Passed 4

Check name Status Explanation
Title check Passed 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 des…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed 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…
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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d45b0865d8 and 7dd0c1c6ce.

Files selected for processing: 2

  • src/common/platform/sysWindowsFileIO.cpp
  • tests/ArchiveFileTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-16 21:13 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2305#issuecomment-6929520068) · edited 2026-11-17 13:43 UTC <!-- coderabbit-ai-generated:v1 --> <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/2305?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- recent_review_status_start --> No actionable comments were generated in the recent review. <!-- recent_review_status_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> <br> On Windows, `HostPath` converts 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`, `aspenini` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"7dd0c1c6ceef6471c9393888757c5229845c8753" --> <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>7dd0c</code></summary> <dl> <dd> <br> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **⚪ Minimal** · up to `7dd0c` --> <!-- final_review_risk_coverage:{"sourceCommitId":"7dd0c1c6ceef6471c9393888757c5229845c8753","coveredCommitId":"7dd0c1c6ceef6471c9393888757c5229845c8753","kind":"reviewed"} --> This 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. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4</strong></summary> <dl> <dd> <br> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | 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 des… | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | 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… | <details> <summary><strong>Full details: Title check</strong></summary> <dl> <dd> <br> **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. </dd> </dl> </details> <details> <summary><strong>Full details: Description check</strong></summary> <dl> <dd> <br> **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. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=2305)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>Share</strong></summary> <dl> <dd> <br> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </dd> </dl> </details> <!-- tips_end --> <!-- recent_review_start --> <h6> <details> <summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Recent review info</strong></summary> <dl> <dd> <br> <!-- review_info_content --> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/d45b0865d85ced3da80f43ef2a2ecbeca6296637/.coderabbit.yaml>) - **Commit**: [d45b086](<https://github.com/KytyPS5/KytyPS5/commit/d45b0865d85ced3da80f43ef2a2ecbeca6296637>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `717c32c6-d60e-4962-afbb-898d5b819393` </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between d45b0865d85ced3da80f43ef2a2ecbeca6296637 and 7dd0c1c6ceef6471c9393888757c5229845c8753. </dd> </dl> </details> <details> <summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 2</strong></summary> <dl> <dd> <br> * `src/common/platform/sysWindowsFileIO.cpp` * `tests/ArchiveFileTests.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. </dd> </dl> </details> </h6> <!-- recent_review_end -->
Author
Owner

@⁠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 02:30 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2305#issuecomment-6997853999) 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.
Author
Owner

@⁠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.

**@⁠LaizyWaizy** on GitHub · 2026-11-19 03:19 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2305#issuecomment-6998638023) 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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2305/head:github-bot/gh-2305'
git switch 'github-bot/gh-2305'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2305'
git switch 'github-bot/gh-2305'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2305'
git switch 'github-bot/gh-2305'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2305'
git switch 'main'
git merge --squash 'github-bot/gh-2305'
git switch 'main'
git merge --ff-only 'github-bot/gh-2305'
git switch 'main'
git merge 'github-bot/gh-2305'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.