diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-09-25 13:46:21 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-09-25 13:51:54 +0900 |
| commit | ae2df2c450dd655b93a950124b6ab16e2b4d967b (patch) | |
| tree | 849ab40049228e17891351d97097f8c9d0e18c10 /internal/app/paths.go | |
| parent | 6e3f34f2ecfe0f3cd024a6e73bf6560080feac53 (diff) | |
internal: remove sys package
This package is replaced by container/stub. Remove and replace it with unexported implementation for the upcoming test suite rewrite.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app/paths.go')
| -rw-r--r-- | internal/app/paths.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/app/paths.go b/internal/app/paths.go new file mode 100644 index 00000000..3316a22e --- /dev/null +++ b/internal/app/paths.go @@ -0,0 +1,36 @@ +package app + +import ( + "strconv" + + "hakurei.app/container" + "hakurei.app/hst" +) + +// CopyPaths populates a [hst.Paths] struct. +func CopyPaths(v *hst.Paths, userid int) { copyPaths(direct{}, v, userid) } + +// copyPaths populates a [hst.Paths] struct. +func copyPaths(k syscallDispatcher, v *hst.Paths, userid int) { + const xdgRuntimeDir = "XDG_RUNTIME_DIR" + + if tempDir, err := container.NewAbs(k.tempdir()); err != nil { + k.fatalf("invalid TMPDIR: %v", err) + } else { + v.TempDir = tempDir + } + + v.SharePath = v.TempDir.Append("hakurei." + strconv.Itoa(userid)) + k.verbosef("process share directory at %q", v.SharePath) + + r, _ := k.lookupEnv(xdgRuntimeDir) + if a, err := container.NewAbs(r); err != nil { + // fall back to path in share since hakurei has no hard XDG dependency + v.RunDirPath = v.SharePath.Append("run") + v.RuntimePath = v.RunDirPath.Append("compat") + } else { + v.RuntimePath = a + v.RunDirPath = v.RuntimePath.Append("hakurei") + } + k.verbosef("runtime directory at %q", v.RunDirPath) +} |
