Repository navigation
fix(libc): read directory entries through the wide dirent API on Windows - #2335
Conversation
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>
|
Full Linux and Windows builds and tests for this head (
Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/37954522946 |
1 similar comment
|
Full Linux and Windows builds and tests for this head (
Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/37954522946 |
…f8-names fix(libc): read directory entries through the wide dirent API on Windows
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