mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 00:16:15 +00:00
app: [Android] set XDG_CACHE_HOME to make os.UserCacheDir work
os.UserCacheDir can't work on Android because it doesn't have access to the Java app context. Gio programs do have access, so set up UserCacheDir's fallback, the XDG_CACHE_HOME environment variable. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -7,6 +7,8 @@ package app
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"gioui.org/app/internal/window"
|
||||
@@ -20,6 +22,9 @@ var (
|
||||
func dataDir() (string, error) {
|
||||
dataDirOnce.Do(func() {
|
||||
dataPath = window.GetDataDir()
|
||||
// Set XDG_CACHE_HOME to make os.UserCacheDir work.
|
||||
cachePath := filepath.Join(dataPath, "cache")
|
||||
os.Setenv("XDG_CACHE_HOME", cachePath)
|
||||
})
|
||||
return dataPath, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user