fix(libc): read directory entries through the wide dirent API on Windows #2335
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2335"
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?
Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T15:48:36Z.
What
The guest passes and expects UTF-8 path names. On Windows, though,
opendir/readdirinDirectory.cppused MinGW's narrow dirent API (opendir,readdir), which works in the ANSI code page. The result:opendirfailed for a directory whose UTF-8 name contains characters outside the code page (e.g.セーブon a Western code page).readdirreturned 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
_wopendirand read with_wreaddir(_wclosedir/_wrewinddirfor the rest), and each name is converted to UTF-8 withstd::filesystem::path::u8string(). Linux keepsDIR/readdir, since its names are already bytes.This is the directory half of #2329. The
fopen/freopenhalf 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.cpphas a new case. It createsセーブ/été.txt, opens the directory withopendirusing its UTF-8 path, and requires thatreaddirreturnété.txtin UTF-8 with typeDT_REG, plus.and...mainit fails:opendirreturns null.ctest -E "^agc_|video_out": 249/249.tools/check_conventions.pypasses, andtools/pr_overlap.py --branchreports no overlap.A Linux and Windows full build will be posted here once it has run.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T16:30:17Z.
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 samebuild.ymlin my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into currentmain(d70b8998):ctest: 516/516 passedctest: 507/507 passedRun: https://github.com/AchrafReyani/AnyPS5/actions/runs/37954522946
Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T16:30:23Z.
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 samebuild.ymlin my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into currentmain(d70b8998):ctest: 516/516 passedctest: 507/507 passedRun: https://github.com/AchrafReyani/AnyPS5/actions/runs/37954522946