Checkpoint
This commit is contained in:
138 files changed
+1898
-57607
No files matched your search
@@ -0,0 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/kyoh86/xdg"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
configFileBase = "harmon.conf"
|
||||
configFileBaseAlt = "harmon.cfg"
|
||||
)
|
||||
|
||||
func findConfigFile() string {
|
||||
var name string
|
||||
for _, dir := range append(xdg.AllConfigDirs(), ".") {
|
||||
// Base
|
||||
name = filepath.Join(dir, configFileBase)
|
||||
logrus.WithField("name", name).Trace("auto detecting configuration file")
|
||||
if i, err := os.Stat(name); err == nil && !i.IsDir() {
|
||||
logrus.WithField("name", name).Trace("found configuration file")
|
||||
return name
|
||||
}
|
||||
|
||||
// Alt
|
||||
name = filepath.Join(dir, configFileBaseAlt)
|
||||
logrus.WithField("name", name).Trace("auto detecting configuration file")
|
||||
if i, err := os.Stat(name); err == nil && !i.IsDir() {
|
||||
logrus.WithField("name", name).Trace("found configuration file")
|
||||
return name
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
Reference in new issue
Block a user