mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 16:35:36 +00:00
2395659be3
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>
31 lines
481 B
Go
31 lines
481 B
Go
// SPDX-License-Identifier: Unlicense OR MIT
|
|
|
|
// +build android
|
|
|
|
package app
|
|
|
|
import "C"
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"sync"
|
|
|
|
"gioui.org/app/internal/window"
|
|
)
|
|
|
|
var (
|
|
dataDirOnce sync.Once
|
|
dataPath string
|
|
)
|
|
|
|
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
|
|
}
|