+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/vendor/github.com/adrg/xdg/README.md b/vendor/github.com/adrg/xdg/README.md
new file mode 100644
index 00000000000..b55403c27c0
--- /dev/null
+++ b/vendor/github.com/adrg/xdg/README.md
@@ -0,0 +1,280 @@
+
+
+

+
+
+
+Go implementation of the XDG Base Directory Specification and XDG user directories.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Provides an implementation of the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html).
+The specification defines a set of standard paths for storing application files,
+including data and configuration files. For portability and flexibility reasons,
+applications should use the XDG defined locations instead of hardcoding paths.
+The package also includes the locations of well known [user directories](https://wiki.archlinux.org/index.php/XDG_user_directories), as well as
+other common directories such as fonts and applications.
+
+The current implementation supports **most flavors of Unix**, **Windows**, **macOS** and **Plan 9**.
+On Windows, where XDG environment variables are not usually set, the package uses [Known Folders](https://docs.microsoft.com/en-us/windows/win32/shell/known-folders)
+as defaults. Therefore, appropriate locations are used for common [folders](https://docs.microsoft.com/en-us/windows/win32/shell/knownfolderid) which may have been redirected.
+
+See usage [examples](#usage) below. Full documentation can be found at https://pkg.go.dev/github.com/adrg/xdg.
+
+## Installation
+ go get github.com/adrg/xdg
+
+## Default locations
+
+The package defines sensible defaults for XDG variables which are empty or not
+present in the environment.
+
+- On Unix-like operating systems, XDG environment variables are tipically defined.
+Appropriate default locations are used for the environment variables which are not set.
+- On Windows, XDG environment variables are usually not set. If that is the case,
+the package relies on the appropriate [Known Folders](https://docs.microsoft.com/en-us/windows/win32/shell/knownfolderid).
+Sensible fallback locations are used for the folders which are not set.
+
+### XDG Base Directory
+
+
+ Unix-like operating systems
+
+
+|
| ![]()
Unix
| ![]()
macOS
| ![]()
Plan 9
|
+| :------------------------------------------------------------: | :-----------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------: |
+| XDG_DATA_HOME | ~/.local/share | ~/Library/Application Support | $home/lib |
+| XDG_DATA_DIRS | /usr/local/share
/usr/share | /Library/Application Support | /lib |
+| XDG_CONFIG_HOME | ~/.config | ~/Library/Application Support | $home/lib |
+| XDG_CONFIG_DIRS | /etc/xdg | ~/Library/Preferences
/Library/Application Support
/Library/Preferences | /lib |
+| XDG_STATE_HOME | ~/.local/state | ~/Library/Application Support | $home/lib/state |
+| XDG_CACHE_HOME | ~/.cache | ~/Library/Caches | $home/lib/cache |
+| XDG_RUNTIME_DIR | /run/user/UID | ~/Library/Application Support | /tmp |
+
+
+
+
+ Microsoft Windows
+
+
+|
| ![]()
Known Folder(s)
| ![]()
Fallback(s)
|
+| :------------------------------------------------------------: | :---------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------: |
+| XDG_DATA_HOME | LocalAppData | %LOCALAPPDATA% |
+| XDG_DATA_DIRS | RoamingAppData
ProgramData | %APPADATA%
%ProgramData% |
+| XDG_CONFIG_HOME | LocalAppData | %LOCALAPPDATA% |
+| XDG_CONFIG_DIRS | ProgramData
RoamingAppData | %ProgramData%
%APPDATA% |
+| XDG_STATE_HOME | LocalAppData | %LOCALAPPDATA% |
+| XDG_CACHE_HOME | LocalAppData\cache | %LOCALAPPDATA%\cache |
+| XDG_RUNTIME_DIR | LocalAppData | %LOCALAPPDATA% |
+
+
+
+### XDG user directories
+
+
+ Unix-like operating systems
+
+
+|
| ![]()
Unix
| ![]()
macOS
| ![]()
Plan 9
|
+| :--------------------------------------------------------------: | :-------------------------------------------------------------------------: | :---------------------------------------------------------------------------: | :---------------------------------------------------------------------------: |
+| XDG_DESKTOP_DIR | ~/Desktop | ~/Desktop | $home/desktop |
+| XDG_DOWNLOAD_DIR | ~/Downloads | ~/Downloads | $home/downloads |
+| XDG_DOCUMENTS_DIR | ~/Documents | ~/Documents | $home/documents |
+| XDG_MUSIC_DIR | ~/Music | ~/Music | $home/music |
+| XDG_PICTURES_DIR | ~/Pictures | ~/Pictures | $home/pictures |
+| XDG_VIDEOS_DIR | ~/Videos | ~/Movies | $home/videos |
+| XDG_TEMPLATES_DIR | ~/Templates | ~/Templates | $home/templates |
+| XDG_PUBLICSHARE_DIR | ~/Public | ~/Public | $home/public |
+
+
+
+
+ Microsoft Windows
+
+
+|
| ![]()
Known Folder(s)
| ![]()
Fallback(s)
|
+| :--------------------------------------------------------------: | :-----------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------: |
+| XDG_DESKTOP_DIR | Desktop | %USERPROFILE%\Desktop |
+| XDG_DOWNLOAD_DIR | Downloads | %USERPROFILE%\Downloads |
+| XDG_DOCUMENTS_DIR | Documents | %USERPROFILE%\Documents |
+| XDG_MUSIC_DIR | Music | %USERPROFILE%\Music |
+| XDG_PICTURES_DIR | Pictures | %USERPROFILE%\Pictures |
+| XDG_VIDEOS_DIR | Videos | %USERPROFILE%\Videos |
+| XDG_TEMPLATES_DIR | Templates | %APPDATA%\Microsoft\Windows\Templates |
+| XDG_PUBLICSHARE_DIR | Public | %PUBLIC% |
+
+
+
+### Other directories
+
+
+ Unix-like operating systems
+
+
+|
| ![]()
Unix
| ![]()
macOS
| ![]()
Plan 9
|
+| :-----------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------: |
+| Home | $HOME | $HOME | $home |
+| Applications | $XDG_DATA_HOME/applications
~/.local/share/applications
/usr/local/share/applications
/usr/share/applications
$XDG_DATA_DIRS/applications | /Applications | $home/bin
/bin |
+| Fonts | $XDG_DATA_HOME/fonts
~/.fonts
~/.local/share/fonts
/usr/local/share/fonts
/usr/share/fonts
$XDG_DATA_DIRS/fonts | ~/Library/Fonts
/Library/Fonts
/System/Library/Fonts
/Network/Library/Fonts | $home/lib/font
/lib/font |
+
+
+
+
+ Microsoft Windows
+
+
+|
| ![]()
Known Folder(s)
| ![]()
Fallback(s)
|
+| :-----------------------------------------------------------: | :--------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------: |
+| Home | Profile | %USERPROFILE% |
+| Applications | Programs
CommonPrograms | %APPDATA%\Microsoft\Windows\Start Menu\Programs
%ProgramData%\Microsoft\Windows\Start Menu\Programs |
+| Fonts | Fonts
- | %SystemRoot%\Fonts
%LOCALAPPDATA%\Microsoft\Windows\Fonts |
+
+
+
+## Usage
+
+#### XDG Base Directory
+
+```go
+package main
+
+import (
+ "log"
+
+ "github.com/adrg/xdg"
+)
+
+func main() {
+ // XDG Base Directory paths.
+ log.Println("Home data directory:", xdg.DataHome)
+ log.Println("Data directories:", xdg.DataDirs)
+ log.Println("Home config directory:", xdg.ConfigHome)
+ log.Println("Config directories:", xdg.ConfigDirs)
+ log.Println("Home state directory:", xdg.StateHome)
+ log.Println("Cache directory:", xdg.CacheHome)
+ log.Println("Runtime directory:", xdg.RuntimeDir)
+
+ // Other common directories.
+ log.Println("Home directory:", xdg.Home)
+ log.Println("Application directories:", xdg.ApplicationDirs)
+ log.Println("Font directories:", xdg.FontDirs)
+
+ // Obtain a suitable location for application config files.
+ // ConfigFile takes one parameter which must contain the name of the file,
+ // but it can also contain a set of parent directories. If the directories
+ // don't exist, they will be created relative to the base config directory.
+ configFilePath, err := xdg.ConfigFile("appname/config.yaml")
+ if err != nil {
+ log.Fatal(err)
+ }
+ log.Println("Save the config file at:", configFilePath)
+
+ // For other types of application files use:
+ // xdg.DataFile()
+ // xdg.StateFile()
+ // xdg.CacheFile()
+ // xdg.RuntimeFile()
+
+ // Finding application config files.
+ // SearchConfigFile takes one parameter which must contain the name of
+ // the file, but it can also contain a set of parent directories relative
+ // to the config search paths (xdg.ConfigHome and xdg.ConfigDirs).
+ configFilePath, err = xdg.SearchConfigFile("appname/config.yaml")
+ if err != nil {
+ log.Fatal(err)
+ }
+ log.Println("Config file was found at:", configFilePath)
+
+ // For other types of application files use:
+ // xdg.SearchDataFile()
+ // xdg.SearchStateFile()
+ // xdg.SearchCacheFile()
+ // xdg.SearchRuntimeFile()
+}
+```
+
+#### XDG user directories
+
+```go
+package main
+
+import (
+ "log"
+
+ "github.com/adrg/xdg"
+)
+
+func main() {
+ // XDG user directories.
+ log.Println("Desktop directory:", xdg.UserDirs.Desktop)
+ log.Println("Download directory:", xdg.UserDirs.Download)
+ log.Println("Documents directory:", xdg.UserDirs.Documents)
+ log.Println("Music directory:", xdg.UserDirs.Music)
+ log.Println("Pictures directory:", xdg.UserDirs.Pictures)
+ log.Println("Videos directory:", xdg.UserDirs.Videos)
+ log.Println("Templates directory:", xdg.UserDirs.Templates)
+ log.Println("Public directory:", xdg.UserDirs.PublicShare)
+}
+```
+
+## Stargazers over time
+
+[](https://starchart.cc/adrg/xdg)
+
+## Contributing
+
+Contributions in the form of pull requests, issues or just general feedback,
+are always welcome.
+See [CONTRIBUTING.MD](CONTRIBUTING.md).
+
+**Contributors**:
+[adrg](https://github.com/adrg),
+[wichert](https://github.com/wichert),
+[bouncepaw](https://github.com/bouncepaw),
+[gabriel-vasile](https://github.com/gabriel-vasile),
+[KalleDK](https://github.com/KalleDK),
+[nvkv](https://github.com/nvkv),
+[djdv](https://github.com/djdv).
+
+## References
+
+For more information see:
+* [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
+* [XDG user directories](https://wiki.archlinux.org/index.php/XDG_user_directories)
+* [Windows Known Folders](https://docs.microsoft.com/en-us/windows/win32/shell/knownfolderid)
+
+## License
+
+Copyright (c) 2014 Adrian-George Bostan.
+
+This project is licensed under the [MIT license](https://opensource.org/licenses/MIT).
+See [LICENSE](LICENSE) for more details.
diff --git a/vendor/github.com/adrg/xdg/base_dirs.go b/vendor/github.com/adrg/xdg/base_dirs.go
new file mode 100644
index 00000000000..a8a3fd55cca
--- /dev/null
+++ b/vendor/github.com/adrg/xdg/base_dirs.go
@@ -0,0 +1,68 @@
+package xdg
+
+import "github.com/adrg/xdg/internal/pathutil"
+
+// XDG Base Directory environment variables.
+const (
+ envDataHome = "XDG_DATA_HOME"
+ envDataDirs = "XDG_DATA_DIRS"
+ envConfigHome = "XDG_CONFIG_HOME"
+ envConfigDirs = "XDG_CONFIG_DIRS"
+ envStateHome = "XDG_STATE_HOME"
+ envCacheHome = "XDG_CACHE_HOME"
+ envRuntimeDir = "XDG_RUNTIME_DIR"
+)
+
+type baseDirectories struct {
+ dataHome string
+ data []string
+ configHome string
+ config []string
+ stateHome string
+ cacheHome string
+ runtime string
+
+ // Non-standard directories.
+ fonts []string
+ applications []string
+}
+
+func (bd baseDirectories) dataFile(relPath string) (string, error) {
+ return pathutil.Create(relPath, append([]string{bd.dataHome}, bd.data...))
+}
+
+func (bd baseDirectories) configFile(relPath string) (string, error) {
+ return pathutil.Create(relPath, append([]string{bd.configHome}, bd.config...))
+}
+
+func (bd baseDirectories) stateFile(relPath string) (string, error) {
+ return pathutil.Create(relPath, []string{bd.stateHome})
+}
+
+func (bd baseDirectories) cacheFile(relPath string) (string, error) {
+ return pathutil.Create(relPath, []string{bd.cacheHome})
+}
+
+func (bd baseDirectories) runtimeFile(relPath string) (string, error) {
+ return pathutil.Create(relPath, []string{bd.runtime})
+}
+
+func (bd baseDirectories) searchDataFile(relPath string) (string, error) {
+ return pathutil.Search(relPath, append([]string{bd.dataHome}, bd.data...))
+}
+
+func (bd baseDirectories) searchConfigFile(relPath string) (string, error) {
+ return pathutil.Search(relPath, append([]string{bd.configHome}, bd.config...))
+}
+
+func (bd baseDirectories) searchStateFile(relPath string) (string, error) {
+ return pathutil.Search(relPath, []string{bd.stateHome})
+}
+
+func (bd baseDirectories) searchCacheFile(relPath string) (string, error) {
+ return pathutil.Search(relPath, []string{bd.cacheHome})
+}
+
+func (bd baseDirectories) searchRuntimeFile(relPath string) (string, error) {
+ return pathutil.Search(relPath, []string{bd.runtime})
+}
diff --git a/vendor/github.com/adrg/xdg/codecov.yml b/vendor/github.com/adrg/xdg/codecov.yml
new file mode 100644
index 00000000000..54ee338fd70
--- /dev/null
+++ b/vendor/github.com/adrg/xdg/codecov.yml
@@ -0,0 +1,11 @@
+coverage:
+ status:
+ project:
+ default:
+ target: 90%
+ threshold: 1%
+ patch:
+ default:
+ target: 100%
+ignore:
+ - "paths_plan9.go"
diff --git a/vendor/github.com/adrg/xdg/doc.go b/vendor/github.com/adrg/xdg/doc.go
new file mode 100644
index 00000000000..7747b183e44
--- /dev/null
+++ b/vendor/github.com/adrg/xdg/doc.go
@@ -0,0 +1,99 @@
+/*
+Package xdg provides an implementation of the XDG Base Directory Specification.
+The specification defines a set of standard paths for storing application files
+including data and configuration files. For portability and flexibility reasons,
+applications should use the XDG defined locations instead of hardcoding paths.
+The package also includes the locations of well known user directories.
+
+The current implementation supports most flavors of Unix, Windows, Mac OS and Plan 9.
+
+ For more information regarding the XDG Base Directory Specification see:
+ https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
+
+ For more information regarding the XDG user directories see:
+ https://wiki.archlinux.org/index.php/XDG_user_directories
+
+ For more information regarding the Windows Known Folders see:
+ https://docs.microsoft.com/en-us/windows/win32/shell/known-folders
+
+Usage
+
+XDG Base Directory
+ package main
+
+ import (
+ "log"
+
+ "github.com/adrg/xdg"
+ )
+
+ func main() {
+ // XDG Base Directory paths.
+ log.Println("Home data directory:", xdg.DataHome)
+ log.Println("Data directories:", xdg.DataDirs)
+ log.Println("Home config directory:", xdg.ConfigHome)
+ log.Println("Config directories:", xdg.ConfigDirs)
+ log.Println("Home state directory:", xdg.StateHome)
+ log.Println("Cache directory:", xdg.CacheHome)
+ log.Println("Runtime directory:", xdg.RuntimeDir)
+
+ // Other common directories.
+ log.Println("Home directory:", xdg.Home)
+ log.Println("Application directories:", xdg.ApplicationDirs)
+ log.Println("Font directories:", xdg.FontDirs)
+
+ // Obtain a suitable location for application config files.
+ // ConfigFile takes one parameter which must contain the name of the file,
+ // but it can also contain a set of parent directories. If the directories
+ // don't exist, they will be created relative to the base config directory.
+ configFilePath, err := xdg.ConfigFile("appname/config.yaml")
+ if err != nil {
+ log.Fatal(err)
+ }
+ log.Println("Save the config file at:", configFilePath)
+
+ // For other types of application files use:
+ // xdg.DataFile()
+ // xdg.StateFile()
+ // xdg.CacheFile()
+ // xdg.RuntimeFile()
+
+ // Finding application config files.
+ // SearchConfigFile takes one parameter which must contain the name of
+ // the file, but it can also contain a set of parent directories relative
+ // to the config search paths (xdg.ConfigHome and xdg.ConfigDirs).
+ configFilePath, err = xdg.SearchConfigFile("appname/config.yaml")
+ if err != nil {
+ log.Fatal(err)
+ }
+ log.Println("Config file was found at:", configFilePath)
+
+ // For other types of application files use:
+ // xdg.SearchDataFile()
+ // xdg.SearchStateFile()
+ // xdg.SearchCacheFile()
+ // xdg.SearchRuntimeFile()
+ }
+
+XDG user directories
+ package main
+
+ import (
+ "log"
+
+ "github.com/adrg/xdg"
+ )
+
+ func main() {
+ // XDG user directories.
+ log.Println("Desktop directory:", xdg.UserDirs.Desktop)
+ log.Println("Download directory:", xdg.UserDirs.Download)
+ log.Println("Documents directory:", xdg.UserDirs.Documents)
+ log.Println("Music directory:", xdg.UserDirs.Music)
+ log.Println("Pictures directory:", xdg.UserDirs.Pictures)
+ log.Println("Videos directory:", xdg.UserDirs.Videos)
+ log.Println("Templates directory:", xdg.UserDirs.Templates)
+ log.Println("Public directory:", xdg.UserDirs.PublicShare)
+ }
+*/
+package xdg
diff --git a/vendor/github.com/adrg/xdg/internal/pathutil/pathutil.go b/vendor/github.com/adrg/xdg/internal/pathutil/pathutil.go
new file mode 100644
index 00000000000..7422342b3c4
--- /dev/null
+++ b/vendor/github.com/adrg/xdg/internal/pathutil/pathutil.go
@@ -0,0 +1,78 @@
+package pathutil
+
+import (
+ "fmt"
+ "os"
+ "path/filepath"
+ "strings"
+)
+
+// Unique eliminates the duplicate paths from the provided slice and returns
+// the result. The items in the output slice are in the order in which they
+// occur in the input slice. If a `home` location is provided, the paths are
+// expanded using the `ExpandHome` function.
+func Unique(paths []string, home string) []string {
+ var (
+ uniq []string
+ registry = map[string]struct{}{}
+ )
+
+ for _, p := range paths {
+ p = ExpandHome(p, home)
+ if p != "" && filepath.IsAbs(p) {
+ if _, ok := registry[p]; ok {
+ continue
+ }
+
+ registry[p] = struct{}{}
+ uniq = append(uniq, p)
+ }
+ }
+
+ return uniq
+}
+
+// Create returns a suitable location relative to which the file with the
+// specified `name` can be written. The first path from the provided `paths`
+// slice which is successfully created (or already exists) is used as a base
+// path for the file. The `name` parameter should contain the name of the file
+// which is going to be written in the location returned by this function, but
+// it can also contain a set of parent directories, which will be created
+// relative to the selected parent path.
+func Create(name string, paths []string) (string, error) {
+ var searchedPaths []string
+ for _, p := range paths {
+ p = filepath.Join(p, name)
+
+ dir := filepath.Dir(p)
+ if Exists(dir) {
+ return p, nil
+ }
+ if err := os.MkdirAll(dir, os.ModeDir|0700); err == nil {
+ return p, nil
+ }
+
+ searchedPaths = append(searchedPaths, dir)
+ }
+
+ return "", fmt.Errorf("could not create any of the following paths: %s",
+ strings.Join(searchedPaths, ", "))
+}
+
+// Search searches for the file with the specified `name` in the provided
+// slice of `paths`. The `name` parameter must contain the name of the file,
+// but it can also contain a set of parent directories.
+func Search(name string, paths []string) (string, error) {
+ var searchedPaths []string
+ for _, p := range paths {
+ p = filepath.Join(p, name)
+ if Exists(p) {
+ return p, nil
+ }
+
+ searchedPaths = append(searchedPaths, filepath.Dir(p))
+ }
+
+ return "", fmt.Errorf("could not locate `%s` in any of the following paths: %s",
+ filepath.Base(name), strings.Join(searchedPaths, ", "))
+}
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 00000000000..8ee4e8d2fbe
--- /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
+}
diff --git a/vendor/github.com/adrg/xdg/internal/pathutil/pathutil_unix.go b/vendor/github.com/adrg/xdg/internal/pathutil/pathutil_unix.go
new file mode 100644
index 00000000000..a014c66ef67
--- /dev/null
+++ b/vendor/github.com/adrg/xdg/internal/pathutil/pathutil_unix.go
@@ -0,0 +1,32 @@
+//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 (
+ "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
+}
diff --git a/vendor/github.com/adrg/xdg/internal/pathutil/pathutil_windows.go b/vendor/github.com/adrg/xdg/internal/pathutil/pathutil_windows.go
new file mode 100644
index 00000000000..44080e3ab61
--- /dev/null
+++ b/vendor/github.com/adrg/xdg/internal/pathutil/pathutil_windows.go
@@ -0,0 +1,64 @@
+package pathutil
+
+import (
+ "os"
+ "path/filepath"
+ "strings"
+
+ "golang.org/x/sys/windows"
+)
+
+// Exists returns true if the specified path exists.
+func Exists(path string) bool {
+ fi, err := os.Lstat(path)
+ if fi != nil && fi.Mode()&os.ModeSymlink != 0 {
+ _, err = filepath.EvalSymlinks(path)
+ }
+
+ return err == nil || os.IsExist(err)
+}
+
+// ExpandHome substitutes `%USERPROFILE%` at the start of the specified
+// `path` using the provided `home` location.
+func ExpandHome(path, home string) string {
+ if path == "" || home == "" {
+ return path
+ }
+ if strings.HasPrefix(path, `%USERPROFILE%`) {
+ return filepath.Join(home, path[13:])
+ }
+
+ return path
+}
+
+// KnownFolder returns the location of the folder with the specified ID.
+// If that fails, the folder location is determined by reading the provided
+// environment variables (the first non-empty read value is returned).
+// If that fails as well, the first non-empty fallback is returned.
+// If all of the above fails, the function returns an empty string.
+func KnownFolder(id *windows.KNOWNFOLDERID, envVars []string, fallbacks []string) string {
+ if id != nil {
+ flags := []uint32{windows.KF_FLAG_DEFAULT, windows.KF_FLAG_DEFAULT_PATH}
+ for _, flag := range flags {
+ p, _ := windows.KnownFolderPath(id, flag|windows.KF_FLAG_DONT_VERIFY)
+ if p != "" {
+ return p
+ }
+ }
+ }
+
+ for _, envVar := range envVars {
+ p := os.Getenv(envVar)
+ if p != "" {
+ return p
+ }
+ }
+
+ for _, fallback := range fallbacks {
+ if fallback != "" {
+ return fallback
+ }
+ }
+
+ return ""
+}
diff --git a/vendor/github.com/adrg/xdg/paths_darwin.go b/vendor/github.com/adrg/xdg/paths_darwin.go
new file mode 100644
index 00000000000..bfe9ad9bc47
--- /dev/null
+++ b/vendor/github.com/adrg/xdg/paths_darwin.go
@@ -0,0 +1,60 @@
+package xdg
+
+import (
+ "os"
+ "path/filepath"
+)
+
+func homeDir() string {
+ if home := os.Getenv("HOME"); home != "" {
+ return home
+ }
+
+ return "/"
+}
+
+func initDirs(home string) {
+ initBaseDirs(home)
+ initUserDirs(home)
+}
+
+func initBaseDirs(home string) {
+ homeAppSupport := filepath.Join(home, "Library", "Application Support")
+ rootAppSupport := "/Library/Application Support"
+
+ // Initialize standard directories.
+ baseDirs.dataHome = xdgPath(envDataHome, homeAppSupport)
+ baseDirs.data = xdgPaths(envDataDirs, rootAppSupport)
+ baseDirs.configHome = xdgPath(envConfigHome, homeAppSupport)
+ baseDirs.config = xdgPaths(envConfigDirs,
+ filepath.Join(home, "Library", "Preferences"),
+ rootAppSupport,
+ "/Library/Preferences",
+ )
+ baseDirs.stateHome = xdgPath(envStateHome, homeAppSupport)
+ baseDirs.cacheHome = xdgPath(envCacheHome, filepath.Join(home, "Library", "Caches"))
+ baseDirs.runtime = xdgPath(envRuntimeDir, homeAppSupport)
+
+ // Initialize non-standard directories.
+ baseDirs.applications = []string{
+ "/Applications",
+ }
+
+ baseDirs.fonts = []string{
+ filepath.Join(home, "Library/Fonts"),
+ "/Library/Fonts",
+ "/System/Library/Fonts",
+ "/Network/Library/Fonts",
+ }
+}
+
+func initUserDirs(home string) {
+ UserDirs.Desktop = xdgPath(envDesktopDir, filepath.Join(home, "Desktop"))
+ UserDirs.Download = xdgPath(envDownloadDir, filepath.Join(home, "Downloads"))
+ UserDirs.Documents = xdgPath(envDocumentsDir, filepath.Join(home, "Documents"))
+ UserDirs.Music = xdgPath(envMusicDir, filepath.Join(home, "Music"))
+ UserDirs.Pictures = xdgPath(envPicturesDir, filepath.Join(home, "Pictures"))
+ UserDirs.Videos = xdgPath(envVideosDir, filepath.Join(home, "Movies"))
+ UserDirs.Templates = xdgPath(envTemplatesDir, filepath.Join(home, "Templates"))
+ UserDirs.PublicShare = xdgPath(envPublicShareDir, filepath.Join(home, "Public"))
+}
diff --git a/vendor/github.com/adrg/xdg/paths_plan9.go b/vendor/github.com/adrg/xdg/paths_plan9.go
new file mode 100644
index 00000000000..2882f688b3c
--- /dev/null
+++ b/vendor/github.com/adrg/xdg/paths_plan9.go
@@ -0,0 +1,55 @@
+package xdg
+
+import (
+ "os"
+ "path/filepath"
+)
+
+func homeDir() string {
+ if home := os.Getenv("home"); home != "" {
+ return home
+ }
+
+ return "/"
+}
+
+func initDirs(home string) {
+ initBaseDirs(home)
+ initUserDirs(home)
+}
+
+func initBaseDirs(home string) {
+ homeLibDir := filepath.Join(home, "lib")
+ rootLibDir := "/lib"
+
+ // Initialize standard directories.
+ baseDirs.dataHome = xdgPath(envDataHome, homeLibDir)
+ baseDirs.data = xdgPaths(envDataDirs, rootLibDir)
+ baseDirs.configHome = xdgPath(envConfigHome, homeLibDir)
+ baseDirs.config = xdgPaths(envConfigDirs, rootLibDir)
+ baseDirs.stateHome = xdgPath(envStateHome, filepath.Join(homeLibDir, "state"))
+ baseDirs.cacheHome = xdgPath(envCacheHome, filepath.Join(homeLibDir, "cache"))
+ baseDirs.runtime = xdgPath(envRuntimeDir, "/tmp")
+
+ // Initialize non-standard directories.
+ baseDirs.applications = []string{
+ filepath.Join(home, "bin"),
+ "/bin",
+ }
+
+ baseDirs.fonts = []string{
+ filepath.Join(homeLibDir, "font"),
+ "/lib/font",
+ }
+}
+
+func initUserDirs(home string) {
+ UserDirs.Desktop = xdgPath(envDesktopDir, filepath.Join(home, "desktop"))
+ UserDirs.Download = xdgPath(envDownloadDir, filepath.Join(home, "downloads"))
+ UserDirs.Documents = xdgPath(envDocumentsDir, filepath.Join(home, "documents"))
+ UserDirs.Music = xdgPath(envMusicDir, filepath.Join(home, "music"))
+ UserDirs.Pictures = xdgPath(envPicturesDir, filepath.Join(home, "pictures"))
+ UserDirs.Videos = xdgPath(envVideosDir, filepath.Join(home, "videos"))
+ UserDirs.Templates = xdgPath(envTemplatesDir, filepath.Join(home, "templates"))
+ UserDirs.PublicShare = xdgPath(envPublicShareDir, filepath.Join(home, "public"))
+}
diff --git a/vendor/github.com/adrg/xdg/paths_unix.go b/vendor/github.com/adrg/xdg/paths_unix.go
new file mode 100644
index 00000000000..ad571dfc811
--- /dev/null
+++ b/vendor/github.com/adrg/xdg/paths_unix.go
@@ -0,0 +1,71 @@
+//go:build aix || dragonfly || freebsd || (js && wasm) || nacl || linux || netbsd || openbsd || solaris
+// +build aix dragonfly freebsd js,wasm nacl linux netbsd openbsd solaris
+
+package xdg
+
+import (
+ "os"
+ "path/filepath"
+ "strconv"
+
+ "github.com/adrg/xdg/internal/pathutil"
+)
+
+func homeDir() string {
+ if home := os.Getenv("HOME"); home != "" {
+ return home
+ }
+
+ return "/"
+}
+
+func initDirs(home string) {
+ initBaseDirs(home)
+ initUserDirs(home)
+}
+
+func initBaseDirs(home string) {
+ // Initialize standard directories.
+ baseDirs.dataHome = xdgPath(envDataHome, filepath.Join(home, ".local", "share"))
+ baseDirs.data = xdgPaths(envDataDirs, "/usr/local/share", "/usr/share")
+ baseDirs.configHome = xdgPath(envConfigHome, filepath.Join(home, ".config"))
+ baseDirs.config = xdgPaths(envConfigDirs, "/etc/xdg")
+ baseDirs.stateHome = xdgPath(envStateHome, filepath.Join(home, ".local", "state"))
+ baseDirs.cacheHome = xdgPath(envCacheHome, filepath.Join(home, ".cache"))
+ baseDirs.runtime = xdgPath(envRuntimeDir, filepath.Join("/run/user", strconv.Itoa(os.Getuid())))
+
+ // Initialize non-standard directories.
+ appDirs := []string{
+ filepath.Join(baseDirs.dataHome, "applications"),
+ filepath.Join(home, ".local/share/applications"),
+ "/usr/local/share/applications",
+ "/usr/share/applications",
+ }
+
+ fontDirs := []string{
+ filepath.Join(baseDirs.dataHome, "fonts"),
+ filepath.Join(home, ".fonts"),
+ filepath.Join(home, ".local/share/fonts"),
+ "/usr/local/share/fonts",
+ "/usr/share/fonts",
+ }
+
+ for _, dir := range baseDirs.data {
+ appDirs = append(appDirs, filepath.Join(dir, "applications"))
+ fontDirs = append(fontDirs, filepath.Join(dir, "fonts"))
+ }
+
+ baseDirs.applications = pathutil.Unique(appDirs, Home)
+ baseDirs.fonts = pathutil.Unique(fontDirs, Home)
+}
+
+func initUserDirs(home string) {
+ UserDirs.Desktop = xdgPath(envDesktopDir, filepath.Join(home, "Desktop"))
+ UserDirs.Download = xdgPath(envDownloadDir, filepath.Join(home, "Downloads"))
+ UserDirs.Documents = xdgPath(envDocumentsDir, filepath.Join(home, "Documents"))
+ UserDirs.Music = xdgPath(envMusicDir, filepath.Join(home, "Music"))
+ UserDirs.Pictures = xdgPath(envPicturesDir, filepath.Join(home, "Pictures"))
+ UserDirs.Videos = xdgPath(envVideosDir, filepath.Join(home, "Videos"))
+ UserDirs.Templates = xdgPath(envTemplatesDir, filepath.Join(home, "Templates"))
+ UserDirs.PublicShare = xdgPath(envPublicShareDir, filepath.Join(home, "Public"))
+}
diff --git a/vendor/github.com/adrg/xdg/paths_windows.go b/vendor/github.com/adrg/xdg/paths_windows.go
new file mode 100644
index 00000000000..722d3e7856f
--- /dev/null
+++ b/vendor/github.com/adrg/xdg/paths_windows.go
@@ -0,0 +1,168 @@
+package xdg
+
+import (
+ "path/filepath"
+
+ "github.com/adrg/xdg/internal/pathutil"
+ "golang.org/x/sys/windows"
+)
+
+func homeDir() string {
+ return pathutil.KnownFolder(
+ windows.FOLDERID_Profile,
+ []string{"USERPROFILE"},
+ nil,
+ )
+}
+
+func initDirs(home string) {
+ kf := initKnownFolders(home)
+ initBaseDirs(home, kf)
+ initUserDirs(home, kf)
+}
+
+func initBaseDirs(home string, kf *knownFolders) {
+ // Initialize standard directories.
+ baseDirs.dataHome = xdgPath(envDataHome, kf.localAppData)
+ baseDirs.data = xdgPaths(envDataDirs, kf.roamingAppData, kf.programData)
+ baseDirs.configHome = xdgPath(envConfigHome, kf.localAppData)
+ baseDirs.config = xdgPaths(envConfigDirs, kf.programData, kf.roamingAppData)
+ baseDirs.stateHome = xdgPath(envStateHome, kf.localAppData)
+ baseDirs.cacheHome = xdgPath(envCacheHome, filepath.Join(kf.localAppData, "cache"))
+ baseDirs.runtime = xdgPath(envRuntimeDir, kf.localAppData)
+
+ // Initialize non-standard directories.
+ baseDirs.applications = []string{
+ kf.programs,
+ kf.commonPrograms,
+ }
+ baseDirs.fonts = []string{
+ kf.fonts,
+ filepath.Join(kf.localAppData, "Microsoft", "Windows", "Fonts"),
+ }
+}
+
+func initUserDirs(home string, kf *knownFolders) {
+ UserDirs.Desktop = xdgPath(envDesktopDir, kf.desktop)
+ UserDirs.Download = xdgPath(envDownloadDir, kf.downloads)
+ UserDirs.Documents = xdgPath(envDocumentsDir, kf.documents)
+ UserDirs.Music = xdgPath(envMusicDir, kf.music)
+ UserDirs.Pictures = xdgPath(envPicturesDir, kf.pictures)
+ UserDirs.Videos = xdgPath(envVideosDir, kf.videos)
+ UserDirs.Templates = xdgPath(envTemplatesDir, kf.templates)
+ UserDirs.PublicShare = xdgPath(envPublicShareDir, kf.public)
+}
+
+type knownFolders struct {
+ systemDrive string
+ systemRoot string
+ programData string
+ userProfile string
+ userProfiles string
+ roamingAppData string
+ localAppData string
+ desktop string
+ downloads string
+ documents string
+ music string
+ pictures string
+ videos string
+ templates string
+ public string
+ fonts string
+ programs string
+ commonPrograms string
+}
+
+func initKnownFolders(home string) *knownFolders {
+ kf := &knownFolders{
+ userProfile: home,
+ }
+ kf.systemDrive = filepath.VolumeName(pathutil.KnownFolder(
+ windows.FOLDERID_Windows,
+ []string{"SystemDrive", "SystemRoot", "windir"},
+ []string{home, `C:`},
+ )) + string(filepath.Separator)
+ kf.systemRoot = pathutil.KnownFolder(
+ windows.FOLDERID_Windows,
+ []string{"SystemRoot", "windir"},
+ []string{filepath.Join(kf.systemDrive, "Windows")},
+ )
+ kf.programData = pathutil.KnownFolder(
+ windows.FOLDERID_ProgramData,
+ []string{"ProgramData", "ALLUSERSPROFILE"},
+ []string{filepath.Join(kf.systemDrive, "ProgramData")},
+ )
+ kf.userProfiles = pathutil.KnownFolder(
+ windows.FOLDERID_UserProfiles,
+ nil,
+ []string{filepath.Join(kf.systemDrive, "Users")},
+ )
+ kf.roamingAppData = pathutil.KnownFolder(
+ windows.FOLDERID_RoamingAppData,
+ []string{"APPDATA"},
+ []string{filepath.Join(home, "AppData", "Roaming")},
+ )
+ kf.localAppData = pathutil.KnownFolder(
+ windows.FOLDERID_LocalAppData,
+ []string{"LOCALAPPDATA"},
+ []string{filepath.Join(home, "AppData", "Local")},
+ )
+ kf.desktop = pathutil.KnownFolder(
+ windows.FOLDERID_Desktop,
+ nil,
+ []string{filepath.Join(home, "Desktop")},
+ )
+ kf.downloads = pathutil.KnownFolder(
+ windows.FOLDERID_Downloads,
+ nil,
+ []string{filepath.Join(home, "Downloads")},
+ )
+ kf.documents = pathutil.KnownFolder(
+ windows.FOLDERID_Documents,
+ nil,
+ []string{filepath.Join(home, "Documents")},
+ )
+ kf.music = pathutil.KnownFolder(
+ windows.FOLDERID_Music,
+ nil,
+ []string{filepath.Join(home, "Music")},
+ )
+ kf.pictures = pathutil.KnownFolder(
+ windows.FOLDERID_Pictures,
+ nil,
+ []string{filepath.Join(home, "Pictures")},
+ )
+ kf.videos = pathutil.KnownFolder(
+ windows.FOLDERID_Videos,
+ nil,
+ []string{filepath.Join(home, "Videos")},
+ )
+ kf.templates = pathutil.KnownFolder(
+ windows.FOLDERID_Templates,
+ nil,
+ []string{filepath.Join(kf.roamingAppData, "Microsoft", "Windows", "Templates")},
+ )
+ kf.public = pathutil.KnownFolder(
+ windows.FOLDERID_Public,
+ []string{"PUBLIC"},
+ []string{filepath.Join(kf.userProfiles, "Public")},
+ )
+ kf.fonts = pathutil.KnownFolder(
+ windows.FOLDERID_Fonts,
+ nil,
+ []string{filepath.Join(kf.systemRoot, "Fonts")},
+ )
+ kf.programs = pathutil.KnownFolder(
+ windows.FOLDERID_Programs,
+ nil,
+ []string{filepath.Join(kf.roamingAppData, "Microsoft", "Windows", "Start Menu", "Programs")},
+ )
+ kf.commonPrograms = pathutil.KnownFolder(
+ windows.FOLDERID_CommonPrograms,
+ nil,
+ []string{filepath.Join(kf.programData, "Microsoft", "Windows", "Start Menu", "Programs")},
+ )
+
+ return kf
+}
diff --git a/vendor/github.com/adrg/xdg/user_dirs.go b/vendor/github.com/adrg/xdg/user_dirs.go
new file mode 100644
index 00000000000..72088748d0c
--- /dev/null
+++ b/vendor/github.com/adrg/xdg/user_dirs.go
@@ -0,0 +1,40 @@
+package xdg
+
+// XDG user directories environment variables.
+const (
+ envDesktopDir = "XDG_DESKTOP_DIR"
+ envDownloadDir = "XDG_DOWNLOAD_DIR"
+ envDocumentsDir = "XDG_DOCUMENTS_DIR"
+ envMusicDir = "XDG_MUSIC_DIR"
+ envPicturesDir = "XDG_PICTURES_DIR"
+ envVideosDir = "XDG_VIDEOS_DIR"
+ envTemplatesDir = "XDG_TEMPLATES_DIR"
+ envPublicShareDir = "XDG_PUBLICSHARE_DIR"
+)
+
+// UserDirectories defines the locations of well known user directories.
+type UserDirectories struct {
+ // Desktop defines the location of the user's desktop directory.
+ Desktop string
+
+ // Download defines a suitable location for user downloaded files.
+ Download string
+
+ // Documents defines a suitable location for user document files.
+ Documents string
+
+ // Music defines a suitable location for user audio files.
+ Music string
+
+ // Pictures defines a suitable location for user image files.
+ Pictures string
+
+ // VideosDir defines a suitable location for user video files.
+ Videos string
+
+ // Templates defines a suitable location for user template files.
+ Templates string
+
+ // PublicShare defines a suitable location for user shared files.
+ PublicShare string
+}
diff --git a/vendor/github.com/adrg/xdg/xdg.go b/vendor/github.com/adrg/xdg/xdg.go
new file mode 100644
index 00000000000..3d33ca6e55d
--- /dev/null
+++ b/vendor/github.com/adrg/xdg/xdg.go
@@ -0,0 +1,218 @@
+package xdg
+
+import (
+ "os"
+ "path/filepath"
+
+ "github.com/adrg/xdg/internal/pathutil"
+)
+
+var (
+ // Home contains the path of the user's home directory.
+ Home string
+
+ // DataHome defines the base directory relative to which user-specific
+ // data files should be stored. This directory is defined by the
+ // $XDG_DATA_HOME environment variable. If the variable is not set,
+ // a default equal to $HOME/.local/share should be used.
+ DataHome string
+
+ // DataDirs defines the preference-ordered set of base directories to
+ // search for data files in addition to the DataHome base directory.
+ // This set of directories is defined by the $XDG_DATA_DIRS environment
+ // variable. If the variable is not set, the default directories
+ // to be used are /usr/local/share and /usr/share, in that order. The
+ // DataHome directory is considered more important than any of the
+ // directories defined by DataDirs. Therefore, user data files should be
+ // written relative to the DataHome directory, if possible.
+ DataDirs []string
+
+ // ConfigHome defines the base directory relative to which user-specific
+ // configuration files should be written. This directory is defined by
+ // the $XDG_CONFIG_HOME environment variable. If the variable is not
+ // not set, a default equal to $HOME/.config should be used.
+ ConfigHome string
+
+ // ConfigDirs defines the preference-ordered set of base directories to
+ // search for configuration files in addition to the ConfigHome base
+ // directory. This set of directories is defined by the $XDG_CONFIG_DIRS
+ // environment variable. If the variable is not set, a default equal
+ // to /etc/xdg should be used. The ConfigHome directory is considered
+ // more important than any of the directories defined by ConfigDirs.
+ // Therefore, user config files should be written relative to the
+ // ConfigHome directory, if possible.
+ ConfigDirs []string
+
+ // StateHome defines the base directory relative to which user-specific
+ // state files should be stored. This directory is defined by the
+ // $XDG_STATE_HOME environment variable. If the variable is not set,
+ // a default equal to ~/.local/state should be used.
+ StateHome string
+
+ // CacheHome defines the base directory relative to which user-specific
+ // non-essential (cached) data should be written. This directory is
+ // defined by the $XDG_CACHE_HOME environment variable. If the variable
+ // is not set, a default equal to $HOME/.cache should be used.
+ CacheHome string
+
+ // RuntimeDir defines the base directory relative to which user-specific
+ // non-essential runtime files and other file objects (such as sockets,
+ // named pipes, etc.) should be stored. This directory is defined by the
+ // $XDG_RUNTIME_DIR environment variable. If the variable is not set,
+ // applications should fall back to a replacement directory with similar
+ // capabilities. Applications should use this directory for communication
+ // and synchronization purposes and should not place larger files in it,
+ // since it might reside in runtime memory and cannot necessarily be
+ // swapped out to disk.
+ RuntimeDir string
+
+ // UserDirs defines the locations of well known user directories.
+ UserDirs UserDirectories
+
+ // FontDirs defines the common locations where font files are stored.
+ FontDirs []string
+
+ // ApplicationDirs defines the common locations of applications.
+ ApplicationDirs []string
+
+ // baseDirs defines the locations of base directories.
+ baseDirs baseDirectories
+)
+
+func init() {
+ Reload()
+}
+
+// Reload refreshes base and user directories by reading the environment.
+// Defaults are applied for XDG variables which are empty or not present
+// in the environment.
+func Reload() {
+ // Initialize home directory.
+ Home = homeDir()
+
+ // Initialize base and user directories.
+ initDirs(Home)
+
+ // Set standard directories.
+ DataHome = baseDirs.dataHome
+ DataDirs = baseDirs.data
+ ConfigHome = baseDirs.configHome
+ ConfigDirs = baseDirs.config
+ StateHome = baseDirs.stateHome
+ CacheHome = baseDirs.cacheHome
+ RuntimeDir = baseDirs.runtime
+
+ // Set non-standard directories.
+ FontDirs = baseDirs.fonts
+ ApplicationDirs = baseDirs.applications
+}
+
+// DataFile returns a suitable location for the specified data file.
+// The relPath parameter must contain the name of the data file, and
+// optionally, a set of parent directories (e.g. appname/app.data).
+// If the specified directories do not exist, they will be created relative
+// to the base data directory. On failure, an error containing the
+// attempted paths is returned.
+func DataFile(relPath string) (string, error) {
+ return baseDirs.dataFile(relPath)
+}
+
+// ConfigFile returns a suitable location for the specified config file.
+// The relPath parameter must contain the name of the config file, and
+// optionally, a set of parent directories (e.g. appname/app.yaml).
+// If the specified directories do not exist, they will be created relative
+// to the base config directory. On failure, an error containing the
+// attempted paths is returned.
+func ConfigFile(relPath string) (string, error) {
+ return baseDirs.configFile(relPath)
+}
+
+// StateFile returns a suitable location for the specified state file. State
+// files are usually volatile data files, not suitable to be stored relative
+// to the $XDG_DATA_HOME directory.
+// The relPath parameter must contain the name of the state file, and
+// optionally, a set of parent directories (e.g. appname/app.state).
+// If the specified directories do not exist, they will be created relative
+// to the base state directory. On failure, an error containing the
+// attempted paths is returned.
+func StateFile(relPath string) (string, error) {
+ return baseDirs.stateFile(relPath)
+}
+
+// CacheFile returns a suitable location for the specified cache file.
+// The relPath parameter must contain the name of the cache file, and
+// optionally, a set of parent directories (e.g. appname/app.cache).
+// If the specified directories do not exist, they will be created relative
+// to the base cache directory. On failure, an error containing the
+// attempted paths is returned.
+func CacheFile(relPath string) (string, error) {
+ return baseDirs.cacheFile(relPath)
+}
+
+// RuntimeFile returns a suitable location for the specified runtime file.
+// The relPath parameter must contain the name of the runtime file, and
+// optionally, a set of parent directories (e.g. appname/app.pid).
+// If the specified directories do not exist, they will be created relative
+// to the base runtime directory. On failure, an error containing the
+// attempted paths is returned.
+func RuntimeFile(relPath string) (string, error) {
+ return baseDirs.runtimeFile(relPath)
+}
+
+// SearchDataFile searches for specified file in the data search paths.
+// The relPath parameter must contain the name of the data file, and
+// optionally, a set of parent directories (e.g. appname/app.data). If the
+// file cannot be found, an error specifying the searched paths is returned.
+func SearchDataFile(relPath string) (string, error) {
+ return baseDirs.searchDataFile(relPath)
+}
+
+// SearchConfigFile searches for the specified file in config search paths.
+// The relPath parameter must contain the name of the config file, and
+// optionally, a set of parent directories (e.g. appname/app.yaml). If the
+// file cannot be found, an error specifying the searched paths is returned.
+func SearchConfigFile(relPath string) (string, error) {
+ return baseDirs.searchConfigFile(relPath)
+}
+
+// SearchStateFile searches for the specified file in the state search path.
+// The relPath parameter must contain the name of the state file, and
+// optionally, a set of parent directories (e.g. appname/app.state). If the
+// file cannot be found, an error specifying the searched path is returned.
+func SearchStateFile(relPath string) (string, error) {
+ return baseDirs.searchStateFile(relPath)
+}
+
+// SearchCacheFile searches for the specified file in the cache search path.
+// The relPath parameter must contain the name of the cache file, and
+// optionally, a set of parent directories (e.g. appname/app.cache). If the
+// file cannot be found, an error specifying the searched path is returned.
+func SearchCacheFile(relPath string) (string, error) {
+ return baseDirs.searchCacheFile(relPath)
+}
+
+// SearchRuntimeFile searches for the specified file in the runtime search path.
+// The relPath parameter must contain the name of the runtime file, and
+// optionally, a set of parent directories (e.g. appname/app.pid). If the
+// file cannot be found, an error specifying the searched path is returned.
+func SearchRuntimeFile(relPath string) (string, error) {
+ return baseDirs.searchRuntimeFile(relPath)
+}
+
+func xdgPath(name, defaultPath string) string {
+ dir := pathutil.ExpandHome(os.Getenv(name), Home)
+ if dir != "" && filepath.IsAbs(dir) {
+ return dir
+ }
+
+ return defaultPath
+}
+
+func xdgPaths(name string, defaultPaths ...string) []string {
+ dirs := pathutil.Unique(filepath.SplitList(os.Getenv(name)), Home)
+ if len(dirs) != 0 {
+ return dirs
+ }
+
+ return pathutil.Unique(defaultPaths, Home)
+}
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 1b9f41882e8..eb3da7d6308 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -1,6 +1,7 @@
-# github.com/OpenPeeDeeP/xdg v1.0.0
-## explicit
-github.com/OpenPeeDeeP/xdg
+# github.com/adrg/xdg v0.4.0
+## explicit; go 1.14
+github.com/adrg/xdg
+github.com/adrg/xdg/internal/pathutil
# github.com/atotto/clipboard v0.1.4
## explicit
github.com/atotto/clipboard