using System.Reflection; using SevenZip; namespace WarcViewerBlazorWinForm.Backend.IO.Archiving { internal static class SevenZipSharpWrapper { static SevenZipSharpWrapper() { // Toggle between the x86 and x64 bit dll var path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Environment.Is64BitProcess ? "x64" : "x86", "7z.dll"); SevenZipBase.SetLibraryPath(path); } // public static void WriteXz(string outputFilePath, Stream inputStream) // { // if (File.Exists(outputFilePath)) throw new IOException("Output file already exist"); // var compressor = new SevenZipCompressor // { // CompressionLevel = CompressionLevel.Ultra, // CompressionMethod = CompressionMethod.Lzma2, // ArchiveFormat = OutArchiveFormat.XZ, // CompressionMode = CompressionMode.Create, // }; // var outputMs = new MemoryStream(); // compressor.CompressStream(inputStream, outputMs); // var bytes = outputMs.ToArray(); // File.WriteAllBytes(outputFilePath, bytes); // } // public static byte[] ReadXz(string inputFilePath) // { // var ms = new MemoryStream(); // var extractor = new SevenZipExtractor(inputFilePath); // extractor.ExtractFile(0, ms); // return ms.ToArray(); // } } }