Skip to content

Saves: export and import - #895

Open
peiikai wants to merge 5 commits into
developfrom
feature/saves-manager
Open

peiikai wants to merge 5 commits into
developfrom
feature/saves-manager

Conversation

@peiikai

@peiikai peiikai commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Adds a Saves section to Settings > System on the start screen: Export saves, Import saves and Saves folder.

What it does

  • Export saves writes one .zip with every save (vanilla and each seed's, with the seed files they need) laid out like the data folder, plus lasrecomp-saves.txt (format, app version, game version, when each slot was saved). Game files are never included: a seed's romfs/ is left out.
  • Import saves checks every save first (size, version 0xE, header and body CRC). It lists each game in the file with a checkbox, and greys out a game with a damaged save, a seed that is neither here nor in the file, or a different seed with the same name (seed ids differ, or only one side has one). The list has no size limit and scrolls when long. The saves it replaces are zipped into backups/ first (the last 20 are kept). Each slot is written as .pending working copies, old sidecars the file doesn't have are set aside, then the save is renamed into place, the set-aside files removed and its sidecars renamed after it, with the folder flushed to disk: the same order as fs.c's commit. A save never pairs with an old .flagsx, and an old save never loses its own. A cut-off import or game save is made whole before its folder is read again: every save mount does it (so a game started without the start screen too), the start screen does it for every folder, and each import does it before its backup. A seed is written to rando/<seed>.import and renamed into place; a failed or cut-off one is removed. Names Windows would read differently (a :, a trailing dot or space) are left out. A seed named like a Windows device (con, com1) exports everywhere and shows as not importable on Windows; the rando tab no longer makes such names. It runs on the start screen only, where no save is open.
  • Saves folder opens the data folder (Finder / Explorer / Files). It isn't on Android, where other apps can't open the app's folder.

A sync folder was in the first version of this PR. It is split out for its own design pass and will come as a separate PR (the code is kept in 47cf20b).

Platforms

  • Desktop: SDL's save and open dialogs.
  • iOS: the existing document picker, plus a new export picker (initForExportingURLs).
  • Android: ACTION_OPEN_DOCUMENT to import and ACTION_CREATE_DOCUMENT to export. This covers the Android request in issue 892 without All files access. Saves can go to Documents or Downloads, which a PC can see over USB.
  • miniz is now built on every platform. The Makefile always builds zipfile.c and miniz. Android's CMake fetches the same pinned release with its own download and unzip (no bash needed). The notices now list Android.

Text

New strings are translated in all 11 tables (one appended block each).

Tested

  • tools/test_saves.c (new, no game data), all passing on macOS:
    • export (no .pending, no romfs/, unplayed seeds left out)
    • inspect, and import into an empty folder (seed added, times kept)
    • import over existing slots (backup made, stale sidecar removed)
    • a damaged save, unsafe names (../), a different seed with the same name, a newer format, a file that isn't a zip
    • recovery after a cut-off import (set-aside files put back or removed) and after a game save whose sidecar rename didn't happen
    • 150 seeds (none left out), leftovers of a cut-off import cleared, the backup order within one second, a local seed with no id, Windows-unsafe names
  • Android CMake's miniz step run on its own with cmake -P: same files as tools/fetch_miniz.sh.
  • macOS build clean; start screen screenshots with a scratch data folder showed the Saves rows and the import window (good, damaged and missing-seed games). Taken before the sync row was removed.
  • Android round trip on a Retroid Pocket 5 (Android 13), release-signed build of this branch installed over v0.6.0:
    • Export saves opened the system save picker with the default name; saved to Downloads; the cache copy was removed.
    • On the Mac, Import saves listed the file's games correctly; the imported saves were byte-identical to the device's, file times kept.
    • Mac export (File 1, a new File 2, Autosave) imported on the device through the system file picker: backup written to backups/, saves byte-identical to the Mac's, and the game's file select showed File 2 with the Autosave intact.
  • Round trip again on the final head (f596350), same device and steps: Android export pulled to the Mac and imported there byte-identical with times kept; a Mac export with a new File 3 imported on the device through the system file picker, backup written, saves byte-identical.
  • The host filesystem tests (test_save_flags, test_save_errors, test_save_romfs_fds) pass with the mount's new call.
  • Import window with 41 games: the list scrolls and the buttons stay on screen (macOS screenshot).
  • iOS: compile check only. CI builds all platforms.
  • Not yet: an iPhone/iPad round trip.

🤖 Generated with Claude Code

peiikai and others added 2 commits November 25, 2026 15:52
Settings > System > Saves on the start screen:
- Export saves: every save (vanilla and each seed's, with the seed files
  they need) in one .zip laid out like the data folder. Never game files.
- Import saves: every save in the file is checked (size, version, both
  CRCs); each game can be picked; the saves it replaces are zipped into
  backups/ first; each slot is written as working copies and renamed in
  place, the save first, so a save and its .flagsx always match.
- Sync folder: a folder the player picks on each device (iCloud Drive, a
  cloud drive folder, any folder on Android through the system picker).
  After each save the slots are merged into one bundle there, newer slot
  wins; newer saves found there are offered at the start.
- Saves folder: opens the data folder (not on Android).

Platforms: desktop file dialogs; iOS document pickers and an export
picker, the sync folder kept by bookmark, reads and writes through
NSFileCoordinator (also on macOS); Android ACTION_OPEN_DOCUMENT,
ACTION_CREATE_DOCUMENT and a persisted ACTION_OPEN_DOCUMENT_TREE folder,
read and written through the storage framework. The Android request in issue 892.

miniz is now built on every platform (Android and the iOS app too).
tools/test_saves.c covers the bundle and the sync merge without game data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The sync folder gets its own design pass and branch. This leaves Export
saves, Import saves and Saves folder. The full sync code is in 47cf20b.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@peiikai peiikai changed the title Saves: export, import and a sync folder Saves: export and import Nov 25, 2026
peiikai and others added 3 commits November 25, 2026 20:46
- No limit on games: the bundle and data folder lists grow as needed (was 64,
  dropped silently); the import list scrolls when long.
- A seed import that fails or was cut off leaves no rando/<seed>.import behind
  (the rando tab skips such folders too).
- Slot import in fs.c's commit order: stale working copies cleared, old
  sidecars removed before the save is renamed, sidecar working copies kept once
  the save is in place; folders flushed after renames, _commit on Windows.
- Names Windows reads differently (':', trailing dot or space, device names)
  are left out.
- A seed here and in the file must both have the same id, or neither.
- Android CMake fetches miniz with CMake itself (no bash).
- Android's picked copy is removed after use; backups pruned oldest first
  within one second; desktop export never replaces <name>.zip unasked; the iOS
  export picker can't be swiped away.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Old slot files the bundle lacks are set aside (<file>.import) and removed
  only after the save is replaced, so an old save never loses its sidecars.
- saves_recover (start screen, and each import before its backup) puts
  set-aside files back or removes them and finishes a .flagsx.pending whose
  save was already renamed, as fs.c's mount does.
- A sidecar rename failing after the save is in place no longer reports the
  import as failed; its working copy is finished later.
- Seeds named like Windows devices export everywhere and show as not
  importable on Windows (new string, all languages); the rando tab no longer
  makes such names.
- The partly read list is freed when the manifest can't be read; the launcher's
  seed list skips .import folders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A game started without the start screen (--play, --load-save, a ready
--game-files) mounted a slot before saves_recover ran: the old save's
set-aside sidecars were lost. fs.c's mount now runs saves_finish_dir
before it drops working copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant