digant73's Description of Work #18705 [TESTERS NEEDED] Fix unpkg bugs
Try to fix some bugs on unpkg.cpp.
Further, improve comments on already merged PR #19497.
Analysis and fixes made by Fable 5.1.
PR marked as draft. It needs to be tested by users affected by the issues that this PR is expected to fix.
Tickets fixed by this PR:
(confirmed) fixes #18705 β Resident Evil: The Darkside Chronicles crashes RPCS3 at 0% during install (regression since #13147); also covers the earlier duplicates (closed but never fixed) #13280 and #15037.
(confirmed) fixes #19456 β "PKG entry path escapes installation directory" when the emulator path contains accented characters.
(confirmed) fixes #19490 β [Regression] PKG installation fail since build 0.0.42-19975 (#19385)
Tickets not covered by this PR (after further investigation):
(related to #13328) #13327 β Raystorm HD crash during installation (same cause, atten_e<82 8E>.pmd).
Changes:
- PKG entry paths are converted to std::filesystem::path through explicit UTF-8 (utf8_to_wchar / wchar_to_utf8) instead of the narrow constructor, which read the bytes in the host ANSI code page and terminated the process on any it could not map (Shift-JIS file names such as s10c3_R126_<90 AC 91 CC>.mdat in Darkside Chronicles).
- The canonical path is converted back with UTF-8 as well, so a dev_hdd0 path with non-ASCII characters yields a valid key and passes the containment check (upstream rejected every entry as "escapes installation directory").
- The installation directory is canonicalized without its closing / separators, like every entry: on a file system that cannot resolve it, the lexical form no longer keeps an empty last element that no entry can match (network drives).
- Absolute / . / .. checks run on the raw name bytes via a shared leaves_directory() helper; the .. case is now an installation failure instead of an emergency exit.
- The installation directory name read from the package is validated with the same helper and escaped.
- weakly_canonical is computed once per directory and reused for files not yet on disk (existing paths and folders are still resolved whole): identical keys and verdicts, ~25x faster enumeration (6000 files: 1.7 s β 63 ms).
- Supersedes #19463 (trailing separator after the lexical fallback)
- Supersedes #19492
- Minor: map key moved instead of copied.