From 0a041957f1b8bcafdd3ea783738fc25a576c190f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 25 Feb 2023 21:20:48 -0800 Subject: [PATCH] os: add flatpak detection --- src/os/flatpak.zig | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/os/flatpak.zig diff --git a/src/os/flatpak.zig b/src/os/flatpak.zig new file mode 100644 index 000000000..afd6c33de --- /dev/null +++ b/src/os/flatpak.zig @@ -0,0 +1,9 @@ +const std = @import("std"); +const builtin = @import("builtin"); + +/// Returns true if we're running in a Flatpak environment. +pub fn isFlatpak() bool { + // If we're not on Linux then we'll make this comptime false. + if (comptime builtin.os.tag != .linux) return false; + return if (std.fs.accessAbsolute("/.flatpak-info", .{})) true else |_| false; +}