parameterize zrokdir (#976)

This commit is contained in:
Michael Quigley 2025-06-04 16:41:46 -04:00
parent f7d78a7bd9
commit 5308285cbd
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 13 additions and 1 deletions

View File

@ -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()

View File

@ -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) {