89 lines
No EOL
3.4 KiB
C#
89 lines
No EOL
3.4 KiB
C#
using System.IO.Compression;
|
|
using MetaforceInstaller.Core.Models;
|
|
|
|
namespace MetaforceInstaller.Core.Services;
|
|
|
|
public class ZipScrapper
|
|
{
|
|
public static InstallationParts PeekFiles(ZipArchive archive)
|
|
{
|
|
return new InstallationParts
|
|
{
|
|
AndroidContentExists = DoesAndroidContentExists(archive),
|
|
OculusClientExists = DoesOculusClientExists(archive),
|
|
PicoClientExists = DoesPicoClientExists(archive),
|
|
AndroidAdminExists = DoesAndroidAdminExists(archive),
|
|
WindowsAdminExists = DoesPcAdminExists(archive),
|
|
WindowsContentExists = DoesWindowsContentExists(archive),
|
|
WindowsServerExists = DoesServerExists(archive),
|
|
};
|
|
// Console.WriteLine($"Contents of {archive}:");
|
|
// Console.WriteLine("----------------------------------");
|
|
//
|
|
// foreach (ZipArchiveEntry entry in archive.Entries)
|
|
// {
|
|
// // You can access properties like entry.Name, entry.FullName, entry.Length (uncompressed size), entry.CompressedLength
|
|
// Console.WriteLine($"Entry: {entry.FullName}");
|
|
// Console.WriteLine($" Uncompressed Size: {entry.Length} bytes");
|
|
// Console.WriteLine($" Compressed Size: {entry.CompressedLength} bytes");
|
|
// Console.WriteLine("----------------------------------");
|
|
// }
|
|
}
|
|
|
|
public static string ExtractZip(ZipArchive archive, string outputPath)
|
|
{
|
|
archive.ExtractToDirectory(outputPath);
|
|
return outputPath;
|
|
}
|
|
|
|
private static bool DoesPicoClientExists(ZipArchive archive)
|
|
{
|
|
return archive.Entries
|
|
.Any(entry => entry.Name.Contains("MetaforcePico")
|
|
&& entry.Name.EndsWith(".apk"));
|
|
}
|
|
|
|
private static bool DoesOculusClientExists(ZipArchive archive)
|
|
{
|
|
return archive.Entries
|
|
.Any(entry => entry.Name.Contains("MetaforceOculus")
|
|
&& entry.Name.EndsWith(".apk"));
|
|
}
|
|
|
|
private static bool DoesAndroidAdminExists(ZipArchive archive)
|
|
{
|
|
return archive.Entries
|
|
.Any(entry => entry.Name.Contains("MetaforceAdmin")
|
|
&& entry.Name.EndsWith(".apk"));
|
|
}
|
|
|
|
private static bool DoesAndroidContentExists(ZipArchive archive)
|
|
{
|
|
return archive.Entries
|
|
.Any(entry => entry.Name.Contains("Content_Android")
|
|
&& entry.Name.EndsWith(".zip"));
|
|
}
|
|
|
|
private static bool DoesWindowsContentExists(ZipArchive archive)
|
|
{
|
|
return archive.Entries
|
|
.Any(entry => entry.Name.Contains("Content_StandaloneWindows")
|
|
&& entry.Name.EndsWith(".zip"));
|
|
}
|
|
|
|
private static bool DoesPcAdminExists(ZipArchive archive)
|
|
{
|
|
return archive.Entries
|
|
.Any(entry => entry.FullName.Contains("MetaforceAdminPC")
|
|
&& entry.Name.EndsWith(".exe") && !entry.Name.Contains("UnityCrashHandler") &&
|
|
!entry.Name.Contains("crashpad_handler"));
|
|
}
|
|
|
|
private static bool DoesServerExists(ZipArchive archive)
|
|
{
|
|
return archive.Entries
|
|
.Any(entry => entry.FullName.Contains("MetaforceServer")
|
|
&& entry.Name.EndsWith(".exe") && !entry.Name.Contains("UnityCrashHandler") &&
|
|
!entry.Name.Contains("crashpad_handler"));
|
|
}
|
|
} |