blob: c73fb5a26b2458a75a41d2bb02aec9a0645626d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
using System;
using System.IO;
namespace UVtools.Core.SystemOS;
/// <summary>
/// Linux specific methods
/// </summary>
public static class Linux
{
/// <summary>
/// Gets if is running under Linux and under AppImage format
/// </summary>
public static bool IsRunningAppImage => !string.IsNullOrWhiteSpace(RunningAppImageRootPath);
/// <summary>
/// Gets if is running under Linux and under AppImage format and return the full root path for the running AppImage
/// </summary>
public static bool IsRunningAppImageGetPath(out string? path)
{
path = RunningAppImageRootPath;
return !string.IsNullOrWhiteSpace(path);
}
/// <summary>
/// <para>Gets the full root path for the running AppImage. Returns null is not Linux and null/empty if not an AppImage</para>
/// <para>The return path is the source file location and not the execution path location.</para>
/// </summary>
public static string? RunningAppImageRootPath => OperatingSystem.IsLinux() ? Environment.GetEnvironmentVariable("APPIMAGE") : null;
/// <summary>
/// Gets the name of the running *.app. Returns null or empty if not running an macOS .app. Returns null or empty if not an AppImage
/// </summary>
public static string? RunningAppName => Path.GetFileName(RunningAppImageRootPath);
}
|