fixed bugs
This commit is contained in:
parent
5635ea474a
commit
a3adc3b91d
@ -15,21 +15,24 @@ func Path(fileExtension string) (string, error) {
|
|||||||
paths := []string{
|
paths := []string{
|
||||||
filepath.Join("/etc/", executableName, configFileName),
|
filepath.Join("/etc/", executableName, configFileName),
|
||||||
filepath.Join("/etc/", configFileName),
|
filepath.Join("/etc/", configFileName),
|
||||||
filepath.Join("etc", configFileName),
|
|
||||||
filepath.Join(userConfigDir, executableName, configFileName),
|
filepath.Join(userConfigDir, executableName, configFileName),
|
||||||
filepath.Join(userConfigDir, configFileName),
|
filepath.Join(userConfigDir, configFileName),
|
||||||
filepath.Clean(configFileName),
|
filepath.Clean(configFileName),
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, path := range paths {
|
for _, path := range paths {
|
||||||
if _, err := os.Stat(path); err != nil {
|
if _, err := os.Stat(path); err == nil {
|
||||||
return path, nil
|
return path, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, path := range paths {
|
for _, path := range paths {
|
||||||
|
if err := os.MkdirAll(filepath.Dir(path), 0744); err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
f, err := os.Create(path)
|
f, err := os.Create(path)
|
||||||
if err != nil {
|
if err == nil {
|
||||||
f.Close()
|
f.Close()
|
||||||
return path, nil
|
return path, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user