feat(xgameruntime): implement XGameSaveFiles on the XGameSave folder #40

Closed
github-bot wants to merge 1 commit from gh-pr/40/head into gh-pr/40/base
Owner

@⁠CaseReed on GitHub · 2026-11-22 19:41 UTC · original
CaseReed:feat/xgamesavefiles → main · +397 −15 · 9 files · 1 commits · closed without merging

What

Implements the three functions of #21, the whole issue: XGameSaveFilesGetFolderWithUiAsync, XGameSaveFilesGetFolderWithUiResult, XGameSaveFilesGetRemainingQuota. Signatures and behaviour come from the public GDK documentation (function pages, overview, error table); nothing is measured on a console, and every choice the documentation does not state is in the debt fragment.

  • Folder. The title gets the XGameSave folder itself, %LOCALAPPDATA%\AnyBox\<TitleId>\XGameSave\, as the issue asks: UTF-8, ending in a backslash, without the \?\ prefix. Its containers are the subfolders. XGameSave only writes top-level .xgs files there (a / in a container name is stored as %), so the two cannot collide, and the documentation says top-level files are ignored by XGameSaveFiles. No UI is shown: there is no cloud to sync with. The user and the SCID are handled as in XGameSave (user ignored, SCID only checked for null).
  • Quota. One 256 MiB pool for both systems: XGameSave blob bytes plus the size of every file inside a subfolder. XGameSaveGetRemainingQuota and the XGameSave submit check use the same count. What the title writes itself with Win32 calls is not limited; the remaining quota is 0 once the folder is over.
  • Mixing. The documentation says a title that uses one system and then calls the other gets E_GS_PROVIDER_MISMATCH (0x8083000F). The first successful XGameSaveInitializeProvider, XGameSaveInitializeProviderAsync or XGameSaveFilesGetFolderWithUiAsync picks the system for the life of the process; a call that fails picks nothing, so a title can fall back to the other API. The error table also says "Only one type of Game Saves API can be initialized at a time within a title", which may mean closing the provider lifts it on a console; AnyBox keeps the choice. This adds a check to the two XGameSave initialize functions, which cannot affect a title that only uses XGameSave.
  • Stops. The documented mapping between containers/blobs and folders/files is not implemented: XGameSaveFilesGetFolderWithUiAsync stops with AbxUnsupported on a folder holding .xgs containers, and the XGameSave initialize functions stop on a folder with a subfolder that holds a file (empty subfolders are ignored). A folder link (reparse point) inside the save folder also stops, since following it could loop or leave the folder.

Two existing XGameSave debt entries change with this (quota counting, and the unknown-file stop now limited to .xgs files); the fragment updates both.

If #39 merges first, the scenario lists in CMakeLists.txt and ARCHITECTURE.md will conflict; I will rebase.

Tested

Windows 11, MSVC 19.38 (VS 2022), Ninja, Release, clean build directory, with #38 applied locally only to get MSVC to build (not part of this PR):

  • CTest: 66/66 passed (pipeline_probe skipped: no Khronos validation layer on this machine). Six new e2e scenarios: gamesavefiles, gamesavefiles_mismatch, gamesavefiles_containers, gamesave_folders, gamesave_folders_async, gamesave_empty_folder. The three stop scenarios also check part of the stop message.
  • The gamesave* and async* scenarios repeated 30 times: 330/330.
  • 18 mutations of the implementation; 14 fail at least one scenario (path prefix and trailing backslash, required size, buffer-too-small mapping, quota ignoring subfolders / not recursing / ignoring blobs, each stop removed, mismatch check removed, claiming before the work, empty folders counted as data).
  • python tools/check_conventions.py, python tools/debt_fold.py --check pass.
  • GameSave.cpp and FakeTitle.cpp compile with -Wall -Wextra and no warning on MinGW-w64 GCC 13.1 and 16.2 (Compiler Explorer).

Not tested:

  • No MinGW binary was run here; the Windows CI job is the check for it.
  • Three behaviours have no test that can fail: a reparse-tagged file being treated as a plain file, a subfolder that disappears during the quota walk counting as empty, and two first calls of different APIs racing (exactly one must win). They need conditions a CI runner does not reliably provide.
  • The over-quota scenario creates a 256 MiB sparse file (FSCTL_SET_SPARSE); it fails, rather than skips, on a volume without sparse files.

Self-review: an independent pass over the diff against the documentation found no signature or ABI issue. It found that the reparse-point stop also hit plain files of XGameSave-only titles, that an empty subfolder stopped XGameSave, that a vanished subfolder failed the quota call, and that a failed first call claimed the save system; all four are fixed in this commit.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • python tools/check_conventions.py passes (no comments in code, one declaration per export, Conventional Commit subjects)
  • Unimplemented paths stop (AbxNotImplemented / AbxUnsupported); silent stubs are listed under Silent stubs through a debt fragment
  • Known gaps added, changed or removed through docs/dev/debt/changes/<branch>.md
  • Generic behaviour, not specific to one title
  • No game files, keys, notes or logs added to the repository
  • Depends on: none (independent of #38 and #39)
  • Fixes: Fixes #21
  • Unblocks: none
  • Source of behaviour: public GDK documentation (XGameSaveFiles function pages, overview, storage and interop pages, game saves error table)
  • AI-assisted: yes

🤖 Generated with Claude Code

**@⁠CaseReed** on GitHub · 2026-11-22 19:41 UTC · [original](https://github.com/Dark3581/AnyBox/pull/40) `CaseReed:feat/xgamesavefiles` → `main` · +397 −15 · 9 files · 1 commits · closed without merging ### What Implements the three functions of #21, the whole issue: `XGameSaveFilesGetFolderWithUiAsync`, `XGameSaveFilesGetFolderWithUiResult`, `XGameSaveFilesGetRemainingQuota`. Signatures and behaviour come from the public GDK documentation ([function pages](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/system/xgamesavefiles/functions/xgamesavefilesgetfolderwithuiasync), [overview](https://learn.microsoft.com/en-us/gaming/gdk/docs/features/common/game-save/xgamesavefiles), [error table](https://learn.microsoft.com/en-us/gaming/gdk/docs/features/common/game-save/game-saves-debugging)); nothing is measured on a console, and every choice the documentation does not state is in the debt fragment. - **Folder.** The title gets the XGameSave folder itself, `%LOCALAPPDATA%\AnyBox\<TitleId>\XGameSave\`, as the issue asks: UTF-8, ending in a backslash, without the `\?\` prefix. Its containers are the subfolders. XGameSave only writes top-level `.xgs` files there (a `/` in a container name is stored as `%`), so the two cannot collide, and the documentation says top-level files are ignored by XGameSaveFiles. No UI is shown: there is no cloud to sync with. The user and the SCID are handled as in XGameSave (user ignored, SCID only checked for null). - **Quota.** One 256 MiB pool for both systems: XGameSave blob bytes plus the size of every file inside a subfolder. `XGameSaveGetRemainingQuota` and the XGameSave submit check use the same count. What the title writes itself with Win32 calls is not limited; the remaining quota is 0 once the folder is over. - **Mixing.** The documentation says a title that uses one system and then calls the other gets `E_GS_PROVIDER_MISMATCH` (`0x8083000F`). The first successful `XGameSaveInitializeProvider`, `XGameSaveInitializeProviderAsync` or `XGameSaveFilesGetFolderWithUiAsync` picks the system for the life of the process; a call that fails picks nothing, so a title can fall back to the other API. The error table also says "Only one type of Game Saves API can be initialized at a time within a title", which may mean closing the provider lifts it on a console; AnyBox keeps the choice. This adds a check to the two XGameSave initialize functions, which cannot affect a title that only uses XGameSave. - **Stops.** The documented mapping between containers/blobs and folders/files is not implemented: `XGameSaveFilesGetFolderWithUiAsync` stops with `AbxUnsupported` on a folder holding `.xgs` containers, and the XGameSave initialize functions stop on a folder with a subfolder that holds a file (empty subfolders are ignored). A folder link (reparse point) inside the save folder also stops, since following it could loop or leave the folder. Two existing XGameSave debt entries change with this (quota counting, and the unknown-file stop now limited to `.xgs` files); the fragment updates both. If #39 merges first, the scenario lists in `CMakeLists.txt` and `ARCHITECTURE.md` will conflict; I will rebase. ### Tested Windows 11, MSVC 19.38 (VS 2022), Ninja, Release, clean build directory, with #38 applied locally only to get MSVC to build (not part of this PR): - CTest: 66/66 passed (`pipeline_probe` skipped: no Khronos validation layer on this machine). Six new e2e scenarios: `gamesavefiles`, `gamesavefiles_mismatch`, `gamesavefiles_containers`, `gamesave_folders`, `gamesave_folders_async`, `gamesave_empty_folder`. The three stop scenarios also check part of the stop message. - The `gamesave*` and `async*` scenarios repeated 30 times: 330/330. - 18 mutations of the implementation; 14 fail at least one scenario (path prefix and trailing backslash, required size, buffer-too-small mapping, quota ignoring subfolders / not recursing / ignoring blobs, each stop removed, mismatch check removed, claiming before the work, empty folders counted as data). - `python tools/check_conventions.py`, `python tools/debt_fold.py --check` pass. - `GameSave.cpp` and `FakeTitle.cpp` compile with `-Wall -Wextra` and no warning on MinGW-w64 GCC 13.1 and 16.2 (Compiler Explorer). Not tested: - No MinGW binary was run here; the Windows CI job is the check for it. - Three behaviours have no test that can fail: a reparse-tagged *file* being treated as a plain file, a subfolder that disappears during the quota walk counting as empty, and two first calls of different APIs racing (exactly one must win). They need conditions a CI runner does not reliably provide. - The over-quota scenario creates a 256 MiB sparse file (`FSCTL_SET_SPARSE`); it fails, rather than skips, on a volume without sparse files. Self-review: an independent pass over the diff against the documentation found no signature or ABI issue. It found that the reparse-point stop also hit plain files of XGameSave-only titles, that an empty subfolder stopped XGameSave, that a vanished subfolder failed the quota call, and that a failed first call claimed the save system; all four are fixed in this commit. ### Checklist <!-- Rules behind each item: 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] `python tools/check_conventions.py` passes (no comments in code, one declaration per export, Conventional Commit subjects) - [x] Unimplemented paths stop (`AbxNotImplemented` / `AbxUnsupported`); silent stubs are listed under Silent stubs through a debt fragment - [x] Known gaps added, changed or removed through `docs/dev/debt/changes/<branch>.md` - [x] Generic behaviour, not specific to one title - [x] No game files, keys, notes or logs added to the repository - [x] Depends on: none (independent of #38 and #39) - [x] Fixes: Fixes #21 - [x] Unblocks: none - [x] Source of behaviour: public GDK documentation (XGameSaveFiles function pages, overview, storage and interop pages, game saves error table) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
XGameSaveFilesGetFolderWithUiAsync, XGameSaveFilesGetFolderWithUiResult and XGameSaveFilesGetRemainingQuota, from the public GDK documentation. The title gets the per-title XGameSave folder and saves in its subfolders; both save systems share one 256 MiB quota, and a title that mixes them gets E_GS_PROVIDER_MISMATCH. Mapping containers to folders is not implemented: each API stops when the folder holds the other one's data.

Fixes #21

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 19:15:06 +00:00
github-bot closed this pull request 2026-11-26 19:15:06 +00:00
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-22 19:41 UTC · original

Progress report (9486199 → d027b13)

📈 Libraries: 25.67% (+0.6696%, +3 implemented functions)

✅ 3 implemented
Library Name
xgameruntime XGameSaveFilesGetFolderWithUiAsync
xgameruntime XGameSaveFilesGetFolderWithUiResult
xgameruntime XGameSaveFilesGetRemainingQuota

Changed libraries

Library Before After Change
xgameruntime 58/391 (14.83%) 61/391 (15.6%) +0.77%
**@⁠github-actions[bot]** on GitHub · 2026-11-22 19:41 UTC · [original](https://github.com/Dark3581/AnyBox/pull/40#issuecomment-7084604807) <!-- progress-report --> ### Progress report (9486199 → d027b13) 📈 **Libraries**: 25.67% (+0.6696%, +3 implemented functions) <details> <summary>✅ 3 implemented</summary> | Library | Name | | - | - | | xgameruntime | `XGameSaveFilesGetFolderWithUiAsync` | | xgameruntime | `XGameSaveFilesGetFolderWithUiResult` | | xgameruntime | `XGameSaveFilesGetRemainingQuota` | </details> #### Changed libraries | Library | Before | After | Change | | - | - | - | - | | xgameruntime | 58/391 (14.83%) | 61/391 (15.6%) | +0.77% |
Author
Owner

@⁠Dark3581 on GitHub · 2026-11-22 20:50 UTC · original · reviewed

Reviewed — looks good, needs a rebase

Folder, quota and the one-system-per-process rule are all sourced or listed in the fragment. The code is ready; the branch needs a rebase onto main first, since #39 just landed. Please rebase and push, and I will merge it.

What I ran

Head d027b13, merged onto current main. Windows 10, MinGW (WinLibs GCC 15.2 UCRT), Ninja, Release, clean build directory, NTFS volume.

Results

Check Result Note
MinGW full build pass no warning
CTest 67/67 the six new scenarios included, the 256 MiB sparse-file quota case passes here
e2e_gamesave* and e2e_async* repeated 330/330 11 scenarios, 30 runs each
check_conventions.py ok
debt_fold.py --check ok
CI pass

Findings

Blocking

None.

Non-blocking

  • Rebase needed: #39 is merged, and it changes the same scenario lists in core/libs/tests/CMakeLists.txt and docs/dev/ARCHITECTURE.md, so this branch now conflicts with main. Keeping both sets of scenarios is all it takes; after the rebase, ctest and python tools/debt_fold.py --check should still pass with both fragments.
  • Keeping the save system chosen for the life of the process, rather than reading "only one at a time" as lifting on close, is the safer reading until a console says otherwise; good that the fragment says so.

Not verified

MSVC, the three races you list as untestable, and a volume without sparse files.

Thanks — the stops on mixed folders keep a title from silently losing saves, which is what matters here.

**@⁠Dark3581** on GitHub · 2026-11-22 20:50 UTC · [original](https://github.com/Dark3581/AnyBox/pull/40#pullrequestreview-6014464650) · **reviewed** # Reviewed — looks good, needs a rebase Folder, quota and the one-system-per-process rule are all sourced or listed in the fragment. The code is ready; the branch needs a rebase onto `main` first, since #39 just landed. Please rebase and push, and I will merge it. ## What I ran Head `d027b13`, merged onto current `main`. Windows 10, MinGW (WinLibs GCC 15.2 UCRT), Ninja, Release, clean build directory, NTFS volume. ## Results | Check | Result | Note | |---|---|---| | MinGW full build | pass | no warning | | CTest | 67/67 | the six new scenarios included, the 256 MiB sparse-file quota case passes here | | `e2e_gamesave*` and `e2e_async*` repeated | 330/330 | 11 scenarios, 30 runs each | | `check_conventions.py` | ok | | | `debt_fold.py --check` | ok | | | CI | pass | | ## Findings ### Blocking None. ### Non-blocking - **Rebase needed:** #39 is merged, and it changes the same scenario lists in `core/libs/tests/CMakeLists.txt` and `docs/dev/ARCHITECTURE.md`, so this branch now conflicts with `main`. Keeping both sets of scenarios is all it takes; after the rebase, `ctest` and `python tools/debt_fold.py --check` should still pass with both fragments. - Keeping the save system chosen for the life of the process, rather than reading "only one at a time" as lifting on close, is the safer reading until a console says otherwise; good that the fragment says so. ## Not verified MSVC, the three races you list as untestable, and a volume without sparse files. Thanks — the stops on mixed folders keep a title from silently losing saves, which is what matters here.
Author
Owner

@⁠github-actions[bot] on GitHub · 2026-11-22 22:12 UTC · original

This pull request conflicts with main. Rebase it on current main and force-push the branch; the label is removed automatically once it merges cleanly.

**@⁠github-actions[bot]** on GitHub · 2026-11-22 22:12 UTC · [original](https://github.com/Dark3581/AnyBox/pull/40#issuecomment-7086642791) This pull request conflicts with `main`. Rebase it on current `main` and force-push the branch; the label is removed automatically once it merges cleanly.
Author
Owner

@⁠Dark3581 on GitHub · 2026-11-23 00:02 UTC · original · approved these changes

Approving: the code was ready, as the earlier review said. Since #39 landed first, I rebased this myself so you did not have to wait.

**@⁠Dark3581** on GitHub · 2026-11-23 00:02 UTC · [original](https://github.com/Dark3581/AnyBox/pull/40#pullrequestreview-6015242320) · **approved these changes** Approving: the code was ready, as the earlier review said. Since #39 landed first, I rebased this myself so you did not have to wait.
Author
Owner

@⁠Dark3581 on GitHub · 2026-11-23 00:02 UTC · original

Landed on main as 013dc10 (through #58, a rebase merge, so the commit is yours: you are its author). The only changes from this branch are the conflict resolutions with #39 in the scenario lists of core/libs/tests/CMakeLists.txt, FakeTitle.cpp and ARCHITECTURE.md, which now hold both sets. Retested on the rebased commit: 72/72 ctest, the gamesave, taskqueue and async e2e scenarios 30 times each, conventions and debt checks. Thank you for the work on this one.

**@⁠Dark3581** on GitHub · 2026-11-23 00:02 UTC · [original](https://github.com/Dark3581/AnyBox/pull/40#issuecomment-7088017303) Landed on `main` as 013dc10 (through #58, a rebase merge, so the commit is yours: you are its author). The only changes from this branch are the conflict resolutions with #39 in the scenario lists of `core/libs/tests/CMakeLists.txt`, `FakeTitle.cpp` and `ARCHITECTURE.md`, which now hold both sets. Retested on the rebased commit: 72/72 ctest, the gamesave, taskqueue and async e2e scenarios 30 times each, conventions and debt checks. Thank you for the work on this one.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.