Update deps
This commit is contained in:
20
vendor/github.com/adrg/xdg/internal/pathutil/pathutil_unix.go
generated
vendored
20
vendor/github.com/adrg/xdg/internal/pathutil/pathutil_unix.go
generated
vendored
@@ -1,23 +1,33 @@
|
||||
//go:build aix || darwin || dragonfly || freebsd || (js && wasm) || nacl || linux || netbsd || openbsd || solaris
|
||||
// +build aix darwin dragonfly freebsd js,wasm nacl linux netbsd openbsd solaris
|
||||
|
||||
package pathutil
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// UserHomeDir returns the home directory of the current user.
|
||||
func UserHomeDir() string {
|
||||
if home := os.Getenv("HOME"); home != "" {
|
||||
return home
|
||||
}
|
||||
|
||||
return "/"
|
||||
}
|
||||
|
||||
// Exists returns true if the specified path exists.
|
||||
func Exists(path string) bool {
|
||||
_, err := os.Stat(path)
|
||||
return err == nil || os.IsExist(err)
|
||||
return err == nil || errors.Is(err, fs.ErrExist)
|
||||
}
|
||||
|
||||
// ExpandHome substitutes `~` and `$HOME` at the start of the specified
|
||||
// `path` using the provided `home` location.
|
||||
func ExpandHome(path, home string) string {
|
||||
// ExpandHome substitutes `~` and `$HOME` at the start of the specified `path`.
|
||||
func ExpandHome(path string) string {
|
||||
home := UserHomeDir()
|
||||
if path == "" || home == "" {
|
||||
return path
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user