2020-10-06 21:06:47 +08:00
|
|
|
package xdg
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
func initBaseDirs(home string) {
|
2021-03-05 18:06:25 +08:00
|
|
|
homeAppSupport := filepath.Join(home, "Library", "Application Support")
|
|
|
|
rootAppSupport := "/Library/Application Support"
|
|
|
|
|
2020-10-06 21:06:47 +08:00
|
|
|
// Initialize base directories.
|
2021-03-05 18:06:25 +08:00
|
|
|
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",
|
|
|
|
)
|
2020-10-06 21:06:47 +08:00
|
|
|
baseDirs.cacheHome = xdgPath(envCacheHome, filepath.Join(home, "Library", "Caches"))
|
2021-03-05 18:06:25 +08:00
|
|
|
baseDirs.runtime = xdgPath(envRuntimeDir, homeAppSupport)
|
2020-10-06 21:06:47 +08:00
|
|
|
|
|
|
|
// Initialize non-standard directories.
|
2021-03-05 18:06:25 +08:00
|
|
|
baseDirs.stateHome = xdgPath(envStateHome, homeAppSupport)
|
2020-10-06 21:06:47 +08:00
|
|
|
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"))
|
|
|
|
}
|