split installation info to parts
This commit is contained in:
parent
c29658e7e4
commit
3dc9c8c279
3 changed files with 111 additions and 0 deletions
10
MetaforceInstaller.Core/Models/InstallationData.cs
Normal file
10
MetaforceInstaller.Core/Models/InstallationData.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
namespace MetaforceInstaller.Core.Models;
|
||||||
|
|
||||||
|
public class InstallationData
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; } = Guid.NewGuid();
|
||||||
|
public string Title { get; set; }
|
||||||
|
public string AndroidPackagePath { get; set; }
|
||||||
|
public string WindowsServerPackagePath { get; set; }
|
||||||
|
public string WindowsAdminPackagePath { get; set; }
|
||||||
|
}
|
||||||
12
MetaforceInstaller.Core/Models/InstallationParts.cs
Normal file
12
MetaforceInstaller.Core/Models/InstallationParts.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
namespace MetaforceInstaller.Core.Models;
|
||||||
|
|
||||||
|
public record InstallationParts
|
||||||
|
{
|
||||||
|
public bool OculusClientExists { get; init; }
|
||||||
|
public bool PicoClientExists { get; init; }
|
||||||
|
public bool AndroidAdminExists { get; init; }
|
||||||
|
public bool AndroidContentExists { get; init; }
|
||||||
|
public bool WindowsContentExists { get; init; }
|
||||||
|
public bool WindowsAdminExists { get; init; }
|
||||||
|
public bool WindowsServerExists { get; init; }
|
||||||
|
}
|
||||||
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