mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
file.go use filepath.Dir()
This commit is contained in:
parent
948e7cc9d0
commit
4e44c9d5f7
@ -3,6 +3,7 @@ package config
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
@ -81,7 +82,7 @@ func Write() (path string, err error) {
|
||||
return path, err
|
||||
}
|
||||
|
||||
cfgdir := basedir(path)
|
||||
cfgdir := filepath.Dir(path)
|
||||
// create config dir if not exist
|
||||
if _, err := os.Stat(cfgdir); err != nil {
|
||||
err = os.MkdirAll(cfgdir, 0755)
|
||||
@ -141,8 +142,3 @@ func xdgSupport() bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func basedir(path string) string {
|
||||
parts := strings.Split(path, "/")
|
||||
return strings.Join((parts[0 : len(parts)-1]), "/")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user