diff --git a/MetaforceInstaller.Core/Models/InstallationData.cs b/MetaforceInstaller.Core/Models/InstallationData.cs new file mode 100644 index 0000000..855fae7 --- /dev/null +++ b/MetaforceInstaller.Core/Models/InstallationData.cs @@ -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; } +} \ No newline at end of file diff --git a/MetaforceInstaller.Core/Models/InstallationParts.cs b/MetaforceInstaller.Core/Models/InstallationParts.cs new file mode 100644 index 0000000..cb531ab --- /dev/null +++ b/MetaforceInstaller.Core/Models/InstallationParts.cs @@ -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; } +} \ No newline at end of file diff --git a/MetaforceInstaller.Core/Services/ZipScrapper.cs b/MetaforceInstaller.Core/Services/ZipScrapper.cs new file mode 100644 index 0000000..b5d1a32 --- /dev/null +++ b/MetaforceInstaller.Core/Services/ZipScrapper.cs @@ -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")); + } +} \ No newline at end of file