2018-02-05 16:05:59 -05:00
|
|
|
package homedir // import "github.com/docker/docker/pkg/homedir"
|
2015-02-06 13:18:49 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2015-02-06 17:17:34 -05:00
|
|
|
// Key returns the env var name for the user's home dir based on
|
|
|
|
// the platform being run on
|
|
|
|
func Key() string {
|
2017-07-10 09:10:43 -04:00
|
|
|
return "USERPROFILE"
|
2015-02-06 17:17:34 -05:00
|
|
|
}
|
|
|
|
|
2015-02-06 13:18:49 -05:00
|
|
|
// Get returns the home directory of the current user with the help of
|
|
|
|
// environment variables depending on the target operating system.
|
|
|
|
// Returned path should be used with "path/filepath" to form new paths.
|
|
|
|
func Get() string {
|
2017-07-10 09:10:43 -04:00
|
|
|
return os.Getenv(Key())
|
2015-02-06 13:18:49 -05:00
|
|
|
}
|
2015-02-19 01:53:04 -05:00
|
|
|
|
|
|
|
// GetShortcutString returns the string that is shortcut to user's home directory
|
|
|
|
// in the native shell of the platform running on.
|
|
|
|
func GetShortcutString() string {
|
2017-07-10 09:10:43 -04:00
|
|
|
return "%USERPROFILE%" // be careful while using in format functions
|
2015-02-19 01:53:04 -05:00
|
|
|
}
|