Game saves: names Windows does not keep as file names stay intact #54

Merged
gefydev merged 1 commit from upstream-pr/55 into main 2026-11-23 09:44:40 +00:00
gefydev commented 2026-11-22 22:50:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by gefydev on 2026-11-22T22:50:02Z.


gamesave.rs turns container and blob names into file names with enc, which only escapes characters outside [A-Za-z0-9._- ]. Some names that pass through unchanged are ones Windows treats specially:

  • "." and "..": pr.root.join(enc(name)) is the provider's folder or its parent. XGameSaveDeleteContainer(p, "..") runs remove_dir_all on gamesave\, deleting every provider's saves; "." deletes the whole provider.
  • Device names (aux, CON.dat, COM1, ...): the write opens the device and XGameSaveSubmitUpdate returns E_FAIL.
  • A trailing dot or space is dropped by Win32, so a blob written as save. is enumerated as save.

enc now escapes one more character for these (.. → %2E%2E, aux → %41ux, save. → save%2E). dec already reverses %XX, and every other name keeps the file name it had, so existing saves are still found.

Validation

  • New test names_windows_would_change_round_trip: containers aux, .. and slot., each with blobs aux, CON.dat, save. and save , all enumerate back with their names and sizes; deleting .. and . leaves the provider's folder. On main it fails at the first submit (E_FAIL for aux). Separately, on main, XGameSaveDeleteContainer(p, ".") removes the provider's folder.
  • cargo test -p xcl --lib: 340 passed, 0 failed, on Windows GNU under Wine.
<!-- greyfinch-sync:ivall/xcl:issue:6548841938 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/55). Originally posted by [gefydev](https://github.com/gefydev) on 2026-11-22T22:50:02Z. --- `gamesave.rs` turns container and blob names into file names with `enc`, which only escapes characters outside `[A-Za-z0-9._- ]`. Some names that pass through unchanged are ones Windows treats specially: - `"."` and `".."`: `pr.root.join(enc(name))` is the provider's folder or its parent. `XGameSaveDeleteContainer(p, "..")` runs `remove_dir_all` on `gamesave\`, deleting every provider's saves; `"."` deletes the whole provider. - Device names (`aux`, `CON.dat`, `COM1`, ...): the write opens the device and `XGameSaveSubmitUpdate` returns `E_FAIL`. - A trailing dot or space is dropped by Win32, so a blob written as `save.` is enumerated as `save`. `enc` now escapes one more character for these (`..` → `%2E%2E`, `aux` → `%41ux`, `save.` → `save%2E`). `dec` already reverses `%XX`, and every other name keeps the file name it had, so existing saves are still found. ## Validation - New test `names_windows_would_change_round_trip`: containers `aux`, `..` and `slot.`, each with blobs `aux`, `CON.dat`, `save.` and `save `, all enumerate back with their names and sizes; deleting `..` and `.` leaves the provider's folder. On `main` it fails at the first submit (`E_FAIL` for `aux`). Separately, on `main`, `XGameSaveDeleteContainer(p, ".")` removes the provider's folder. - `cargo test -p xcl --lib`: 340 passed, 0 failed, on Windows GNU under Wine.
upstream-sync closed this pull request 2026-11-24 06:56:56 +00:00
ivall commented 2026-11-24 07:00:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T09:45:14Z.


Merged (331b734). On top (ff5c940): a device name with spaces before its extension (nul .txt) is escaped too – Win32 drops trailing spaces of the base; added to names_windows_would_change_round_trip.

Tested on Windows 11 (RX 9070): cargo test --workspace green (lib 351, e2e), and a 45 s Unicorn Overlord run on the release build (VFS hooks active, ~60 fps, clean exit). Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7097052549 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/55#issuecomment-7097052549). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T09:45:14Z. --- Merged (331b734). On top (ff5c940): a device name with spaces before its extension (`nul .txt`) is escaped too – Win32 drops trailing spaces of the base; added to `names_windows_would_change_round_trip`. Tested on Windows 11 (RX 9070): `cargo test --workspace` green (lib 351, e2e), and a 45 s Unicorn Overlord run on the release build (VFS hooks active, ~60 fps, clean exit). Thanks!
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
xcl-dev/xcl!54
No description provided.