mlaumcherb/Mlaumcherb.Client.Avalonia/холопы/PathHelper.cs
2025-04-07 06:18:22 +05:00

69 lines
2.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Mlaumcherb.Client.Avalonia.зримое;
namespace Mlaumcherb.Client.Avalonia.холопы;
public static class PathHelper
{
public static IOPath GetRootFullPath() =>
System.IO.Path.GetFullPath(new IOPath(LauncherApp.Config.minecraft_dir).ToString());
public static IOPath GetAssetsDir() =>
Path.Concat(GetRootFullPath(), "assets");
public static IOPath GetAssetIndexFilePath(string id) =>
Path.Concat(GetAssetsDir(), $"indexes/{id}.json"); // this path is hardcoded in the game
public static IOPath GetVersionDescriptorPath(string id) =>
Path.Concat(GetVersionDir(id), id + ".json");
public static IOPath GetVersionsDir() =>
Path.Concat(GetRootFullPath(), "versions");
public static IOPath GetVersionDir(string id) =>
Path.Concat(GetVersionsDir(), id);
public static IOPath GetVersionJarFilePath(string id) =>
Path.Concat(GetVersionDir(id), id + ".jar");
public static IOPath GetLibrariesDir() =>
Path.Concat(GetRootFullPath(), "libraries");
public static IOPath GetNativeLibrariesDir(string id) =>
Path.Concat(GetVersionDir(id), "natives", PlatformHelper.GetOsAndArch());
public static IOPath GetJavaRuntimesDir() =>
Path.Concat(GetRootFullPath(), "java");
public static IOPath GetJavaRuntimeDir(string id) =>
Path.Concat(GetJavaRuntimesDir(), PlatformHelper.GetOsAndArch(), id);
public static IOPath GetJavaBinDir(string id) =>
Path.Concat(GetJavaRuntimeDir(id), "bin");
public static IOPath GetJavaExecutablePath(string id, bool redirectOutput)
{
string executable_name = "java";
if (!redirectOutput)
executable_name = "javaw";
if(OperatingSystem.IsWindows())
executable_name += ".exe";
var path = Path.Concat(GetJavaBinDir(id), executable_name);
if(!redirectOutput && !File.Exists(path))
return GetJavaExecutablePath(id, true);
return path;
}
public static string GetLog4jConfigFileName() => "log4j.xml";
public static IOPath GetLog4jConfigFilePath() =>
Path.Concat(GetAssetsDir(), GetLog4jConfigFileName());
public static IOPath GetModpackDescriptorPath(string game_version) =>
Path.Concat(GetVersionDir(game_version), "timerix_modpack.json");
public static IOPath GetCacheDir() =>
Path.Concat(GetRootFullPath(), "cache");
public static IOPath GetInstalledVersionCatalogPath() =>
Path.Concat(GetCacheDir(), "installed_versions.json");
}