rewrote config file path search (#219)
added comment to clarify coding choices added package xdg to vendor folder rewrote config file path search Co-authored-by: crapStone <crapstone01@gmail.com> Reviewed-on: https://gitea.com/gitea/tea/pulls/219 Reviewed-by: 6543 <6543@noreply.gitea.io> Reviewed-by: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
69
vendor/github.com/adrg/xdg/paths_windows.go
generated
vendored
Normal file
69
vendor/github.com/adrg/xdg/paths_windows.go
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
package xdg
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func initBaseDirs(home string) {
|
||||
appDataDir := os.Getenv("APPDATA")
|
||||
if appDataDir == "" {
|
||||
appDataDir = filepath.Join(home, "AppData")
|
||||
}
|
||||
roamingAppDataDir := filepath.Join(appDataDir, "Roaming")
|
||||
|
||||
localAppDataDir := os.Getenv("LOCALAPPDATA")
|
||||
if localAppDataDir == "" {
|
||||
localAppDataDir = filepath.Join(appDataDir, "Local")
|
||||
}
|
||||
|
||||
programDataDir := os.Getenv("PROGRAMDATA")
|
||||
if programDataDir == "" {
|
||||
if systemDrive := os.Getenv("SystemDrive"); systemDrive != "" {
|
||||
programDataDir = filepath.Join(systemDrive, "ProgramData")
|
||||
} else {
|
||||
programDataDir = home
|
||||
}
|
||||
}
|
||||
|
||||
winDir := os.Getenv("windir")
|
||||
if winDir == "" {
|
||||
winDir = os.Getenv("SystemRoot")
|
||||
if winDir == "" {
|
||||
winDir = home
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize base directories.
|
||||
baseDirs.dataHome = xdgPath(envDataHome, localAppDataDir)
|
||||
baseDirs.data = xdgPaths(envDataDirs, roamingAppDataDir, programDataDir)
|
||||
baseDirs.configHome = xdgPath(envConfigHome, localAppDataDir)
|
||||
baseDirs.config = xdgPaths(envConfigDirs, programDataDir)
|
||||
baseDirs.cacheHome = xdgPath(envCacheHome, filepath.Join(localAppDataDir, "cache"))
|
||||
baseDirs.runtime = xdgPath(envRuntimeDir, localAppDataDir)
|
||||
|
||||
// Initialize non-standard directories.
|
||||
baseDirs.applications = []string{
|
||||
filepath.Join(roamingAppDataDir, "Microsoft", "Windows", "Start Menu", "Programs"),
|
||||
}
|
||||
baseDirs.fonts = []string{
|
||||
filepath.Join(winDir, "Fonts"),
|
||||
filepath.Join(localAppDataDir, "Microsoft", "Windows", "Fonts"),
|
||||
}
|
||||
}
|
||||
|
||||
func initUserDirs(home string) {
|
||||
publicDir := os.Getenv("PUBLIC")
|
||||
if publicDir == "" {
|
||||
publicDir = filepath.Join(home, "Public")
|
||||
}
|
||||
|
||||
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, publicDir)
|
||||
}
|
||||
Reference in New Issue
Block a user