summaryrefslogtreecommitdiff
path: root/src/AppDirs.vala
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2024-11-11 12:28:09 +0100
committerJörg Frings-Fürst <debian@jff.email>2024-11-11 12:28:09 +0100
commitcb001bb8056869f98e9a62248bdd509a69d08faf (patch)
treeec5e83ac39e4e5cec0ab9494da2d0edaafe72d89 /src/AppDirs.vala
parent1bbf886bafc680c56ddd5e27ddd803b4e03685df (diff)
parent5b7b3b1dfd5ce7c275881098310667b09562ad27 (diff)
Update upstream source from tag 'upstream/0.32.10'
Update to upstream version '0.32.10' with Debian dir 4a4ccaeec66d543745486a1cf408bbaa58c6e02f
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";
}