Files
strata/strata_control/paths.py
T
Niko1221 236cca71bb host: no /usr/bin/tar, /usr/bin/env or HOME/.local/state on Windows
- engine-install.mjs extracts with tarBinary(): System32\tar.exe on Windows (bsdtar reads .zip and .tar.*), /usr/bin/tar
  elsewhere.
- util.mjs which() asks System32\where.exe on Windows (first match), /usr/bin/env which elsewhere.
- the tuning and Time-skip state default to %LOCALAPPDATA%\Strata\tuning and \time-skip on Windows
  (apps/host/server/platform-paths.mjs; POSIX keeps $XDG_STATE_HOME/strata). The Python side resolves the same folders
  (strata_control/paths.py, used by the runtime directory and the tune and timeskip commands), so the host and the
  terminal agree.
- tests: apps/host/tests/platform-paths.test.mjs (both platforms from either host) and tests/terminal/test_state_paths.py.
2026-10-15 12:31:49 +02:00

22 lines
945 B
Python

"""Per-user state locations, one rule for the terminal and the host.
POSIX keeps $XDG_STATE_HOME (default ~/.local/state) under ``strata/``. Windows has no such place: state goes to
``%LOCALAPPDATA%\\Strata``. The Node host (apps/host/server/platform-paths.mjs) resolves the same folders.
"""
from __future__ import annotations
import os
from pathlib import Path
def state_base(environ=None, *, windows: bool | None = None, home: Path | None = None) -> Path:
"""The folder that holds Strata's per-user state: runtime/, tuning/, time-skip/."""
environ = os.environ if environ is None else environ
windows = os.name == "nt" if windows is None else windows
home = Path.home() if home is None else home
if windows:
local = environ.get("LOCALAPPDATA") or str(home / "AppData" / "Local")
return Path(local) / "Strata"
return Path(environ.get("XDG_STATE_HOME") or str(home / ".local" / "state")) / "strata"