natives unzip

This commit is contained in:
2024-09-29 09:28:24 +05:00
parent 4704f1217a
commit beb701ca40
7 changed files with 55 additions and 16 deletions

View File

@@ -7,7 +7,7 @@ public class Libraries
private static readonly string[] enabled_features = [];
public record JarLib(string name, IOPath jarFilePath, Artifact artifact);
public record NativeLib(string name, IOPath jarFilePath, Artifact artifact, IOPath nativeFilesDir, Extract? extractionOptions)
public record NativeLib(string name, IOPath jarFilePath, Artifact artifact, Extract? extractionOptions)
: JarLib(name, jarFilePath, artifact);
public IReadOnlyCollection<JarLib> Libs { get; }
@@ -43,9 +43,9 @@ public class Libraries
if(!libHashes.Add(artifact.sha1))
continue;
IOPath dir = Пути.GetVersionDir(descriptor.id);
IOPath jarPath = Path.Concat(dir, Path.ReplaceRestrictedChars(l.name));
libs.Add(new NativeLib(l.name, jarPath, artifact, dir, l.extract));
string urlTail = artifact.url.AsSpan().After("://").After('/').ToString();
IOPath jarFilePath = Path.Concat(Пути.GetLibrariesDir(), urlTail);
libs.Add(new NativeLib(l.name, jarFilePath, artifact, l.extract));
}
else
{
@@ -57,8 +57,9 @@ public class Libraries
if(!libHashes.Add(artifact.sha1))
continue;
IOPath path = artifact.url.AsSpan().After("://").After('/').ToString();
libs.Add(new JarLib(l.name, Path.Concat(Пути.GetLibrariesDir(), path), artifact));
string urlTail = artifact.url.AsSpan().After("://").After('/').ToString();
IOPath jarFilePath = Path.Concat(Пути.GetLibrariesDir(), urlTail);
libs.Add(new JarLib(l.name, jarFilePath, artifact));
}
}

View File

@@ -52,5 +52,14 @@ public static class Буржуазия
}
return allowed;
}
}
public static string GetOs() =>
Environment.OSVersion.Platform switch
{
PlatformID.Win32NT => "windows",
PlatformID.Unix => "linux",
PlatformID.MacOSX => "osx",
_ => throw new ArgumentOutOfRangeException(Environment.OSVersion.Platform.ToString())
};
}

View File

@@ -25,6 +25,9 @@ public static class Пути
public static IOPath GetLibrariesDir() =>
Path.Concat(Приложение.Настройки.путь_к_кубачу, "libraries");
public static IOPath GetNativeLibrariesDir(string id) =>
Path.Concat(GetVersionDir(id), "natives", Буржуазия.GetOs());
public static IOPath GetJavaRuntimesDir() =>
Path.Concat(Приложение.Настройки.путь_к_кубачу, "java");