summaryrefslogtreecommitdiff
path: root/src/AppDirs.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2024-11-11 12:27:53 +0100
committerJörg Frings-Fürst <debian@jff.email>2024-11-11 12:27:53 +0100
commit5b7b3b1dfd5ce7c275881098310667b09562ad27 (patch)
treed2760df372d76da84d901cfc3a20514d5dc73bdf /src/AppDirs.vala
parentf6062696f6bbd00d4eaa8a6e994dabfefc455f31 (diff)
New upstream version 0.32.10upstream/0.32.10upstream
Diffstat (limited to 'src/AppDirs.vala')
-rw-r--r--src/AppDirs.vala31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/AppDirs.vala b/src/AppDirs.vala
index 05e172c..fd357c2 100644
--- a/src/AppDirs.vala
+++ b/src/AppDirs.vala
@@ -193,12 +193,39 @@ class AppDirs {
public static File get_exec_dir() {
return exec_dir;
}
+
+ public enum Runtime {
+ NATIVE,
+ FLATPAK,
+ SNAP,
+ UNKNOWN
+ }
+
+ private static Runtime _runtime = Runtime.UNKNOWN;
+
+ public static Runtime get_runtime() {
+ if (_runtime == Runtime.UNKNOWN) {
+ var snap = Environment.get_variable("SNAP_NAME");
+ if (snap != null) {
+ _runtime = Runtime.SNAP;
+ }
+ else {
+ var flatpak_canary = File.new_for_path("/.flatpak-info");
+ if (flatpak_canary.query_exists()) {
+ _runtime = Runtime.FLATPAK;
+ } else {
+ _runtime = Runtime.NATIVE;
+ }
+ }
+ }
+
+ return _runtime;
+ }
public static File get_temp_dir() {
if (tmp_dir == null) {
var basedir = Environment.get_tmp_dir();
- var flatpak_canary = File.new_for_path("/.flatpak-info");
- if (flatpak_canary.query_exists() && basedir == "/tmp") {
+ if (get_runtime() == Runtime.FLATPAK && basedir == "/tmp") {
basedir = Environment.get_user_cache_dir() + "/tmp";
}