Skip to content

feat(xgameruntime): implement XPersistentLocalStorage on a per-title folder - #80

Open
CaseReed wants to merge 1 commit into
Dark3581:mainfrom
CaseReed:feat/xpersistentlocalstorage
Open

CaseReed wants to merge 1 commit into
Dark3581:mainfrom
CaseReed:feat/xpersistentlocalstorage

Conversation

@CaseReed

Copy link
Copy Markdown
Contributor

What

Implements XPersistentLocalStorage from #20 on a per-title folder. This takes the issue in part: five of the six exports are done, XPersistentLocalStorageMountForPackage stays a stub (it now carries its documented signature).

Function Behaviour
XPersistentLocalStorageGetPathSize, XPersistentLocalStorageGetPath %LOCALAPPDATA%\AnyBox\<TitleId>\PersistentLocalStorage\, created on first use, beside the XGameSave folder and outside it, so it never counts against the save quota or triggers the mixed-folder stops. UTF-8, trailing backslash, no \?\ prefix, as XGameSaveFiles. The size and pathUsed count the terminator. A short buffer returns HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), the documented PC error, without writing.
XPersistentLocalStorageGetSpaceInfo usedBytes is the sum of the file sizes under the title's folder; availableFreeBytes and totalFreeBytes are the bytes GetDiskFreeSpaceExW reports free to the caller; totalBytes is usedBytes + totalFreeBytes. A folder link inside the storage stops, as in GameSave.cpp.
XPersistentLocalStoragePromptUserForSpaceAsync, ...Result Stop with AbxUnsupported for every input.
XPersistentLocalStorageMountForPackage Still AbxNotImplemented: a relinked title has no package identity, so which title's storage a package identifier names is unknown.

Choices I would like your ruling on:

  • Prompt for space stops (the decision the issue asks for). The documentation only gives results that reflect a user's choice (S_OK when the user acted, E_ABORT when they declined) and says not to use the call on PC. With no UI, either result would invent the user's answer. Completing with E_ABORT would keep such a title running; say so if you prefer it.
  • The space mapping is AnyBox's. The documentation describes the fields for a storage allocated on a console; the host provisions nothing, and <PersistentLocalStorage> in MicrosoftGame.config is not read (the GetPath page says no entry is required on PC). It is in the fragment with a Closes when.
  • Shared helper. The folder lookup of OpenRoot and the UTF-8 conversion of SaveFilesFolder moved unchanged out of GameSave.cpp into TitleFolder.cpp / TitleFolder.hpp, to avoid a second copy. GameSave still maps their errors through FromWin32. One stop message changed for XGameSave as a result: "no folder for the title's saves" is now "no folder for the title's data".

This PR and #79 both add lines to the scenario lists (core/libs/tests/CMakeLists.txt, FakeTitle.cpp, e2e.py), the xgameruntime source list, ARCHITECTURE.md and the generated README.md, so the second to land needs a rebase; I will rebase whichever remains.

Tested

Windows 11, MSVC 19.38 (Visual Studio 2022), Ninja, Release, clean build directory:

  • Full build with no warning, CTest 82/82 passed, pipeline_probe skipped (no Khronos validation layer here). The seven existing gamesave* scenarios still pass after the helper move.
  • New e2e scenarios:
    • pls: exact path, size and pathUsed with the terminator, a buffer one short and a zero-size buffer return the error without writing, a null pathUsed, the folder is writable, a 4 KiB write leaves the XGameSave quota at exactly 256 MiB, rewriting a 1234-byte file in a subfolder grows usedBytes by exactly 1234, usedBytes equals the folder content summed by e2e.py, totalBytes == usedBytes + totalFreeBytes, and free space matches GetDiskFreeSpaceExW read by e2e.py (1 GiB tolerance). A second run finds the first run's file; a third run under another title ID gets its own folder.
    • pls_prompt, pls_prompt_result: the stop names the right function and message.
  • Mutations: reporting volume usage as usedBytes, and a walk that skips subfolders, each fail e2e_pls ("FAIL used bytes after a write").
  • python tools/check_conventions.py, python tools/debt_fold.py --check (24 fragments), python tools/readme_docs.py: pass. progress.py --module xgameruntime: 77 implemented.
  • MinGW: full Build workflow on my fork before opening this PR, windows and both relinker jobs green: https://github.com/CaseReed/AnyBox/actions/runs/45158110637

Not tested: anything on a console or against the desktop GDK runtime (terminator, trailing backslash, encoding, the space fields). No test covers a folder link inside the storage, a subfolder vanishing during the walk, GetDiskFreeSpaceExW or folder creation failing, the null-pointer stops, a non-ASCII or very long LOCALAPPDATA, or a host with per-user disk quotas. The folder walk runs on every GetSpaceInfo call and was not timed on a large folder.

Self-review: an independent pass over the diff (signatures and struct layout against the documentation, the helper move against the merged XGameSave behaviour, debt lines against the code, whether each test can fail, how anybox_scan.py counts stubs) found nothing blocking. Fixed from it before opening: usedBytes reported the whole volume's usage; MountForPackage and the prompt Result call counted as implemented while doing nothing useful (the first is a stub again, the second stops); the test compared against the volume's total free bytes instead of the caller's.

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 (overlaps feat(xgameruntime): implement the remaining XSystem functions #79 in the scenario lists, see above)
  • Fixes: part of feat(xgameruntime): implement XPersistentLocalStorage on a per-title folder #20 (XPersistentLocalStorageMountForPackage remains)
  • Unblocks: none
  • Source of behaviour: the public XPersistentLocalStorage reference pages on learn.microsoft.com (function pages and XPersistentLocalStorageSpaceInfo). No header copied, nothing disassembled.
  • AI-assisted: yes

🤖 Generated with Claude Code

…folder

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot added the libs core/libs: libraries, runtime and their tests label Nov 23, 2026
@github-actions

Copy link
Copy Markdown

Progress report (9f53c52 → 9057ced)

📈 Libraries: 28.85% (+1.1013%, +5 implemented functions)

✅ 5 implemented
Library Name
xgameruntime XPersistentLocalStorageGetPath
xgameruntime XPersistentLocalStorageGetPathSize
xgameruntime XPersistentLocalStorageGetSpaceInfo
xgameruntime XPersistentLocalStoragePromptUserForSpaceAsync
xgameruntime XPersistentLocalStoragePromptUserForSpaceResult

Changed libraries

Library Before After Change
xgameruntime 72/397 (18.14%) 77/397 (19.4%) +1.26%

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libs core/libs: libraries, runtime and their tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant