diff options
Diffstat (limited to 'android_shared_android.go')
| -rw-r--r-- | android_shared_android.go | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/android_shared_android.go b/android_shared_android.go index b736fab..e46fab2 100644 --- a/android_shared_android.go +++ b/android_shared_android.go @@ -3,32 +3,24 @@ package main import ( - "os" - "path/filepath" + "os" + "path/filepath" ) // readSharedFromCache tries to read the shared text written by the Android activity. // The activity writes into getCacheDir()/quicklogger-shared.txt; on Go, os.TempDir() // maps to the same location in Android (app cache directory). func readSharedFromCache() (string, error) { - dir, derr := os.UserCacheDir() - if derr != nil || dir == "" { - dir = os.TempDir() - } - path := filepath.Join(dir, "quicklogger-shared.txt") - b, err := os.ReadFile(path) - if err != nil { - return "", err - } - // best-effort cleanup; ignore errors - _ = os.Remove(path) - return string(b), nil -} - -func debugSharedPath() string { - dir, _ := os.UserCacheDir() - if dir == "" { - dir = os.TempDir() - } - return filepath.Join(dir, "quicklogger-shared.txt") + dir, derr := os.UserCacheDir() + if derr != nil || dir == "" { + dir = os.TempDir() + } + path := filepath.Join(dir, "quicklogger-shared.txt") + b, err := os.ReadFile(path) + if err != nil { + return "", err + } + // best-effort cleanup; ignore errors + _ = os.Remove(path) + return string(b), nil } |
