Update Vendors (#337)
* update & migrate gitea sdk (Fix Delete Tag Issue) * upgraded github.com/AlecAivazis/survey v2.2.7 => v2.2.8 * upgraded github.com/adrg/xdg v0.2.3 => v0.3.1 * upgraded github.com/araddon/dateparse * upgraded github.com/olekukonko/tablewriter v0.0.4 => v0.0.5 * upgraded gopkg.in/yaml.v2 v2.3.0 => v2.4.0 Reviewed-on: https://gitea.com/gitea/tea/pulls/337 Reviewed-by: Norwin <noerw@noreply.gitea.io> Reviewed-by: khmarbaise <khmarbaise@noreply.gitea.io> Co-authored-by: 6543 <6543@obermui.de> Co-committed-by: 6543 <6543@obermui.de>
This commit is contained in:
161
vendor/github.com/adrg/xdg/README.md
generated
vendored
161
vendor/github.com/adrg/xdg/README.md
generated
vendored
@@ -1,21 +1,50 @@
|
||||
xdg
|
||||
===
|
||||
<h1 align="center">
|
||||
<div>
|
||||
<img src="https://raw.githubusercontent.com/adrg/adrg.github.io/master/assets/projects/xdg/logo.png" height="80px" alt="xdg logo"/>
|
||||
</div>
|
||||
</h1>
|
||||
|
||||
[](https://github.com/adrg/xdg/actions?query=workflow%3ACI)
|
||||
[](https://codecov.io/gh/adrg/xdg)
|
||||
[](https://pkg.go.dev/github.com/adrg/xdg)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://goreportcard.com/report/github.com/adrg/xdg)
|
||||
[](https://github.com/adrg/xdg/issues)
|
||||
[](https://www.buymeacoffee.com/adrg)
|
||||
[](https://github.com/adrg/xdg/stargazers)
|
||||
<h4 align="center">Go implementation of the XDG Base Directory Specification and XDG user directories.</h4>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/adrg/xdg/actions?query=workflow%3ACI">
|
||||
<img alt="Build status" src="https://github.com/adrg/xdg/workflows/CI/badge.svg">
|
||||
</a>
|
||||
<a href="https://app.codecov.io/gh/adrg/xdg">
|
||||
<img alt="Code coverage" src="https://codecov.io/gh/adrg/xdg/branch/master/graphs/badge.svg?branch=master">
|
||||
</a>
|
||||
<a href="https://pkg.go.dev/github.com/adrg/xdg">
|
||||
<img alt="pkg.go.dev documentation" src="https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white">
|
||||
</a>
|
||||
<a href="https://opensource.org/licenses/MIT" rel="nofollow">
|
||||
<img alt="MIT license" src="https://img.shields.io/github/license/adrg/xdg">
|
||||
</a>
|
||||
<br />
|
||||
<a href="https://goreportcard.com/report/github.com/adrg/xdg">
|
||||
<img alt="Go report card" src="https://goreportcard.com/badge/github.com/adrg/xdg">
|
||||
</a>
|
||||
<a href="https://github.com/avelino/awesome-go#configuration">
|
||||
<img alt="Awesome Go" src="https://awesome.re/mentioned-badge.svg">
|
||||
</a>
|
||||
<a href="https://github.com/adrg/xdg/graphs/contributors">
|
||||
<img alt="GitHub contributors" src="https://img.shields.io/github/contributors/adrg/xdg" />
|
||||
</a>
|
||||
<a href="https://github.com/adrg/xdg/issues">
|
||||
<img alt="GitHub open issues" src="https://img.shields.io/github/issues-raw/adrg/xdg">
|
||||
</a>
|
||||
<a href="https://ko-fi.com/T6T72WATK">
|
||||
<img alt="Buy me a coffee" src="https://img.shields.io/static/v1.svg?label=%20&message=Buy%20me%20a%20coffee&color=579fbf&logo=buy%20me%20a%20coffee&logoColor=white">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
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).
|
||||
The current implementation supports Windows, Mac OS and most flavors of Unix.
|
||||
|
||||
The package also includes the locations of well known [user directories](https://wiki.archlinux.org/index.php/XDG_user_directories)
|
||||
and an implementation of the [state directory](https://wiki.debian.org/XDGBaseDirectorySpecification#Proposal:_STATE_directory) proposal.
|
||||
Windows, macOS and most flavors of Unix are supported.
|
||||
|
||||
Full documentation can be found at: https://pkg.go.dev/github.com/adrg/xdg.
|
||||
|
||||
@@ -29,19 +58,19 @@ present in the environment.
|
||||
|
||||
#### XDG Base Directory
|
||||
|
||||
| | Unix | Mac OS | Windows |
|
||||
| :--- | :--- | :----- | :--- |
|
||||
| XDG_DATA_HOME | `~/.local/share` | `~/Library/Application Support` | `%LOCALAPPDATA%` |
|
||||
| XDG_DATA_DIRS | `/usr/local/share`<br/>`/usr/share` | `/Library/Application Support` | `%APPDATA%\Roaming`<br/>`%PROGRAMDATA%` |
|
||||
| XDG_CONFIG_HOME | `~/.config` | `~/Library/Preferences` | `%LOCALAPPDATA%` |
|
||||
| XDG_CONFIG_DIRS | `/etc/xdg` | `/Library/Preferences` | `%PROGRAMDATA%` |
|
||||
| XDG_CACHE_HOME | `~/.cache` | `~/Library/Caches` | `%LOCALAPPDATA%\cache` |
|
||||
| XDG_RUNTIME_DIR | `/run/user/UID` | `~/Library/Application Support` | `%LOCALAPPDATA%` |
|
||||
| | Unix | macOS | Windows |
|
||||
| :-------------- | :---------------------------------- | :------------------------------------------------------------------------------------ | :-------------------------------------- |
|
||||
| XDG_DATA_HOME | `~/.local/share` | `~/Library/Application Support` | `%LOCALAPPDATA%` |
|
||||
| XDG_DATA_DIRS | `/usr/local/share`<br/>`/usr/share` | `/Library/Application Support` | `%APPDATA%\Roaming`<br/>`%PROGRAMDATA%` |
|
||||
| XDG_CONFIG_HOME | `~/.config` | `~/Library/Application Support` | `%LOCALAPPDATA%` |
|
||||
| XDG_CONFIG_DIRS | `/etc/xdg` | `~/Library/Preferences`<br/>`/Library/Application Support`<br/>`/Library/Preferences` | `%PROGRAMDATA%` |
|
||||
| XDG_CACHE_HOME | `~/.cache` | `~/Library/Caches` | `%LOCALAPPDATA%\cache` |
|
||||
| XDG_RUNTIME_DIR | `/run/user/UID` | `~/Library/Application Support` | `%LOCALAPPDATA%` |
|
||||
|
||||
#### XDG user directories
|
||||
|
||||
| | Unix | Mac OS | Windows |
|
||||
| :--- | :--- | :----- | :--- |
|
||||
| | Unix | macOS | Windows |
|
||||
| :------------------ | :------------ | :------------ | :------------------------ |
|
||||
| XDG_DESKTOP_DIR | `~/Desktop` | `~/Desktop` | `%USERPROFILE%/Desktop` |
|
||||
| XDG_DOWNLOAD_DIR | `~/Downloads` | `~/Downloads` | `%USERPROFILE%/Downloads` |
|
||||
| XDG_DOCUMENTS_DIR | `~/Documents` | `~/Documents` | `%USERPROFILE%/Documents` |
|
||||
@@ -53,43 +82,50 @@ present in the environment.
|
||||
|
||||
#### Non-standard directories
|
||||
|
||||
State directory
|
||||
|
||||
```
|
||||
Unix
|
||||
• ~/.local/state
|
||||
macOS
|
||||
• ~/Library/Application Support
|
||||
Windows
|
||||
• %LOCALAPPDATA%
|
||||
```
|
||||
|
||||
Application directories
|
||||
|
||||
```
|
||||
Unix:
|
||||
- $XDG_DATA_HOME/applications
|
||||
- ~/.local/share/applications
|
||||
- /usr/local/share/applications
|
||||
- /usr/share/applications
|
||||
- $XDG_DATA_DIRS/applications
|
||||
|
||||
Mac OS:
|
||||
- /Applications
|
||||
|
||||
Windows:
|
||||
- %APPDATA%\Roaming\Microsoft\Windows\Start Menu\Programs
|
||||
Unix
|
||||
• $XDG_DATA_HOME/applications
|
||||
• ~/.local/share/applications
|
||||
• /usr/local/share/applications
|
||||
• /usr/share/applications
|
||||
• $XDG_DATA_DIRS/applications
|
||||
macOS
|
||||
• /Applications
|
||||
Windows
|
||||
• %APPDATA%\Roaming\Microsoft\Windows\Start Menu\Programs
|
||||
```
|
||||
|
||||
Font Directories
|
||||
Font directories
|
||||
|
||||
```
|
||||
Unix:
|
||||
- $XDG_DATA_HOME/fonts
|
||||
- ~/.fonts
|
||||
- ~/.local/share/fonts
|
||||
- /usr/local/share/fonts
|
||||
- /usr/share/fonts
|
||||
- $XDG_DATA_DIRS/fonts
|
||||
|
||||
Mac OS:
|
||||
- ~/Library/Fonts
|
||||
- /Library/Fonts
|
||||
- /System/Library/Fonts
|
||||
- /Network/Library/Fonts
|
||||
|
||||
Windows:
|
||||
- %windir%\Fonts
|
||||
- %LOCALAPPDATA%\Microsoft\Windows\Fonts
|
||||
Unix
|
||||
• $XDG_DATA_HOME/fonts
|
||||
• ~/.fonts
|
||||
• ~/.local/share/fonts
|
||||
• /usr/local/share/fonts
|
||||
• /usr/share/fonts
|
||||
• $XDG_DATA_DIRS/fonts
|
||||
macOS
|
||||
• ~/Library/Fonts
|
||||
• /Library/Fonts
|
||||
• /System/Library/Fonts
|
||||
• /Network/Library/Fonts
|
||||
Windows
|
||||
• %windir%\Fonts
|
||||
• %LOCALAPPDATA%\Microsoft\Windows\Fonts
|
||||
```
|
||||
|
||||
## Usage
|
||||
@@ -115,6 +151,7 @@ func main() {
|
||||
log.Println("Runtime directory:", xdg.RuntimeDir)
|
||||
|
||||
// Non-standard directories.
|
||||
log.Println("Home state directory:", xdg.StateHome)
|
||||
log.Println("Application directories:", xdg.ApplicationDirs)
|
||||
log.Println("Font directories:", xdg.FontDirs)
|
||||
|
||||
@@ -132,6 +169,7 @@ func main() {
|
||||
// xdg.DataFile()
|
||||
// xdg.CacheFile()
|
||||
// xdg.RuntimeFile()
|
||||
// xdg.StateFile()
|
||||
|
||||
// Finding application config files.
|
||||
// SearchConfigFile takes one parameter which must contain the name of
|
||||
@@ -147,6 +185,7 @@ func main() {
|
||||
// xdg.SearchDataFile()
|
||||
// xdg.SearchCacheFile()
|
||||
// xdg.SearchRuntimeFile()
|
||||
// xdg.SearchStateFile()
|
||||
}
|
||||
```
|
||||
|
||||
@@ -181,31 +220,27 @@ func main() {
|
||||
## Contributing
|
||||
|
||||
Contributions in the form of pull requests, issues or just general feedback,
|
||||
are always welcome.
|
||||
See [CONTRIBUTING.MD](https://github.com/adrg/xdg/blob/master/CONTRIBUTING.md).
|
||||
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).
|
||||
[gabriel-vasile](https://github.com/gabriel-vasile),
|
||||
[KalleDK](https://github.com/KalleDK).
|
||||
|
||||
## 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)
|
||||
|
||||
## Buy me a coffee
|
||||
|
||||
If you found this project useful and want to support it, consider buying me a coffee.
|
||||
<a href="https://www.buymeacoffee.com/adrg">
|
||||
<img src="https://cdn.buymeacoffee.com/buttons/v2/arial-orange.png" alt="Buy Me A Coffee" height="42px">
|
||||
</a>
|
||||
* [XDG state directory proposal](https://wiki.debian.org/XDGBaseDirectorySpecification#Proposal:_STATE_directory)
|
||||
* [XDG_STATE_HOME proposal](https://lists.freedesktop.org/archives/xdg/2016-December/013803.html)
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2014 Adrian-George Bostan.
|
||||
|
||||
This project is licensed under the [MIT license](https://opensource.org/licenses/MIT).
|
||||
See [LICENSE](https://github.com/adrg/xdg/blob/master/LICENSE) for more details.
|
||||
See [LICENSE](LICENSE) for more details.
|
||||
|
||||
32
vendor/github.com/adrg/xdg/base_dirs.go
generated
vendored
32
vendor/github.com/adrg/xdg/base_dirs.go
generated
vendored
@@ -1,7 +1,5 @@
|
||||
package xdg
|
||||
|
||||
import "os"
|
||||
|
||||
// XDG Base Directory environment variables.
|
||||
const (
|
||||
envDataHome = "XDG_DATA_HOME"
|
||||
@@ -10,6 +8,7 @@ const (
|
||||
envConfigDirs = "XDG_CONFIG_DIRS"
|
||||
envCacheHome = "XDG_CACHE_HOME"
|
||||
envRuntimeDir = "XDG_RUNTIME_DIR"
|
||||
envStateHome = "XDG_STATE_HOME"
|
||||
)
|
||||
|
||||
type baseDirectories struct {
|
||||
@@ -21,6 +20,7 @@ type baseDirectories struct {
|
||||
runtime string
|
||||
|
||||
// Non-standard directories.
|
||||
stateHome string
|
||||
fonts []string
|
||||
applications []string
|
||||
}
|
||||
@@ -38,29 +38,13 @@ func (bd baseDirectories) cacheFile(relPath string) (string, error) {
|
||||
}
|
||||
|
||||
func (bd baseDirectories) runtimeFile(relPath string) (string, error) {
|
||||
fi, err := os.Lstat(bd.runtime)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return createPath(relPath, []string{bd.runtime})
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
if fi.IsDir() {
|
||||
// The runtime directory must be owned by the user.
|
||||
if err = chown(bd.runtime, os.Getuid(), os.Getgid()); err != nil {
|
||||
return "", err
|
||||
}
|
||||
} else {
|
||||
// For security reasons, the runtime directory cannot be a symlink.
|
||||
if err = os.Remove(bd.runtime); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
return createPath(relPath, []string{bd.runtime})
|
||||
}
|
||||
|
||||
func (bd baseDirectories) stateFile(relPath string) (string, error) {
|
||||
return createPath(relPath, []string{bd.stateHome})
|
||||
}
|
||||
|
||||
func (bd baseDirectories) searchDataFile(relPath string) (string, error) {
|
||||
return searchFile(relPath, append([]string{bd.dataHome}, bd.data...))
|
||||
}
|
||||
@@ -76,3 +60,7 @@ func (bd baseDirectories) searchCacheFile(relPath string) (string, error) {
|
||||
func (bd baseDirectories) searchRuntimeFile(relPath string) (string, error) {
|
||||
return searchFile(relPath, []string{bd.runtime})
|
||||
}
|
||||
|
||||
func (bd baseDirectories) searchStateFile(relPath string) (string, error) {
|
||||
return searchFile(relPath, []string{bd.stateHome})
|
||||
}
|
||||
|
||||
1
vendor/github.com/adrg/xdg/go.sum
generated
vendored
1
vendor/github.com/adrg/xdg/go.sum
generated
vendored
@@ -5,6 +5,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
18
vendor/github.com/adrg/xdg/paths_darwin.go
generated
vendored
18
vendor/github.com/adrg/xdg/paths_darwin.go
generated
vendored
@@ -5,15 +5,23 @@ import (
|
||||
)
|
||||
|
||||
func initBaseDirs(home string) {
|
||||
homeAppSupport := filepath.Join(home, "Library", "Application Support")
|
||||
rootAppSupport := "/Library/Application Support"
|
||||
|
||||
// Initialize base directories.
|
||||
baseDirs.dataHome = xdgPath(envDataHome, filepath.Join(home, "Library", "Application Support"))
|
||||
baseDirs.data = xdgPaths(envDataDirs, "/Library/Application Support")
|
||||
baseDirs.configHome = xdgPath(envConfigHome, filepath.Join(home, "Library", "Preferences"))
|
||||
baseDirs.config = xdgPaths(envConfigDirs, "/Library/Preferences")
|
||||
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.cacheHome = xdgPath(envCacheHome, filepath.Join(home, "Library", "Caches"))
|
||||
baseDirs.runtime = xdgPath(envRuntimeDir, filepath.Join(home, "Library", "Application Support"))
|
||||
baseDirs.runtime = xdgPath(envRuntimeDir, homeAppSupport)
|
||||
|
||||
// Initialize non-standard directories.
|
||||
baseDirs.stateHome = xdgPath(envStateHome, homeAppSupport)
|
||||
baseDirs.applications = []string{
|
||||
"/Applications",
|
||||
}
|
||||
|
||||
1
vendor/github.com/adrg/xdg/paths_unix.go
generated
vendored
1
vendor/github.com/adrg/xdg/paths_unix.go
generated
vendored
@@ -18,6 +18,7 @@ func initBaseDirs(home string) {
|
||||
baseDirs.runtime = xdgPath(envRuntimeDir, filepath.Join("/run/user", strconv.Itoa(os.Getuid())))
|
||||
|
||||
// Initialize non-standard directories.
|
||||
baseDirs.stateHome = xdgPath(envStateHome, filepath.Join(home, ".local", "state"))
|
||||
appDirs := []string{
|
||||
filepath.Join(baseDirs.dataHome, "applications"),
|
||||
filepath.Join(home, ".local/share/applications"),
|
||||
|
||||
1
vendor/github.com/adrg/xdg/paths_windows.go
generated
vendored
1
vendor/github.com/adrg/xdg/paths_windows.go
generated
vendored
@@ -43,6 +43,7 @@ func initBaseDirs(home string) {
|
||||
baseDirs.runtime = xdgPath(envRuntimeDir, localAppDataDir)
|
||||
|
||||
// Initialize non-standard directories.
|
||||
baseDirs.stateHome = xdgPath(envStateHome, localAppDataDir)
|
||||
baseDirs.applications = []string{
|
||||
filepath.Join(roamingAppDataDir, "Microsoft", "Windows", "Start Menu", "Programs"),
|
||||
}
|
||||
|
||||
8
vendor/github.com/adrg/xdg/utils.go
generated
vendored
8
vendor/github.com/adrg/xdg/utils.go
generated
vendored
@@ -33,14 +33,6 @@ func homeDir() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func chown(name string, uid, gid int) error {
|
||||
if goOS := runtime.GOOS; goOS == "windows" || goOS == "plan9" {
|
||||
return nil
|
||||
}
|
||||
|
||||
return os.Chown(name, uid, gid)
|
||||
}
|
||||
|
||||
func exists(path string) bool {
|
||||
_, err := os.Stat(path)
|
||||
return err == nil || os.IsExist(err)
|
||||
|
||||
55
vendor/github.com/adrg/xdg/xdg.go
generated
vendored
55
vendor/github.com/adrg/xdg/xdg.go
generated
vendored
@@ -12,6 +12,10 @@ flavors of Unix.
|
||||
|
||||
For more information regarding the XDG user directories see:
|
||||
https://wiki.archlinux.org/index.php/XDG_user_directories
|
||||
|
||||
For more information regarding the XDG state directory proposal see:
|
||||
https://wiki.debian.org/XDGBaseDirectorySpecification#Proposal:_STATE_directory
|
||||
https://lists.freedesktop.org/archives/xdg/2016-December/013803.html
|
||||
*/
|
||||
package xdg
|
||||
|
||||
@@ -21,14 +25,14 @@ var (
|
||||
|
||||
// DataHome defines the base directory relative to which user-specific
|
||||
// data files should be stored. This directory is defined by the
|
||||
// environment variable $XDG_DATA_HOME. If this variable is not set,
|
||||
// $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 environment variable
|
||||
// $XDG_DATA_DIRS. If this variable is not set, the default directories
|
||||
// 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
|
||||
@@ -37,30 +41,30 @@ var (
|
||||
|
||||
// ConfigHome defines the base directory relative to which user-specific
|
||||
// configuration files should be written. This directory is defined by
|
||||
// the environment variable $XDG_CONFIG_HOME. If this variable is not
|
||||
// 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 environment
|
||||
// variable $XDG_CONFIG_DIRS. If this 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.
|
||||
// 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
|
||||
|
||||
// CacheHome defines the base directory relative to which user-specific
|
||||
// non-essential (cached) data should be written. This directory is
|
||||
// defined by the environment variable $XDG_CACHE_HOME. If this variable
|
||||
// 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
|
||||
// environment variable $XDG_RUNTIME_DIR. If this variable is not set,
|
||||
// $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,
|
||||
@@ -68,6 +72,12 @@ var (
|
||||
// swapped out to disk.
|
||||
RuntimeDir string
|
||||
|
||||
// StateHome defines the base directory relative to which user-specific
|
||||
// volatile data files should be stored. This directory is defined by
|
||||
// the non-standard $XDG_STATE_HOME environment variable. If the variable
|
||||
// is not set, a default equal to ~/.local/state should be used.
|
||||
StateHome string
|
||||
|
||||
// UserDirs defines the locations of well known user directories.
|
||||
UserDirs UserDirectories
|
||||
|
||||
@@ -96,6 +106,7 @@ func Reload() {
|
||||
ConfigDirs = baseDirs.config
|
||||
CacheHome = baseDirs.cacheHome
|
||||
RuntimeDir = baseDirs.runtime
|
||||
StateHome = baseDirs.stateHome
|
||||
FontDirs = baseDirs.fonts
|
||||
ApplicationDirs = baseDirs.applications
|
||||
|
||||
@@ -143,6 +154,18 @@ func RuntimeFile(relPath string) (string, error) {
|
||||
return baseDirs.runtimeFile(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)
|
||||
}
|
||||
|
||||
// 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
|
||||
@@ -175,6 +198,14 @@ func SearchRuntimeFile(relPath string) (string, error) {
|
||||
return baseDirs.searchRuntimeFile(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)
|
||||
}
|
||||
|
||||
func init() {
|
||||
Reload()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user