diff --git a/CompressionMethod.cs b/CompressionMethod.cs
index 349a77b2..11717fe9 100644
--- a/CompressionMethod.cs
+++ b/CompressionMethod.cs
@@ -121,6 +121,26 @@ public enum CompressionMethod : short
///
LZ77 = 19,
+ ///
+ /// LZMA2 Compressed data
+ ///
+ LZMA2 = 33,
+
+ ///
+ /// Zstandard compressed data
+ ///
+ ZSTD = 93,
+
+ ///
+ /// XZ compressed data
+ ///
+ XZ = 95,
+
+ ///
+ /// Compressed Jpeg data
+ ///
+ JPEG = 96,
+
///
/// WavPack compressed data
///
diff --git a/LibZipSharp.UnitTest/LibZipSharp.UnitTest.csproj b/LibZipSharp.UnitTest/LibZipSharp.UnitTest.csproj
index 10877ded..6db34362 100644
--- a/LibZipSharp.UnitTest/LibZipSharp.UnitTest.csproj
+++ b/LibZipSharp.UnitTest/LibZipSharp.UnitTest.csproj
@@ -29,6 +29,9 @@
libzip.dll
PreserveNewest
+
+ PreserveNewest
+
diff --git a/LibZipSharp.UnitTest/ZipTests.cs b/LibZipSharp.UnitTest/ZipTests.cs
index 50721ff2..5cbc8fed 100644
--- a/LibZipSharp.UnitTest/ZipTests.cs
+++ b/LibZipSharp.UnitTest/ZipTests.cs
@@ -192,6 +192,44 @@ public void SmallTextFile ()
}
}
+ [Test]
+ public void UpdateEntryCompressionMethod ()
+ {
+ var zipStream = new MemoryStream ();
+ var encoding = Encoding.UTF8;
+ using (var zip = ZipArchive.Create (zipStream)) {
+ zip.AddEntry ("foo", "bar", encoding, CompressionMethod.Deflate);
+ }
+ using (var zip = ZipArchive.Open (zipStream)) {
+ var entry = zip.ReadEntry ("foo");
+ Assert.IsNotNull (entry, "Entry 'foo' should exist!");
+ AssertEntryIsValid (entry, "foo", compression: CompressionMethod.Deflate);
+ using (var stream = new MemoryStream ()) {
+ entry.Extract (stream);
+ stream.Position = 0;
+ Assert.AreEqual ("bar", encoding.GetString (stream.ToArray ()));
+ }
+ zip.AddEntry ("foo", "foo", encoding, CompressionMethod.Store);
+ entry = zip.ReadEntry ("foo");
+ AssertEntryIsValid (entry, "foo", compression: CompressionMethod.Store);
+ }
+ }
+
+ [Test]
+ public void CheckForUnknownCompressionMethods ()
+ {
+ string filePath = Path.GetFullPath ("packaged_resources");
+ if (!File.Exists (filePath)) {
+ filePath = Path.GetFullPath (Path.Combine ("LibZipSharp.UnitTest", "packaged_resources"));
+ }
+ using (var zip = ZipArchive.Open (filePath, FileMode.Open)) {
+ foreach (var e in zip) {
+ Console.WriteLine ($"{e.FullName} is {e.CompressionMethod}");
+ Assert.AreNotEqual (CompressionMethod.Unknown, e.CompressionMethod, "Compression Method should not be Unknown.");
+ }
+ }
+ }
+
[TestCase (false)]
[TestCase (true)]
public void EnumerateSkipDeletedEntries (bool deleteFromExistingFile)
diff --git a/LibZipSharp.UnitTest/packaged_resources b/LibZipSharp.UnitTest/packaged_resources
new file mode 100644
index 00000000..699e517c
Binary files /dev/null and b/LibZipSharp.UnitTest/packaged_resources differ
diff --git a/LibZipSharp.props b/LibZipSharp.props
index 56c87a1e..a6825f42 100644
--- a/LibZipSharp.props
+++ b/LibZipSharp.props
@@ -1,5 +1,5 @@
- <_LibZipSharpNugetVersion>1.0.21
+ <_LibZipSharpNugetVersion>1.0.22
diff --git a/Native.cs b/Native.cs
index 6876beab..4a097509 100644
--- a/Native.cs
+++ b/Native.cs
@@ -47,17 +47,28 @@ public struct zip_source_args_seek_t
public int whence;
};
+ [StructLayout(LayoutKind.Explicit)]
public struct zip_stat_t
{
+ [FieldOffset (0)]
public UInt64 valid; /* which fields have valid values */
+ [FieldOffset (8)]
public IntPtr name; /* name of the file (char *) */
+ [FieldOffset (16)]
public UInt64 index; /* index within archive */
+ [FieldOffset (24)]
public UInt64 size; /* size of file (uncompressed) */
+ [FieldOffset (32)]
public UInt64 comp_size; /* size of file (compressed) */
+ [FieldOffset (40)]
public IntPtr mtime; /* modification time (time_t) */
+ [FieldOffset (48)]
public UInt32 crc; /* crc of file data */
+ [FieldOffset (52)]
public Int16 comp_method; /* compression method used */
+ [FieldOffset (56)]
public UInt16 encryption_method; /* encryption method used */
+ [FieldOffset (60)]
public UInt32 flags; /* reserved for future use */
};