Upstream twpayne/chezmoi state of the touched files before c6778d6771
This commit is contained in:
commit
ee28f348f2
5 files changed
+4195
No files matched your search
@@ -0,0 +1,46 @@
|
||||
//go:build unix
|
||||
|
||||
package chezmoi
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var devNullAbsPath = NewAbsPath("/dev/null")
|
||||
|
||||
// NewAbsPathFromExtPath returns a new AbsPath by converting extPath to use
|
||||
// slashes, performing tilde expansion, and making the path absolute.
|
||||
func NewAbsPathFromExtPath(extPath string, homeDirAbsPath AbsPath) (AbsPath, error) {
|
||||
extPath = filepath.Clean(extPath)
|
||||
switch {
|
||||
case extPath == "~":
|
||||
return homeDirAbsPath, nil
|
||||
case strings.HasPrefix(extPath, "~/"):
|
||||
return homeDirAbsPath.JoinString(extPath[2:]), nil
|
||||
case filepath.IsAbs(extPath):
|
||||
return NewAbsPath(extPath), nil
|
||||
default:
|
||||
absPath, err := filepath.Abs(extPath)
|
||||
if err != nil {
|
||||
return EmptyAbsPath, err
|
||||
}
|
||||
return NewAbsPath(absPath), nil
|
||||
}
|
||||
}
|
||||
|
||||
// NormalizePath returns path normalized. On non-Windows systems, normalized
|
||||
// paths are absolute paths.
|
||||
func NormalizePath(path string) (AbsPath, error) {
|
||||
absPath, err := filepath.Abs(path)
|
||||
if err != nil {
|
||||
return EmptyAbsPath, err
|
||||
}
|
||||
return NewAbsPath(absPath), nil
|
||||
}
|
||||
|
||||
// normalizeLinkname returns linkname normalized. On non-Windows systems, it
|
||||
// returns linkname unchanged.
|
||||
func normalizeLinkname(linkname string) string {
|
||||
return linkname
|
||||
}
|
||||
Reference in new issue
Block a user