mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: agonostic dll
This commit is contained in:
1 parent
7098395323
commit
1957d960aa
2 files changed
+62
-14
No files matched your search
@@ -1,4 +1,4 @@
|
||||
using CUE4Parse.Compression;
|
||||
using CLI.Utils;
|
||||
using CUE4Parse.FileProvider.Objects;
|
||||
using CUE4Parse.UE4.Pak;
|
||||
|
||||
@@ -7,7 +7,11 @@ namespace CLI.Functions
|
||||
class Unpacker
|
||||
{
|
||||
public static string ZlibPath = "../../temp/zlib.dll";
|
||||
public static string VFSWriteDirectory = "../../temp/vfs/";
|
||||
public static string VFSWriteDir = "../../temp/vfs/";
|
||||
|
||||
// this may be different from the one provided in args so check this and not args[1]
|
||||
// we don't wanna delete my local installation of the game when debugging haha!
|
||||
public static string tempDepotsDir = "../../temp/depot/";
|
||||
|
||||
public static void Unpack(string[] args)
|
||||
{
|
||||
@@ -16,17 +20,7 @@ namespace CLI.Functions
|
||||
throw new ArgumentException("Missing required initial paks directory");
|
||||
}
|
||||
|
||||
if (File.Exists(ZlibPath))
|
||||
{
|
||||
Console.WriteLine($"Zlib found at {ZlibPath}; using that...");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Zlib not found; downloading to {ZlibPath}...");
|
||||
ZlibHelper.DownloadDll(ZlibPath);
|
||||
}
|
||||
|
||||
ZlibHelper.Initialize(ZlibPath);
|
||||
AgnosticZlibHelper.Initialize();
|
||||
|
||||
string workingDirectory = args[1];
|
||||
string paksDirectory = Path.Combine(workingDirectory, "Blitz/Content/Paks");
|
||||
@@ -36,6 +30,12 @@ namespace CLI.Functions
|
||||
{
|
||||
Exergy(container);
|
||||
}
|
||||
|
||||
if (Directory.Exists(tempDepotsDir))
|
||||
{
|
||||
Console.WriteLine("Deleting temp depots directory...");
|
||||
Directory.Delete(tempDepotsDir, true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Exergy(string container)
|
||||
@@ -56,7 +56,7 @@ namespace CLI.Functions
|
||||
continue;
|
||||
}
|
||||
|
||||
string writePath = Path.Combine(VFSWriteDirectory, gameFile.Path);
|
||||
string writePath = Path.Combine(VFSWriteDir, gameFile.Path);
|
||||
|
||||
if (File.Exists(writePath))
|
||||
{
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using CUE4Parse.Compression;
|
||||
|
||||
namespace CLI.Utils
|
||||
{
|
||||
public static class AgnosticZlibHelper
|
||||
{
|
||||
public const string ZlibRootPath = "../../temp/";
|
||||
public const string ZlibBinariesPrefix =
|
||||
"https://github.com/NotOfficer/Zlib-ng.NET/releases/download/1.0.0";
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
string binariesUrl;
|
||||
string fileExtension;
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
binariesUrl = $"{ZlibBinariesPrefix}/zlib-ng2.dll";
|
||||
fileExtension = "dll";
|
||||
}
|
||||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
binariesUrl = $"{ZlibBinariesPrefix}/libz-ng.so";
|
||||
fileExtension = "so";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
string fileName = $"zlib.{fileExtension}";
|
||||
string filePath = Path.Combine(ZlibRootPath, fileName);
|
||||
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
Console.WriteLine($"Zlib found at {filePath}; using that...");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Zlib not found; downloading to {filePath} from {binariesUrl}...");
|
||||
ZlibHelper.DownloadDll(filePath, binariesUrl);
|
||||
}
|
||||
|
||||
ZlibHelper.Initialize(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user