mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
app: [Android] tweak environment for os.UserHomeDir and os.UserConfigDir
Set the fallback environment variables XDG_CONFIG_HOME and HOME to make os.UserConfigDir and os.UserHomeDir report useful paths. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+13
-2
@@ -23,8 +23,19 @@ func dataDir() (string, error) {
|
|||||||
dataDirOnce.Do(func() {
|
dataDirOnce.Do(func() {
|
||||||
dataPath = window.GetDataDir()
|
dataPath = window.GetDataDir()
|
||||||
// Set XDG_CACHE_HOME to make os.UserCacheDir work.
|
// Set XDG_CACHE_HOME to make os.UserCacheDir work.
|
||||||
cachePath := filepath.Join(dataPath, "cache")
|
if _, exists := os.LookupEnv("XDG_CACHE_HOME"); !exists {
|
||||||
os.Setenv("XDG_CACHE_HOME", cachePath)
|
cachePath := filepath.Join(dataPath, "cache")
|
||||||
|
os.Setenv("XDG_CACHE_HOME", cachePath)
|
||||||
|
}
|
||||||
|
// Set XDG_CONFIG_HOME to make os.UserConfigDir work.
|
||||||
|
if _, exists := os.LookupEnv("XDG_CONFIG_HOME"); !exists {
|
||||||
|
cfgPath := filepath.Join(dataPath, "config")
|
||||||
|
os.Setenv("XDG_CONFIG_HOME", cfgPath)
|
||||||
|
}
|
||||||
|
// Set HOME to make os.UserHomeDir work.
|
||||||
|
if _, exists := os.LookupEnv("HOME"); !exists {
|
||||||
|
os.Setenv("HOME", dataPath)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return dataPath, nil
|
return dataPath, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user