summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/adrg/xdg/internal/pathutil/pathutil_plan9.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/adrg/xdg/internal/pathutil/pathutil_plan9.go')
-rw-r--r--vendor/github.com/adrg/xdg/internal/pathutil/pathutil_plan9.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/vendor/github.com/adrg/xdg/internal/pathutil/pathutil_plan9.go b/vendor/github.com/adrg/xdg/internal/pathutil/pathutil_plan9.go
new file mode 100644
index 000000000..8ee4e8d2f
--- /dev/null
+++ b/vendor/github.com/adrg/xdg/internal/pathutil/pathutil_plan9.go
@@ -0,0 +1,29 @@
+package pathutil
+
+import (
+ "os"
+ "path/filepath"
+ "strings"
+)
+
+// Exists returns true if the specified path exists.
+func Exists(path string) bool {
+ _, err := os.Stat(path)
+ return err == nil || os.IsExist(err)
+}
+
+// ExpandHome substitutes `~` and `$home` at the start of the specified
+// `path` using the provided `home` location.
+func ExpandHome(path, home string) string {
+ if path == "" || home == "" {
+ return path
+ }
+ if path[0] == '~' {
+ return filepath.Join(home, path[1:])
+ }
+ if strings.HasPrefix(path, "$home") {
+ return filepath.Join(home, path[5:])
+ }
+
+ return path
+}