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

Manually merged
github merged 1 commit from gh-pr/55/head into gh-pr/55/base 2026-11-26 04:06:52 +00:00
Owner

@⁠gefydev on GitHub · 2026-11-22 22:50 UTC · original
gefydev:gamesave-windows-names → main · +64 −2 · 1 files · 1 commits · merged 2026-11-23 09:44 UTC

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.
**@⁠gefydev** on GitHub · 2026-11-22 22:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/55) `gefydev:gamesave-windows-names` → `main` · +64 −2 · 1 files · 1 commits · merged 2026-11-23 09:44 UTC `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.
Container and blob names become file names with only unusual characters
escaped, so some names reached the file system as names Windows treats
specially:

- "." and ".." were the provider's folder and its parent: deleting a
  container named ".." deleted every provider's saves, "." the whole
  provider.
- a device name (aux, CON.dat, COM1, ...) opened the device, so the
  write failed with E_FAIL.
- a trailing dot or space was dropped, so "save." came back as "save".

Such names now get one more character escaped (%XX), which the existing
decoding already reverses. Other names keep their file names, so
existing saves are found as before.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:06:52 +00:00
github manually merged commit cfed9051da into gh-pr/55/base 2026-11-26 04:06:52 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-23 09:45 UTC · original

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!

**@⁠ivall** on GitHub · 2026-11-23 09:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/55#issuecomment-7097052549) 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!
This discussion has been locked. Commenting is limited to contributors.
No description provided.