mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 17:04:39 +03:00
mox!
This commit is contained in:
36
mox-/dir.go
Normal file
36
mox-/dir.go
Normal file
@ -0,0 +1,36 @@
|
||||
package mox
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// ConfigDirPath returns the path to "f". Either f itself when absolute, or
|
||||
// interpreted relative to the directory of the current config file.
|
||||
func ConfigDirPath(f string) string {
|
||||
return configDirPath(ConfigStaticPath, f)
|
||||
}
|
||||
|
||||
// DataDirPath returns to the path to "f". Either f itself when absolute, or
|
||||
// interpreted relative to the data directory from the currently active
|
||||
// configuration.
|
||||
func DataDirPath(f string) string {
|
||||
return dataDirPath(ConfigStaticPath, Conf.Static.DataDir, f)
|
||||
}
|
||||
|
||||
// return f interpreted relative to the directory of the config dir. f is returned
|
||||
// unchanged when absolute.
|
||||
func configDirPath(configFile, f string) string {
|
||||
if filepath.IsAbs(f) {
|
||||
return f
|
||||
}
|
||||
return filepath.Join(filepath.Dir(configFile), f)
|
||||
}
|
||||
|
||||
// return f interpreted relative to the data directory that is interpreted relative
|
||||
// to the directory of the config dir. f is returned unchanged when absolute.
|
||||
func dataDirPath(configFile, dataDir, f string) string {
|
||||
if filepath.IsAbs(f) {
|
||||
return f
|
||||
}
|
||||
return filepath.Join(configDirPath(configFile, dataDir), f)
|
||||
}
|
Reference in New Issue
Block a user