1package mox
2
3import (
4 "path/filepath"
5)
6
7// ConfigDirPath returns the path to "f". Either f itself when absolute, or
8// interpreted relative to the directory of the current config file.
9func ConfigDirPath(f string) string {
10 return configDirPath(ConfigStaticPath, f)
11}
12
13// DataDirPath returns to the path to "f". Either f itself when absolute, or
14// interpreted relative to the data directory from the currently active
15// configuration.
16func DataDirPath(f string) string {
17 return dataDirPath(ConfigStaticPath, Conf.Static.DataDir, f)
18}
19
20// return f interpreted relative to the directory of the config dir. f is returned
21// unchanged when absolute.
22func configDirPath(configFile, f string) string {
23 if filepath.IsAbs(f) {
24 return f
25 }
26 return filepath.Join(filepath.Dir(configFile), f)
27}
28
29// return f interpreted relative to the data directory that is interpreted relative
30// to the directory of the config dir. f is returned unchanged when absolute.
31func dataDirPath(configFile, dataDir, f string) string {
32 if filepath.IsAbs(f) {
33 return f
34 }
35 return filepath.Join(configDirPath(configFile, dataDir), f)
36}
37