support ~ in rootDir as home directory

This commit is contained in:
André Roth
2024-08-02 17:48:57 +02:00
parent f7f220aa18
commit 32a3943821
4 changed files with 11 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
)
// ConfigStructure is structure of main configuration
@@ -209,3 +210,8 @@ func SaveConfig(filename string, config *ConfigStructure) error {
_, err = f.Write(encoded)
return err
}
// GetRootDir returns the RootDir with expanded ~ as home directory
func (conf *ConfigStructure) GetRootDir() string {
return strings.Replace(conf.RootDir, "~", os.Getenv("HOME"), 1)
}