using System; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; using Wabbajack.Common; using Wabbajack.Common.FileSignatures; using Wabbajack.VirtualFileSystem.SevenZipExtractor; namespace Wabbajack.VirtualFileSystem { public static class FileExtractor2 { public static readonly SignatureChecker ArchiveSigs = new SignatureChecker(Definitions.FileType.TES3, Definitions.FileType.BSA, Definitions.FileType.BA2, Definitions.FileType.ZIP, Definitions.FileType.EXE, Definitions.FileType.RAR, Definitions.FileType._7Z); public static async Task> GatheringExtract(IStreamFactory sFn, Predicate shouldExtract, Func> mapfn) { await using var archive = await sFn.GetStream(); var sig = await ArchiveSigs.MatchesAsync(archive); archive.Position = 0; switch (sig) { case Definitions.FileType.ZIP: return await GatheringExtractWith7Zip(archive, (Definitions.FileType)sig, shouldExtract, mapfn); default: throw new Exception("Invalid file format"); } } private static async Task> GatheringExtractWith7Zip(Stream stream, Definitions.FileType sig, Predicate shouldExtract, Func> mapfn) { return await new GatheringExtractor(stream, sig, shouldExtract, mapfn).Extract(); } } }