From 5308285cbd4bc5c76b7e6f2f3de12f21b70661db Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Wed, 4 Jun 2025 16:41:46 -0400 Subject: [PATCH] parameterize zrokdir (#976) --- environment/api.go | 6 ++++++ environment/env_v0_4/dirs.go | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/environment/api.go b/environment/api.go index 54addb7e..9bc8d263 100644 --- a/environment/api.go +++ b/environment/api.go @@ -7,6 +7,12 @@ import ( "github.com/pkg/errors" ) +// SetRootDirName allows setting a custom name for the root directory. +// This should be called before any other environment operations. +func SetRootDirName(name string) { + env_v0_4.SetRootDirName(name) +} + func LoadRoot() (env_core.Root, error) { if assert, err := env_v0_4.Assert(); assert && err == nil { return env_v0_4.Load() diff --git a/environment/env_v0_4/dirs.go b/environment/env_v0_4/dirs.go index baf23be8..d0b9b65e 100644 --- a/environment/env_v0_4/dirs.go +++ b/environment/env_v0_4/dirs.go @@ -6,12 +6,18 @@ import ( "path/filepath" ) +var rootDirName = ".zrok" + +func SetRootDirName(name string) { + rootDirName = ".zrok" +} + func rootDir() (string, error) { home, err := os.UserHomeDir() if err != nil { return "", err } - return filepath.Join(home, ".zrok"), nil + return filepath.Join(home, rootDirName), nil } func metadataFile() (string, error) {