/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc.
* 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;
///
/// Linux specific methods
///
public static class Linux
{
///
/// Gets if is running under Linux and under AppImage format
///
public static bool IsRunningAppImage => !string.IsNullOrWhiteSpace(RunningAppImageRootPath);
///
/// Gets if is running under Linux and under AppImage format and return the full root path for the running AppImage
///
public static bool IsRunningAppImageGetPath(out string? path)
{
path = RunningAppImageRootPath;
return !string.IsNullOrWhiteSpace(path);
}
///
/// Gets the full root path for the running AppImage. Returns null is not Linux and null/empty if not an AppImage
/// The return path is the source file location and not the execution path location.
///
public static string? RunningAppImageRootPath => OperatingSystem.IsLinux() ? Environment.GetEnvironmentVariable("APPIMAGE") : null;
///
/// 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
///
public static string? RunningAppName => Path.GetFileName(RunningAppImageRootPath);
}