diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-06-21 19:06:17 -0700 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2017-06-21 19:06:17 -0700 |
commit | 42f28ab8e374137fe3f5d25424489d879d4724f8 (patch) | |
tree | 20353f2446b506d32e6d353b72a57bf48f070389 /vendor/github.com/minio/go-homedir/homedir.go | |
parent | 6b39c308d882a0aeac533f8ab1d90b48a2ae4b5a (diff) | |
download | chat-42f28ab8e374137fe3f5d25424489d879d4724f8.tar.gz chat-42f28ab8e374137fe3f5d25424489d879d4724f8.tar.bz2 chat-42f28ab8e374137fe3f5d25424489d879d4724f8.zip |
Updating server dependancies (#6712)
Diffstat (limited to 'vendor/github.com/minio/go-homedir/homedir.go')
-rw-r--r-- | vendor/github.com/minio/go-homedir/homedir.go | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/vendor/github.com/minio/go-homedir/homedir.go b/vendor/github.com/minio/go-homedir/homedir.go deleted file mode 100644 index 092373801..000000000 --- a/vendor/github.com/minio/go-homedir/homedir.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2016 (C) Mitchell Hashimoto -// Distributed under the MIT License. - -// Package homedir implements a portable function to determine current user's homedir. -package homedir - -import ( - "errors" - "path/filepath" - "sync" -) - -// DisableCache will disable caching of the home directory. Caching is enabled -// by default. -var DisableCache bool - -var homedirCache string -var cacheLock sync.Mutex - -// Dir returns the home directory for the executing user. -// -// This uses an OS-specific method for discovering the home directory. -// An error is returned if a home directory cannot be detected. -func Dir() (string, error) { - cacheLock.Lock() - defer cacheLock.Unlock() - - // Return cached homedir if available. - if !DisableCache { - if homedirCache != "" { - return homedirCache, nil - } - } - - // Determine OS speific current homedir. - result, err := dir() - if err != nil { - return "", err - } - - // Cache for future lookups. - homedirCache = result - return result, nil -} - -// Expand expands the path to include the home directory if the path -// is prefixed with `~`. If it isn't prefixed with `~`, the path is -// returned as-is. -func Expand(path string) (string, error) { - if len(path) == 0 { - return path, nil - } - - if path[0] != '~' { - return path, nil - } - - if len(path) > 1 && path[1] != '/' && path[1] != '\\' { - return "", errors.New("cannot expand user-specific home dir") - } - - dir, err := Dir() - if err != nil { - return "", err - } - - return filepath.Join(dir, path[1:]), nil -} |