diff --git a/FORMATS.md b/FORMATS.md index 350b9027..09d5ae63 100644 --- a/FORMATS.md +++ b/FORMATS.md @@ -22,7 +22,7 @@ | LZip (single file) (5) | LZip (LZMA) | Both | LZipArchive | LZipReader | LZipWriter | 1. SOLID Rars are only supported in the RarReader API. - 2. Zip format supports pkware and WinzipAES encryption. However, encrypted LZMA is not supported. Zip64 reading is supported. + 2. Zip format supports pkware and WinzipAES encryption. However, encrypted LZMA is not supported. Zip64 reading/writing is supported but only with seekable streams as the Zip spec doesn't support Zip64 data in post data descriptors. 3. The Tar format requires a file size in the header. If no size is specified to the TarWriter and the stream is not seekable, then an exception will be thrown. 4. The 7Zip format doesn't allow for reading as a forward-only stream so 7Zip is only supported through the Archive API 5. LZip has no support for extra data like the file name or timestamp. There is a default filename used when looking at the entry Key on the archive. diff --git a/src/SharpCompress/Writers/Zip/ZipCentralDirectoryEntry.cs b/src/SharpCompress/Writers/Zip/ZipCentralDirectoryEntry.cs index 0f18e813..39e488df 100644 --- a/src/SharpCompress/Writers/Zip/ZipCentralDirectoryEntry.cs +++ b/src/SharpCompress/Writers/Zip/ZipCentralDirectoryEntry.cs @@ -59,8 +59,8 @@ namespace SharpCompress.Writers.Zip } } - //constant sig, then version made by, compabitility, then version to extract - outputStream.Write(new byte[] { 80, 75, 1, 2, 0x14, 0, version, 0 }, 0, 8); + //constant sig, then version made by, then version to extract + outputStream.Write(new byte[] { 80, 75, 1, 2, version, 0, version, 0 }, 0, 8); outputStream.Write(DataConverter.LittleEndian.GetBytes((ushort)flags), 0, 2); outputStream.Write(DataConverter.LittleEndian.GetBytes((ushort)compression), 0, 2); // zipping method diff --git a/src/SharpCompress/Writers/Zip/ZipWriter.cs b/src/SharpCompress/Writers/Zip/ZipWriter.cs index b908df5e..3e981a01 100644 --- a/src/SharpCompress/Writers/Zip/ZipWriter.cs +++ b/src/SharpCompress/Writers/Zip/ZipWriter.cs @@ -30,6 +30,10 @@ namespace SharpCompress.Writers.Zip { zipComment = zipWriterOptions.ArchiveComment ?? string.Empty; isZip64 = zipWriterOptions.UseZip64; + if (destination.CanSeek) + { + streamPosition = destination.Position; + } compressionType = zipWriterOptions.CompressionType; compressionLevel = zipWriterOptions.DeflateCompressionLevel; @@ -207,14 +211,6 @@ namespace SharpCompress.Writers.Zip OutputStream.Write(DataConverter.LittleEndian.GetBytes(uncompressed), 0, 4); } - private void WritePostdataDescriptor(uint crc, ulong compressed, ulong uncompressed) - { - OutputStream.Write(DataConverter.LittleEndian.GetBytes(ZipHeaderFactory.POST_DATA_DESCRIPTOR), 0, 4); - OutputStream.Write(DataConverter.LittleEndian.GetBytes(crc), 0, 4); - OutputStream.Write(DataConverter.LittleEndian.GetBytes((uint)compressed), 0, 4); - OutputStream.Write(DataConverter.LittleEndian.GetBytes((uint)uncompressed), 0, 4); - } - private void WriteEndRecord(ulong size) { byte[] encodedComment = ArchiveEncoding.Default.GetBytes(zipComment); diff --git a/tests/SharpCompress.Test/Zip/Zip64Tests.cs b/tests/SharpCompress.Test/Zip/Zip64Tests.cs index 07955304..ffa2859b 100644 --- a/tests/SharpCompress.Test/Zip/Zip64Tests.cs +++ b/tests/SharpCompress.Test/Zip/Zip64Tests.cs @@ -21,7 +21,6 @@ namespace SharpCompress.Test.Zip // 4GiB + 1 const long FOUR_GB_LIMIT = ((long)uint.MaxValue) + 1; - [Fact(Skip = "Takes too long")] [Trait("format", "zip64")] public void Zip64_Single_Large_File() { @@ -29,7 +28,6 @@ namespace SharpCompress.Test.Zip RunSingleTest(1, FOUR_GB_LIMIT, set_zip64: true, forward_only: false); } - [Fact(Skip = "Takes too long")] [Trait("format", "zip64")] public void Zip64_Two_Large_Files() { @@ -37,7 +35,6 @@ namespace SharpCompress.Test.Zip RunSingleTest(2, FOUR_GB_LIMIT, set_zip64: true, forward_only: false); } - [Fact(Skip = "Takes too long")] [Trait("format", "zip64")] public void Zip64_Two_Small_files() { @@ -45,7 +42,6 @@ namespace SharpCompress.Test.Zip RunSingleTest(2, FOUR_GB_LIMIT / 2, set_zip64: false, forward_only: false); } - [Fact(Skip = "Takes too long")] [Trait("format", "zip64")] public void Zip64_Two_Small_files_stream() { @@ -53,7 +49,6 @@ namespace SharpCompress.Test.Zip RunSingleTest(2, FOUR_GB_LIMIT / 2, set_zip64: false, forward_only: true); } - [Fact(Skip = "Takes too long")] [Trait("format", "zip64")] public void Zip64_Two_Small_Files_Zip64() { @@ -61,7 +56,6 @@ namespace SharpCompress.Test.Zip RunSingleTest(2, FOUR_GB_LIMIT / 2, set_zip64: true, forward_only: false); } - [Fact(Skip = "Takes too long")] [Trait("format", "zip64")] public void Zip64_Single_Large_File_Fail() { @@ -76,7 +70,6 @@ namespace SharpCompress.Test.Zip } } - [Fact(Skip = "Takes too long")] [Trait("zip64", "true")] public void Zip64_Single_Large_File_Zip64_Streaming_Fail() { @@ -91,7 +84,6 @@ namespace SharpCompress.Test.Zip } } - [Fact(Skip = "Takes too long")] [Trait("zip64", "true")] public void Zip64_Single_Large_File_Streaming_Fail() {