fix(savedata): let a trailing % in a directory name pattern match nothing #4504

Merged
EagleBearerYS merged 1 commit from upstream-pr/4504 into main 2026-10-12 18:29:49 +00:00
EagleBearerYS commented 2026-10-12 13:46:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-12T13:46:58Z.


What

sceSaveDataDirNameSearch reads % in the directory name pattern as any run of characters and _ as exactly one (the same rules shadPS4's matcher states in its comments: "0 or more wildcard", "1 character wildcard"). dir_name_match stopped as soon as the name ran out and then required the pattern to have ended too, so a % that was left at the end with nothing to match made the whole match fail:

Saves Pattern main This branch
TRAIL, TRAIL1 TRAIL% TRAIL1 TRAIL, TRAIL1
TRAIL, TRAIL1 TRAIL%% TRAIL1 TRAIL, TRAIL1
TRAIL, TRAIL1 TRAI_% TRAIL1 TRAIL, TRAIL1
TRAIL, TRAIL1 TRAIL_% TRAIL1 TRAIL1

A title that names its main save SAVEDATA and looks for its saves with SAVEDATA% gets no hit for that save and treats it as missing. The matcher now skips the %s left at the end of the pattern before it checks that both strings have ended, so a trailing % matches no characters as one in the middle already did. A % in the middle, _, and a pattern without wildcards behave as before. TechnicalDebt now names the source of the wildcard rules, which are not confirmed on hardware either.

Tested

Windows 11 (10.0.26300), WinLibs MinGW-w64 GCC 15.2.0 r7 (UCRT), Release, -DBUILD_TESTING=ON, on main at c6efe068:

  • New TrailingWildcards in guest_savedata_search creates the saves TRAIL and TRAIL1 and searches with the four patterns in the table. With main's Export.cpp it fails at the first pattern (a trailing % must also match no characters); with the change it passes, 20 runs in a row.
  • All 128 tests registered in core/libs/prx/libc/CMakeLists.txt and core/libs/prx/libkernel/CMakeLists.txt that build on Windows pass, and so do the other save-data tests (guest_savedata_cancel, guest_savedata_convert, guest_savedata_delete, guest_savedata_mount_status, savedata_core_write_replacement, savedata_memory_growth, savedata_memory_growth_read_failure, savedata_memory_metadata, savedata_native_write_replacement, savedata_replace_file_failure).
  • tools/check_conventions.py --base origin/main passes.
  • Not tested: Linux, macOS, any title.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4830322392 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4504). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-12T13:46:58Z. --- ### What `sceSaveDataDirNameSearch` reads `%` in the directory name pattern as any run of characters and `_` as exactly one (the same rules shadPS4's matcher states in its comments: "0 or more wildcard", "1 character wildcard"). `dir_name_match` stopped as soon as the name ran out and then required the pattern to have ended too, so a `%` that was left at the end with nothing to match made the whole match fail: | Saves | Pattern | `main` | This branch | |---|---|---|---| | `TRAIL`, `TRAIL1` | `TRAIL%` | `TRAIL1` | `TRAIL`, `TRAIL1` | | `TRAIL`, `TRAIL1` | `TRAIL%%` | `TRAIL1` | `TRAIL`, `TRAIL1` | | `TRAIL`, `TRAIL1` | `TRAI_%` | `TRAIL1` | `TRAIL`, `TRAIL1` | | `TRAIL`, `TRAIL1` | `TRAIL_%` | `TRAIL1` | `TRAIL1` | A title that names its main save `SAVEDATA` and looks for its saves with `SAVEDATA%` gets no hit for that save and treats it as missing. The matcher now skips the `%`s left at the end of the pattern before it checks that both strings have ended, so a trailing `%` matches no characters as one in the middle already did. A `%` in the middle, `_`, and a pattern without wildcards behave as before. TechnicalDebt now names the source of the wildcard rules, which are not confirmed on hardware either. ### Tested Windows 11 (10.0.26300), WinLibs MinGW-w64 GCC 15.2.0 r7 (UCRT), Release, `-DBUILD_TESTING=ON`, on `main` at c6efe068: - New `TrailingWildcards` in `guest_savedata_search` creates the saves `TRAIL` and `TRAIL1` and searches with the four patterns in the table. With `main`'s `Export.cpp` it fails at the first pattern (`a trailing % must also match no characters`); with the change it passes, 20 runs in a row. - All 128 tests registered in `core/libs/prx/libc/CMakeLists.txt` and `core/libs/prx/libkernel/CMakeLists.txt` that build on Windows pass, and so do the other save-data tests (`guest_savedata_cancel`, `guest_savedata_convert`, `guest_savedata_delete`, `guest_savedata_mount_status`, `savedata_core_write_replacement`, `savedata_memory_growth`, `savedata_memory_growth_read_failure`, `savedata_memory_metadata`, `savedata_native_write_replacement`, `savedata_replace_file_failure`). - `tools/check_conventions.py --base origin/main` passes. - Not tested: Linux, macOS, any title. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
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!4504
No description provided.