From 4983606cb565b15f8ffad63d0dc8207071f281d8 Mon Sep 17 00:00:00 2001 From: Christian Engelhardt Date: Sun, 3 Mar 2024 15:02:51 +0100 Subject: [PATCH] change NuGet package for zip files again --- libNOM.test/Common.cs | 59 +++++++++++++++++++++++++++++++--- libNOM.test/libNOM.test.csproj | 1 + 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/libNOM.test/Common.cs b/libNOM.test/Common.cs index 0aa5c2d..0b3c293 100644 --- a/libNOM.test/Common.cs +++ b/libNOM.test/Common.cs @@ -1,11 +1,12 @@ using System.Text; -using Aspose.Zip; - using libNOM.io; using Microsoft.VisualStudio.TestTools.UnitTesting; +using SharpCompress.Archives; +using SharpCompress.Common; + namespace libNOM.test; @@ -200,11 +201,59 @@ public void ExtractArchive() if (!Directory.Exists(template)) { - using var zipArchive = new Archive($"{nameof(Properties.Resources.TESTSUITE_ARCHIVE)}.zip", new ArchiveLoadOptions() + //using SharpCompress.Archives; + //using SharpCompress.Common; + Directory.CreateDirectory(template); + using var zipArchive = ArchiveFactory.Open($"{nameof(Properties.Resources.TESTSUITE_ARCHIVE)}.zip", new() { - DecryptionPassword = Properties.Resources.TESTSUITE_PASSWORD, + Password = Properties.Resources.TESTSUITE_PASSWORD, }); - zipArchive.ExtractToDirectory(template); + foreach (var entry in zipArchive.Entries) + { + if (entry.IsDirectory) + continue; + + entry.WriteToDirectory(template, new ExtractionOptions + { + ExtractFullPath = true, + Overwrite = true, + }); + } + + //using ICSharpCode.SharpZipLib.Zip; + //using var zipArchive = new ZipFile($"{nameof(Properties.Resources.TESTSUITE_ARCHIVE)}.zip") + //{ + // Password = Properties.Resources.TESTSUITE_PASSWORD, + //}; + //foreach (ZipEntry entry in zipArchive) + // if (entry.IsFile) + // { + // string outputFile = Path.Combine(template, entry.Name); + + // Directory.CreateDirectory(Path.GetDirectoryName(outputFile)!); + + // using var input = zipArchive.GetInputStream(entry); + // using var output = File.Create(outputFile); + // var buffer = new byte[4096]; + // int bytesRead; + // while ((bytesRead = input.Read(buffer, 0, buffer.Length)) > 0) + // output.Write(buffer, 0, bytesRead); + // } + + //using Aspose.Zip; + //using var zipArchive = new Archive($"{nameof(Properties.Resources.TESTSUITE_ARCHIVE)}.zip", new ArchiveLoadOptions() + //{ + // DecryptionPassword = Properties.Resources.TESTSUITE_PASSWORD, + //}); + //zipArchive.ExtractToDirectory(template); + + //using Ionic.Zip; + //using var zipArchive = new ZipFile($"{nameof(Properties.Resources.TESTSUITE_ARCHIVE)}.zip") + //{ + // Encryption = EncryptionAlgorithm.WinZipAes256, + // Password = Properties.Resources.TESTSUITE_PASSWORD, + //}; + //zipArchive.ExtractAll(template, ExtractExistingFileAction.DoNotOverwrite); } if (!Directory.Exists(working)) { diff --git a/libNOM.test/libNOM.test.csproj b/libNOM.test/libNOM.test.csproj index b1e0f4b..931afc9 100644 --- a/libNOM.test/libNOM.test.csproj +++ b/libNOM.test/libNOM.test.csproj @@ -27,6 +27,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive +