Skip to content

fix(libc): read directory entries through the wide dirent API on Windows - #2335

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
reyani-dev:fix/directory-utf8-names
Oct 10, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
reyani-dev:fix/directory-utf8-names

Conversation

@reyani-dev

Copy link
Copy Markdown
Contributor

What

The guest passes and expects UTF-8 path names. On Windows, though, opendir/readdir in Directory.cpp used MinGW's narrow dirent API (opendir, readdir), which works in the ANSI code page. The result:

  • opendir failed for a directory whose UTF-8 name contains characters outside the code page (e.g. セーブ on a Western code page).
  • readdir returned entry names as ANSI bytes rather than UTF-8. A character the code page lacks came back as ?, so the guest could not open the entry it had just listed.

On Windows the directory is now opened with _wopendir and read with _wreaddir (_wclosedir/_wrewinddir for the rest), and each name is converted to UTF-8 with std::filesystem::path::u8string(). Linux keeps DIR/readdir, since its names are already bytes.

This is the directory half of #2329. The fopen/freopen half is left out on purpose, because #1549, #2033 and #2170 already touch that line.

Tested

Windows 11, WinLibs GCC 15.2.0 r7, Release, -DBUILD_TESTING=ON:

  • GuestDirectory.cpp has a new case. It creates セーブ/été.txt, opens the directory with opendir using its UTF-8 path, and requires that readdir return été.txt in UTF-8 with type DT_REG, plus . and ...
    • On main it fails: opendir returns null.
    • With the fix it passes.
  • ctest -E "^agc_|video_out": 249/249.
  • tools/check_conventions.py passes, and tools/pr_overlap.py --branch reports no overlap.

A Linux and Windows full build will be posted here once it has run.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes

🤖 Generated with Claude Code

The guest passes and expects UTF-8 names, but on Windows opendir and
readdir used MinGW's narrow dirent API, which works in the ANSI code
page: opendir failed for a directory whose name is outside the code page,
and readdir returned names as ANSI bytes, with "?" for characters the code
page lacks. Use _wopendir and _wreaddir there and convert each name to
UTF-8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@reyani-dev

Copy link
Copy Markdown
Contributor Author

Full Linux and Windows builds and tests for this head (46786b1e), using the project's Build workflow. I can't start the upstream manual run, so I ran the same build.yml in my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into current main (d70b8998):

Job Result
linux success; full build, ctest: 516/516 passed
windows success; full build, ctest: 507/507 passed
relinker (Linux, Windows, macOS) success

Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/37954522946

1 similar comment
@reyani-dev

Copy link
Copy Markdown
Contributor Author

Full Linux and Windows builds and tests for this head (46786b1e), using the project's Build workflow. I can't start the upstream manual run, so I ran the same build.yml in my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into current main (d70b8998):

Job Result
linux success; full build, ctest: 516/516 passed
windows success; full build, ctest: 507/507 passed
relinker (Linux, Windows, macOS) success

Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/37954522946

@github-actions github-actions Bot added the libc label Oct 9, 2026
oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Oct 10, 2026
oneandonlydean added a commit to oneandonlydean/AnyPS5 that referenced this pull request Oct 10, 2026
@oneandonlydean
oneandonlydean merged commit 568745c into boykopovar:main Oct 10, 2026
8 checks passed
SleglJan pushed a commit to SleglJan/AnyPS5 that referenced this pull request Oct 10, 2026
…f8-names

fix(libc): read directory entries through the wide dirent API on Windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants