okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221host: no /usr/bin/tar, /usr/bin/env or HOME/.local/state on Windows236cca71b

main
945 B21 linesraw
1"""Per-user state locations, one rule for the terminal and the host.
2
3POSIX keeps $XDG_STATE_HOME (default ~/.local/state) under ``strata/``. Windows has no such place: state goes to
4``%LOCALAPPDATA%\\Strata``. The Node host (apps/host/server/platform-paths.mjs) resolves the same folders.
5"""
6
7from __future__ import annotations
8
9import os
10from pathlib import Path
11
12
13def state_base(environ=None, *, windows: bool | None = None, home: Path | None = None) -> Path:
14    """The folder that holds Strata's per-user state: runtime/, tuning/, time-skip/."""
15    environ = os.environ if environ is None else environ
16    windows = os.name == "nt" if windows is None else windows
17    home = Path.home() if home is None else home
18    if windows:
19        local = environ.get("LOCALAPPDATA") or str(home / "AppData" / "Local")
20        return Path(local) / "Strata"
21    return Path(environ.get("XDG_STATE_HOME") or str(home / ".local" / "state")) / "strata"