Repository navigation
Conversation
5 of 12 tasks
v0lumehi
force-pushed
the
mac-data-folder
branch
4 times, most recently
from
October 27, 2026 20:26
1f9feb8 to
d2180b9
Compare
Contributor
Author
|
Two additions, after the discussion in #388:
This makes three shapes:
What else changed in the launcher:
|
1 task done
v0lumehi
force-pushed
the
mac-data-folder
branch
from
October 28, 2026 01:58
36c0f62 to
bc0be64
Compare
This was referenced Oct 28, 2026
Merged
v0lumehi
force-pushed
the
mac-data-folder
branch
from
October 29, 2026 18:47
bc0be64 to
37f406a
Compare
MIsaacM
added a commit
to MIsaacM/nxnative-lab
that referenced
this pull request
Oct 30, 2026
…s#555, seedds#476) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs seedds#388. A front end that keeps each game in its own folder (varyform's <title ID>_build/run) could not make the Mac app keep its save, pipeline cache and log there; they were always in ~/Library. A dataFolder string in the app's preferences domain (read with CFPreferences, like the launcher.<VAR> choices) names the game's own folder, relative to the folder the .app is in (so a moved library keeps working) or absolute. With it, save/, save.work/, temp/, the player's env.txt, pso_user.tsv, pso_archive/ and the log (log/<title ID>.log and .prev.log) live there; it is DM_ROOT and the working folder. DM_SAVE, DM_TEMP, DM_ROOT and DM_PSO_USER set in the environment or an env.txt still win, each for its own path (DM_SAVE alone moves only the save). Order: key, then <data>/env.txt, then the bundle's. First start with the key and no save/ yet: the old save (and save_device/) and pso_user.tsv are copied, never moved, via a .copying sibling renamed into place, and both paths are logged. A folder that cannot be made or written prints a [RED] line with the path and the start keeps ~/Library. No layout rule: the key is the opt-in. Checked: test_nsp_mac_app test_data_folder (key unset, relative, absolute, env.txt order, DM_SAVE/DM_TEMP/DM_ROOT/DM_PSO_USER precedence, one-time copy, read-only and uncreatable folders, non-string value); dm/tools/tests (only test_regress.test_routes fails, as on upstream/main); test_docs; lint ratchet 0 new; host builds.
…p's folder The log is opened after the env files are read, so DM_LOG_DIR can come from the launch environment, the player's env.txt or the bundle's; what the launcher prints before is kept in a temporary file and copied into the log first. A relative DM_SAVE or DM_LOG_DIR is resolved against the folder the .app is in, like a relative dataFolder. An unusable DM_LOG_DIR is a [RED] line and ~/Library/Logs/nxnative.
… host starts The host makes only the last level before it clones the save and mounts the save read-only when that fails, so a relative DM_SAVE in a library without save/ lost every save. An unmakeable DM_SAVE is a [RED] line; the player's choice stays.
v0lumehi
force-pushed
the
mac-data-folder
branch
from
October 31, 2026 03:53
37f406a to
aade932
Compare
lucaszhongsj
pushed a commit
to lucaszhongsj/nxnative
that referenced
this pull request
Nov 19, 2026
Upstream-Status: pending (seedds#460 is the upstream design) Reason: Store saves and logs alongside the game library folder while falling back to Library on non-APFS volumes Issue: LNPANDY/NX2Apple#123
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Refs #388. A front end that keeps each game in its own folder (varyform's
<title ID>_build/run) could not have the Mac app keep its data there: the save, the pipeline cache and the log were always in~/Library. This PR adds that, as agreed in #388.A
dataFolderstring in the app's preferences domain (read with CFPreferences, like thelauncher.<VAR>saved choices) names the game's own folder:.appis in, so a library that's renamed or moved keeps working. An absolute path works too.save/,save.work/,temp/, the player'senv.txt,pso_user.tsv,pso_archive/and the log (log/<title ID>.log,.prev.log). The folder isDM_ROOTand the working folder.<data folder>/env.txt, then the bundle'sdm/env.txt. ADM_SAVE,DM_TEMP,DM_ROOTorDM_PSO_USERset in the environment or anenv.txtstill wins, each for its own path.DM_SAVEalone stays the lean option: only the save moves.save/yet, the oldsave/(andsave_device/, which the host mounts beside it) andpso_user.tsvare copied, never moved, and the log names both paths. The copy goes to a.copyingsibling that is renamed into place, so an interrupted copy leaves no half save and the next start tries again. If the copy fails, that start keeps the old save and prints a[RED]line.access()says yes on a read-only volume or where privacy checks refuse the open. It prints[RED] launcher: data folder <path> (dataFolder <key>) cannot be made or written (<reason>), and that start uses~/Libraryas before.Save and log only:
DM_LOG_DIRand relative pathsA front end that keeps only a game's save and log beside the app (everything else in
~/Library) could say "everything" (dataFolder) or "only the save" (DM_SAVE), not both. Two additions:DM_LOG_DIRis the folder the launcher writes<title ID>.logand<title ID>.prev.loginto. It is read likeDM_SAVE(the launch environment, the player'senv.txt, the bundle'sdm/env.txt, the first wins) and beats the data folder'slog/when both are set. One that cannot be made or written is a[RED]line, and the log goes to~/Library/Logs/nxnative.DM_SAVEandDM_LOG_DIRare resolved against the folder the.appis in, as a relativedataFolderis, so a library that moves keeps working. Absolute values are unchanged, and the host gets the absolute path only.env.txtfiles. It now opens it after them. Until then its own lines (the name line, the data folder line, eachenvline) go to an unnamed temporary file, which is copied into the log first, so nothing is lost. If the log cannot be opened, they go back to stderr.DM_SAVE: the host makes only the last level before it clones the save, and mounts it read-only when that fails. One that cannot be made is a[RED] launcher: cannot make the save folderline (no fallback: the player's choice stays).dataFolder; the launcher copies only from~/Library(docs/frontends.md, Data folder).Files:
dm/mac/launcher.c;test_data_folderandtest_log_dir_and_relative_pathsindm/tools/tests/test_nsp_mac_app.py;docs/frontends.md, the paths indocs/development.md(A Mac app) anddocs/settings.md, andDM_LOG_DIRindocs/env_switches.tsv.Checked
test_nsp_mac_app.test_data_folder. It runs the real launcher with a stand-in host, a temporaryHOMEand a throwaway preferences domain, and covers:env.txtorder;DM_SAVE,DM_TEMP,DM_ROOTandDM_PSO_USEReach winning for their own path only;.copyingleft behind, not repeated);.prev.log;test_nsp_mac_app.test_log_dir_and_relative_paths, same setup:DM_LOG_DIRfrom the environment, the player'senv.txt, relative and absolute; the early lines in the log; the rotation to.prev.log; relativeDM_SAVE;DM_LOG_DIRover a data folder'slog/; an unwritable and an uncreatableDM_LOG_DIRfalling back to~/Library/Logswith a[RED]line; aDM_SAVEtwo levels deep in a fresh library made before the host runs (environment andenv.txt) and an unmakeable one's[RED]line; the save-and-log shape withoutdataFolderleavingDM_ROOT,temp/and the pipeline list in~/Library.test_nsp_mac_app44 tests pass (including both new and old data folder tests),test_docsandtest_env_switchespass (11). The wholedm/tools/tests(unittest discovery) ran 375 tests; the failures and errors there are all missing Python modules on this machine (capstone,lz4) intest_nso_match,test_nro_pack,test_size_prefixed_frames,test_split_unreadableand three import errors, none touching the launcher.dm/tools/tests: 400 tests pass, apart fromtest_regress.test_routes, which failed onmaintoo until 3283fee. Rebased onto 3283fee,test_regress,test_docsandtest_nsp_mac_apppass.test_docs: OK.make -C dm/host GAME=01007EF00011E000: builds.pso_archive/fromDM_PSO_USER's folder is read fromnvn_mtl.m, not seen in a run.dm/mac/launcher.c), andregress.pystartsdmhostdirectly, so its runs don't reach it..appreached through a symbolic link resolves a relativedataFolderagainst the app's real location, because the launcher uses the real path of its own executable.Docs
docs/frontends.md(Data folder) anddocs/development.md(A Mac app)