1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2026-05-22 10:15:43 +02:00
Files
lazygit/vendor/github.com/adrg/xdg/base_dirs.go
T
dependabot[bot] a205bb74eb Bump github.com/adrg/xdg from 0.4.0 to 0.5.3
Bumps [github.com/adrg/xdg](https://github.com/adrg/xdg) from 0.4.0 to 0.5.3.
- [Release notes](https://github.com/adrg/xdg/releases)
- [Commits](https://github.com/adrg/xdg/compare/v0.4.0...v0.5.3)

---
updated-dependencies:
- dependency-name: github.com/adrg/xdg
  dependency-version: 0.5.3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-04-01 08:19:10 +00:00

83 lines
2.2 KiB
Go

package xdg
import (
"os"
"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"
// Non-standard.
envBinHome = "XDG_BIN_HOME"
)
type baseDirectories struct {
dataHome string
data []string
configHome string
config []string
stateHome string
cacheHome string
runtime string
// Non-standard.
binHome string
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) {
var paths []string
for _, p := range pathutil.Unique([]string{bd.runtime, os.TempDir()}) {
if pathutil.Exists(p) {
paths = append(paths, p)
}
}
return pathutil.Create(relPath, paths)
}
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, pathutil.Unique([]string{bd.runtime, os.TempDir()}))
}