{"draft":null,"from":16,"to":17,"files":[{"path":"client/src/state-dir.ts","added":32,"removed":0,"diff":"--- /dev/null\n+++ b/client/src/state-dir.ts\n@@ -0,0 +1,32 @@\n+// Where abso keeps its state (the rename from avcs). A new folder keeps it in .abso/ and the user's in ~/.abso/.\n+// Folders and machines from before keep working on .avcs/ and ~/.avcs/, untouched: a folder is never half-moved,\n+// so an older client or installed mod still finds it. A later `abso migrate` moves a folder once its mods are updated.\n+// No imports from the rest of the client, so any module can use this.\n+\n+import { existsSync } from \"node:fs\";\n+import { join } from \"node:path\";\n+\n+export const STATE_DIR = \".abso\";\n+export const OLD_STATE_DIR = \".avcs\";\n+const STATE_DIRS = [STATE_DIR, OLD_STATE_DIR] as const;\n+\n+/** A folder's state folder: whichever has a config.json (.abso first), else whichever exists, else .abso for a folder not made yet. */\n+export function stateDir(root: string): string {\n+\tfor (const name of STATE_DIRS) if (existsSync(join(root, name, \"config.json\"))) return join(root, name);\n+\tfor (const name of STATE_DIRS) if (existsSync(join(root, name))) return join(root, name);\n+\treturn join(root, STATE_DIR);\n+}\n+\n+/** A file under the user's home to read: ~/.abso/<parts>, else the old ~/.avcs/<parts> when only that exists, else the new place. */\n+export function homeFile(home: string, ...parts: string[]): string {\n+\tfor (const name of STATE_DIRS) {\n+\t\tconst path = join(home, name, ...parts);\n+\t\tif (existsSync(path)) return path;\n+\t}\n+\treturn join(home, STATE_DIR, ...parts);\n+}\n+\n+/** Where to write a file under the user's home: always the new place. The old file is left as it is, for older clients and mods. */\n+export function homeWritePath(home: string, ...parts: string[]): string {\n+\treturn join(home, STATE_DIR, ...parts);\n+}"}],"unmatched":[]}