split installation info to parts
This commit is contained in:
parent
c29658e7e4
commit
3dc9c8c279
3 changed files with 111 additions and 0 deletions
89
MetaforceInstaller.Core/Services/ZipScrapper.cs
Normal file
89
MetaforceInstaller.Core/Services/ZipScrapper.cs
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
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"));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue