feat(libSceFreeTypeOt): implement FT_Stream_Open, FT_Stream_New and FT_Raccess_Guess #16121

Merged
noamroger merged 3 commits from upstream-pr/16121 into main 2026-11-10 10:47:36 +00:00
noamroger commented 2026-11-05 17:50:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by noamroger on 2026-11-05T17:50:58Z.


What

Implements the last three stream and resource fork stubs of libSceFreeTypeOt that the debt file still listed as throwing: FT_Stream_Open (iruPsrXCN7U), FT_Stream_New (uDXTnGbAz44) and FT_Raccess_Guess (8cnVx1yH9-I). It follows up on the merged FT_Stream_* calls and #15050 (FT_Raccess_Get_HeaderInfo/Get_DataOffsets), in two commits.

  • FT_Stream_Open (new src/System.cpp) follows the ANSI layer of FreeType 2.4.12 src/base/ftsystem.c on the existing 80-byte guest stream record: the guest path resolves like libc paths (ResolvePathError_nid_no_patch), a host file backs guest-callable read and close callbacks, and the errors match 2.4.12 (Invalid_Stream_Handle 0x28, Cannot_Open_Resource 0x01, Cannot_Open_Stream 0x51 for an empty file). Directories and other non-regular files throw, since their fopen result depends on the C library.
  • FT_Stream_New follows 2.4.12 ftobjs.c on the 64-byte LP64 FT_Open_Args: memory, pathname then stream sources in that order, the record allocated and freed through ft_mem_alloc/ft_mem_free with the library memory, and a caller stream taking the library memory as in FreeType.
  • FT_Raccess_Guess ports the nine rules of 2.4.12 ftrfork.c in order (AppleDouble, AppleSingle, darwin ._, /..namedfork/rsrc, /rsrc, resource.frk/, .resource/, %, .AppleDouble/). Names are allocated from the library memory, and the AppleDouble probes open their file through FT_Stream_New and release it with FT_Stream_Free.

The open questions are recorded in docs/dev/debt/libSceFreeTypeOt.md: the console system layer is unmeasured (the unix layer would map the file and leave read null instead of using callbacks), and FT_Raccess_Guess assumes the default FT_CONFIG_OPTION_MAC_FONTS. Null pointers that 2.4.12 dereferences throw before anything is allocated or written. The Unknown stub count goes from 61 to 58.

Tested

Linux (Ubuntu 24.04, g++ 13), full build with -DBUILD_TESTING=ON: the new guest_freetype_ot_system test plus the existing guest_freetype_ot_raccess, guest_freetype_ot_memory, guest_freetype_ot_constants, guest_freetype_corner, guest_freetype_ot, guest_freetype_stream and their relinked _patched variants pass (8/8). The new test was also run with -fsanitize=address,undefined (no error, no leak). It covers:

  • FT_Stream_Open: null stream, missing file (record still reset), empty file, directory and null path (throw), then seek/read/frame/try-read through the existing Ot FT_Stream_* calls on a 300-byte file, and close;
  • FT_Stream_New: null result, library and arguments, no source, memory winning over path, path, missing path, throwing path (record freed), caller stream, failed allocation, with allocations and frees counted;
  • FT_Raccess_Guess: the nine rules on real AppleSingle/AppleDouble files (rewind from a non-zero position, unsigned 32-bit fork offset, a double file without a fork entry), no stream, a name without a directory, cut and empty entry lists, failed allocations, null base name and library.

tools/check_conventions.py --base upstream/main passes. tools/pr_overlap.py cannot reach the GitHub API from my environment; I checked by NID that no open pull request changes iruPsrXCN7U, uDXTnGbAz44 or 8cnVx1yH9-I. Text conflicts only (stub counter, end of CMakeLists.txt) are expected with #15052, #15053, #15687 and #12370; I will rebase whichever merges first.

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 under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5176123777 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16121). Originally posted by [noamroger](https://github.com/noamroger) on 2026-11-05T17:50:58Z. --- ### What Implements the last three stream and resource fork stubs of libSceFreeTypeOt that the debt file still listed as throwing: `FT_Stream_Open` (`iruPsrXCN7U`), `FT_Stream_New` (`uDXTnGbAz44`) and `FT_Raccess_Guess` (`8cnVx1yH9-I`). It follows up on the merged `FT_Stream_*` calls and #15050 (`FT_Raccess_Get_HeaderInfo`/`Get_DataOffsets`), in two commits. - `FT_Stream_Open` (new `src/System.cpp`) follows the ANSI layer of FreeType 2.4.12 `src/base/ftsystem.c` on the existing 80-byte guest stream record: the guest path resolves like libc paths (`ResolvePathError_nid_no_patch`), a host file backs guest-callable `read` and `close` callbacks, and the errors match 2.4.12 (Invalid_Stream_Handle 0x28, Cannot_Open_Resource 0x01, Cannot_Open_Stream 0x51 for an empty file). Directories and other non-regular files throw, since their `fopen` result depends on the C library. - `FT_Stream_New` follows 2.4.12 `ftobjs.c` on the 64-byte LP64 `FT_Open_Args`: memory, pathname then stream sources in that order, the record allocated and freed through `ft_mem_alloc`/`ft_mem_free` with the library memory, and a caller stream taking the library memory as in FreeType. - `FT_Raccess_Guess` ports the nine rules of 2.4.12 `ftrfork.c` in order (AppleDouble, AppleSingle, darwin `._`, `/..namedfork/rsrc`, `/rsrc`, `resource.frk/`, `.resource/`, `%`, `.AppleDouble/`). Names are allocated from the library memory, and the AppleDouble probes open their file through `FT_Stream_New` and release it with `FT_Stream_Free`. The open questions are recorded in `docs/dev/debt/libSceFreeTypeOt.md`: the console system layer is unmeasured (the unix layer would map the file and leave `read` null instead of using callbacks), and `FT_Raccess_Guess` assumes the default `FT_CONFIG_OPTION_MAC_FONTS`. Null pointers that 2.4.12 dereferences throw before anything is allocated or written. The Unknown stub count goes from 61 to 58. ### Tested Linux (Ubuntu 24.04, g++ 13), full build with `-DBUILD_TESTING=ON`: the new `guest_freetype_ot_system` test plus the existing `guest_freetype_ot_raccess`, `guest_freetype_ot_memory`, `guest_freetype_ot_constants`, `guest_freetype_corner`, `guest_freetype_ot`, `guest_freetype_stream` and their relinked `_patched` variants pass (8/8). The new test was also run with `-fsanitize=address,undefined` (no error, no leak). It covers: - `FT_Stream_Open`: null stream, missing file (record still reset), empty file, directory and null path (throw), then seek/read/frame/try-read through the existing Ot `FT_Stream_*` calls on a 300-byte file, and close; - `FT_Stream_New`: null result, library and arguments, no source, memory winning over path, path, missing path, throwing path (record freed), caller stream, failed allocation, with allocations and frees counted; - `FT_Raccess_Guess`: the nine rules on real AppleSingle/AppleDouble files (rewind from a non-zero position, unsigned 32-bit fork offset, a double file without a fork entry), no stream, a name without a directory, cut and empty entry lists, failed allocations, null base name and library. `tools/check_conventions.py --base upstream/main` passes. `tools/pr_overlap.py` cannot reach the GitHub API from my environment; I checked by NID that no open pull request changes `iruPsrXCN7U`, `uDXTnGbAz44` or `8cnVx1yH9-I`. Text conflicts only (stub counter, end of `CMakeLists.txt`) are expected with #15052, #15053, #15687 and #12370; I will rebase whichever merges first. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!16121
No description provided.