From dc79b5bff7fb47853239ba33f07895979402a749 Mon Sep 17 00:00:00 2001 From: Joao Matos Date: Thu, 24 Apr 2014 14:47:58 +0100 Subject: [PATCH] Revert "Added System.IO.Compression implementation." This is currently breaking the build for Mono Droid. This reverts commit b175675ad9cf513f3ee3772091b3bfd02849213c. --- mcs/class/System.IO.Compression/Makefile | 5 +- .../System.IO.Compression.dll.sources | 46 +--- .../System.IO.Compression_test.dll.sources | 1 - .../Test/System.IO.Compression/ZipTest.cs | 226 ------------------ mcs/class/System.IO.Compression/ZipArchive.cs | 190 ++------------- .../System.IO.Compression/ZipArchiveEntry.cs | 80 ++----- mcs/class/System.IO.Compression/archive.zip | Bin 689 -> 0 bytes mcs/class/System.IO.Compression/create.zip | Bin 184 -> 0 bytes 8 files changed, 37 insertions(+), 511 deletions(-) delete mode 100644 mcs/class/System.IO.Compression/System.IO.Compression_test.dll.sources delete mode 100644 mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs delete mode 100644 mcs/class/System.IO.Compression/archive.zip delete mode 100644 mcs/class/System.IO.Compression/create.zip diff --git a/mcs/class/System.IO.Compression/Makefile b/mcs/class/System.IO.Compression/Makefile index f175e11c38c..91a8458ccf1 100644 --- a/mcs/class/System.IO.Compression/Makefile +++ b/mcs/class/System.IO.Compression/Makefile @@ -3,7 +3,8 @@ SUBDIRS = include ../../build/rules.make LIBRARY = System.IO.Compression.dll -LIB_MCS_FLAGS = /r:System /r:System.Core /nowarn:219 -TEST_MCS_FLAGS = /r:System /r:System.Core +LIB_MCS_FLAGS = /r:System + +NO_TEST = yes include ../../build/library.make diff --git a/mcs/class/System.IO.Compression/System.IO.Compression.dll.sources b/mcs/class/System.IO.Compression/System.IO.Compression.dll.sources index 6877d587626..051da23b8ca 100644 --- a/mcs/class/System.IO.Compression/System.IO.Compression.dll.sources +++ b/mcs/class/System.IO.Compression/System.IO.Compression.dll.sources @@ -1,51 +1,7 @@ - AssemblyInfo.cs TypeForwarders.cs ZipArchive.cs ZipArchiveEntry.cs ZipArchiveMode.cs ../../build/common/Consts.cs -../../build/common/MonoTODOAttribute.cs -Ionic/Common/CRC32.cs -Ionic/Common/Iso8859Dash1Encoding.cs -Ionic/Zip/EncryptionAlgorithm.cs -Ionic/Zip/Events.cs -Ionic/Zip/Exceptions.cs -Ionic/Zip/ExtractExistingFileAction.cs -Ionic/Zip/FileSelector.cs -Ionic/Zip/OffsetStream.cs -Ionic/Zip/Shared.cs -Ionic/Zip/ZipConstants.cs -Ionic/Zip/ZipCrypto.cs -Ionic/Zip/ZipDirEntry.cs -Ionic/Zip/ZipEntry.cs -Ionic/Zip/ZipEntry.Extract.cs -Ionic/Zip/ZipEntry.Read.cs -Ionic/Zip/ZipEntry.Write.cs -Ionic/Zip/ZipEntrySource.cs -Ionic/Zip/ZipErrorAction.cs -Ionic/Zip/ZipFile.AddUpdate.cs -Ionic/Zip/ZipFile.Check.cs -Ionic/Zip/ZipFile.cs -Ionic/Zip/ZipFile.Events.cs -Ionic/Zip/ZipFile.Extract.cs -Ionic/Zip/ZipFile.Read.cs -Ionic/Zip/ZipFile.Save.cs -Ionic/Zip/ZipFile.SaveSelfExtractor.cs -Ionic/Zip/ZipFile.Selector.cs -Ionic/Zip/ZipFile.x-IEnumerable.cs -Ionic/Zip/ZipInputStream.cs -Ionic/Zip/ZipOutputStream.cs -Ionic/Zip/ZipSegmentedStream.cs -Ionic/Zlib/Deflate.cs -Ionic/Zlib/DeflateStream.cs -Ionic/Zlib/GZipStream.cs -Ionic/Zlib/Inflate.cs -Ionic/Zlib/InfTree.cs -Ionic/Zlib/ParallelDeflateOutputStream.cs -Ionic/Zlib/Tree.cs -Ionic/Zlib/Zlib.cs -Ionic/Zlib/ZlibBaseStream.cs -Ionic/Zlib/ZlibCodec.cs -Ionic/Zlib/ZlibConstants.cs -Ionic/Zlib/ZlibStream.cs +../../build/common/MonoTODOAttribute.cs \ No newline at end of file diff --git a/mcs/class/System.IO.Compression/System.IO.Compression_test.dll.sources b/mcs/class/System.IO.Compression/System.IO.Compression_test.dll.sources deleted file mode 100644 index 2308abc6656..00000000000 --- a/mcs/class/System.IO.Compression/System.IO.Compression_test.dll.sources +++ /dev/null @@ -1 +0,0 @@ -System.IO.Compression/ZipTest.cs diff --git a/mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs b/mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs deleted file mode 100644 index 0c0e36886aa..00000000000 --- a/mcs/class/System.IO.Compression/Test/System.IO.Compression/ZipTest.cs +++ /dev/null @@ -1,226 +0,0 @@ -// -// ZipTests.cs -// -// Author: -// Joao Matos -// -// Copyright (c) 2013 Xamarin Inc. (http://www.xamarin.com) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -using System; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Security.Cryptography; -using NUnit.Framework; - -namespace MonoTests.System.IO.Compression -{ - [TestFixture] - public class ZipArchiveTests - { - static string GetSHA1HashFromFile(Stream stream) - { - using (var sha1 = SHA1.Create()) - { - return BitConverter.ToString(sha1.ComputeHash(stream)) - .Replace("-", string.Empty); - } - } - - [Test] - public void ZipGetEntryReadMode() - { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), - ZipArchiveMode.Read)) - { - var entry = archive.GetEntry("foo.txt"); - Assert.IsNotNull(entry); - - var nullEntry = archive.GetEntry("nonexisting"); - Assert.IsNull(nullEntry); - } - } - - [Test] - public void ZipGetEntryCreateMode() - { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), - ZipArchiveMode.Create)) - { - try { - archive.GetEntry("foo"); - } catch(NotSupportedException ex) { - return; - } - - Assert.Fail(); - } - } - - [Test] - public void ZipGetEntryUpdateMode() - { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), - ZipArchiveMode.Read)) - { - var entry = archive.GetEntry("foo.txt"); - Assert.IsNotNull(entry); - - var nullEntry = archive.GetEntry("nonexisting"); - Assert.IsNull(nullEntry); - } - } - - [Test] - public void ZipGetEntryOpen() - { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), - ZipArchiveMode.Read)) - { - var entry = archive.GetEntry("foo.txt"); - Assert.IsNotNull(entry); - - var foo = entry.Open(); - Assert.AreEqual("F1D2D2F924E986AC86FDF7B36C94BCDF32BEEC15", - GetSHA1HashFromFile(foo)); - } - } - - [Test] - public void ZipGetEntryDeleteReadMode() - { - File.Copy("archive.zip", "delete.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("delete.zip", FileMode.Open), - ZipArchiveMode.Update)) - { - var entry = archive.GetEntry("foo.txt"); - Assert.IsNotNull(entry); - - entry.Delete(); - } - - using (var archive = new ZipArchive(File.Open("delete.zip", FileMode.Open), - ZipArchiveMode.Read)) - { - var entry = archive.GetEntry("foo.txt"); - Assert.IsNull(entry); - } - } - - [Test] - public void ZipGetEntryDeleteUpdateMode() - { - File.Copy("archive.zip", "delete.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("delete.zip", FileMode.Open), - ZipArchiveMode.Update)) - { - var entry = archive.GetEntry("foo.txt"); - Assert.IsNotNull(entry); - - entry.Delete(); - } - - using (var archive = new ZipArchive(File.Open("delete.zip", FileMode.Open), - ZipArchiveMode.Read)) - { - var entry = archive.GetEntry("foo.txt"); - Assert.IsNull(entry); - } - } - - [Test] - public void ZipCreateArchive() - { - using (var archive = new ZipArchive(File.Open("create.zip", FileMode.Create), - ZipArchiveMode.Create)) - { - var entry = archive.CreateEntry("foo.txt"); - using (var stream = entry.Open()) - { - } - } - - using (var archive = new ZipArchive(File.Open("create.zip", FileMode.Open), - ZipArchiveMode.Read)) - { - var entry = archive.GetEntry("foo.txt"); - Assert.IsNotNull(entry); - } - } - - [Test] - public void ZipEnumerateEntriesReadMode() - { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), - ZipArchiveMode.Read)) - { - var entries = archive.Entries; - Assert.AreEqual(5, entries.Count); - - Assert.AreEqual("bar.txt", entries[0].FullName); - Assert.AreEqual("foo.txt", entries[1].FullName); - Assert.AreEqual("foobar/", entries[2].FullName); - Assert.AreEqual("foobar/bar.txt", entries[3].FullName); - Assert.AreEqual("foobar/foo.txt", entries[4].FullName); - } - } - - [Test] - public void ZipEnumerateEntriesUpdateMode() - { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), - ZipArchiveMode.Read)) - { - var entries = archive.Entries; - Assert.AreEqual(5, entries.Count); - - Assert.AreEqual("bar.txt", entries[0].FullName); - Assert.AreEqual("foo.txt", entries[1].FullName); - Assert.AreEqual("foobar/", entries[2].FullName); - Assert.AreEqual("foobar/bar.txt", entries[3].FullName); - Assert.AreEqual("foobar/foo.txt", entries[4].FullName); - } - } - - [Test] - public void ZipEnumerateEntriesCreateMode() - { - File.Copy("archive.zip", "test.zip", overwrite: true); - using (var archive = new ZipArchive(File.Open("test.zip", FileMode.Open), - ZipArchiveMode.Create)) - { - try { - archive.Entries.ToList(); - } catch(NotSupportedException ex) { - return; - } - - Assert.Fail(); - } - } - } -} diff --git a/mcs/class/System.IO.Compression/ZipArchive.cs b/mcs/class/System.IO.Compression/ZipArchive.cs index 841d1265bd4..c8f68f707f6 100644 --- a/mcs/class/System.IO.Compression/ZipArchive.cs +++ b/mcs/class/System.IO.Compression/ZipArchive.cs @@ -2,8 +2,7 @@ // ZipArchive.cs // // Author: -// Martin Baulig -// Joao Matos +// Martin Baulig // // Copyright (c) 2013 Xamarin Inc. (http://www.xamarin.com) // @@ -24,225 +23,74 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Linq; using System.Text; -using Ionic.Zip; namespace System.IO.Compression { + [MonoTODO] public class ZipArchive : IDisposable { - internal Stream stream; - internal readonly bool leaveStreamOpen; - internal readonly ZipArchiveMode mode; - internal Encoding entryNameEncoding; - internal bool disposed; - internal Dictionary entries; - internal ZipFile zipFile; - public ZipArchive (Stream stream) { - if (stream == null) - throw new ArgumentNullException("stream"); - - this.stream = stream; - mode = ZipArchiveMode.Read; - CreateZip(stream, mode); + throw new NotImplementedException (); } public ZipArchive (Stream stream, ZipArchiveMode mode) + : this (stream) { - if (stream == null) - throw new ArgumentNullException("stream"); - - this.stream = stream; - this.mode = mode; - CreateZip(stream, mode); } - public ZipArchive (Stream stream, ZipArchiveMode mode, bool leaveOpen) + public ZipArchive (Stream stream, ZipArchiveMode mode, + bool leaveOpen) + : this (stream, mode) { - if (stream == null) - throw new ArgumentNullException("stream"); - - this.stream = stream; - this.mode = mode; - this.leaveStreamOpen = leaveOpen; - CreateZip(stream, mode); } - public ZipArchive (Stream stream, ZipArchiveMode mode, bool leaveOpen, Encoding entryNameEncoding) + public ZipArchive (Stream stream, ZipArchiveMode mode, + bool leaveOpen, Encoding entryNameEncoding) + : this (stream, mode, leaveOpen) { - if (stream == null) - throw new ArgumentNullException("stream"); - - this.stream = stream; - this.mode = mode; - this.leaveStreamOpen = leaveOpen; - this.entryNameEncoding = entryNameEncoding; - CreateZip(stream, mode); - } - - private void CreateZip(Stream stream, ZipArchiveMode mode) - { - if (mode != ZipArchiveMode.Read && mode != ZipArchiveMode.Create && mode != ZipArchiveMode.Update) - throw new ArgumentOutOfRangeException("mode"); - - // If the mode parameter is set to Read, the stream must support reading. - if (mode == ZipArchiveMode.Read && !stream.CanRead) - throw new ArgumentException("Stream must support reading for Read archive mode"); - - // If the mode parameter is set to Create, the stream must support writing. - if (mode == ZipArchiveMode.Create && !stream.CanWrite) - throw new ArgumentException("Stream must support writing for Create archive mode"); - - // If the mode parameter is set to Update, the stream must support reading, writing, and seeking. - if (mode == ZipArchiveMode.Update && (!stream.CanRead || !stream.CanWrite || !stream.CanSeek)) - throw new ArgumentException("Stream must support reading, writing and seeking for Update archive mode"); - - try { - zipFile = new ZipFile(stream, (mode != ZipArchiveMode.Read) ? stream : null, leaveStreamOpen, - entryNameEncoding); - - if (stream.Length != 0) { - zipFile.FullScan = true; - zipFile.ReadToInstance(); - } - - if (mode == ZipArchiveMode.Create) - zipFile.Save(); - } catch (Exception) { - throw new InvalidDataException("The contents of the stream are not in the zip archive format."); - } - - entries = new Dictionary(); - if (Mode != ZipArchiveMode.Create) { - foreach (var entry in zipFile.Entries) { - var zipEntry = new ZipArchiveEntry(this, entry); - entries[entry.FileName] = zipEntry; - } - } } public ReadOnlyCollection Entries { get { - if (disposed) - throw new ObjectDisposedException("The zip archive has been disposed."); - - if (Mode == ZipArchiveMode.Create) - throw new NotSupportedException("Cannot access entries in Create mode."); - - if (zipFile == null) - throw new InvalidDataException("The zip archive is corrupt, and its entries cannot be retrieved."); - - if (entries == null) - return new ReadOnlyCollection(new List()); - - return new ReadOnlyCollection(entries.Values.ToList()); + throw new NotImplementedException (); } } public ZipArchiveMode Mode { get { - if (disposed) - throw new ObjectDisposedException("The zip archive has been disposed."); - - return mode; + throw new NotImplementedException (); } } public ZipArchiveEntry CreateEntry (string entryName) { - if (disposed) - throw new ObjectDisposedException("The zip archive has been disposed."); - - return CreateEntry(entryName, CompressionLevel.Optimal); + throw new NotImplementedException (); } public ZipArchiveEntry CreateEntry (string entryName, - CompressionLevel compressionLevel) + CompressionLevel compressionLevel) { - if (disposed) - throw new ObjectDisposedException("The zip archive has been disposed."); - - if (entryName == string.Empty) - throw new ArgumentException("Entry name cannot be empty."); - - if (entryName == null) - throw new ArgumentNullException("entryName"); - - if (mode != ZipArchiveMode.Create && mode != ZipArchiveMode.Update) - throw new NotSupportedException("The zip archive does not support writing."); - - if (zipFile == null) - throw new InvalidDataException("The zip archive is corrupt, and its entries cannot be retrieved."); - - var memoryStream = new MemoryStream(); - var entry = zipFile.AddEntry(entryName, memoryStream); - var archiveEntry = new ZipArchiveEntry(this, entry); - entries[entryName] = archiveEntry; - - return archiveEntry; + throw new NotImplementedException (); } public ZipArchiveEntry GetEntry (string entryName) { - if (disposed) - throw new ObjectDisposedException("The zip archive has been disposed."); - - if (entryName == string.Empty) - throw new ArgumentException("Entry name cannot be empty."); - - if (entryName == null) - throw new ArgumentNullException("entryName"); - - if (mode != ZipArchiveMode.Read && mode != ZipArchiveMode.Update) - throw new NotSupportedException("The zip archive does not support reading."); - - if (zipFile == null) - throw new InvalidDataException("The zip archive is corrupt, and its entries cannot be retrieved."); - - return entries.ContainsKey(entryName) ? entries[entryName] : null; - } - - private void Save() - { - // We save to a memory stream first because Ionic does not deal well - // with saving to a file that has previously been open before. - using (var newZip = new MemoryStream()) { - zipFile.Save(newZip); - - stream.Position = 0; - newZip.Position = 0; - newZip.CopyTo(stream); - } + throw new NotImplementedException (); } protected virtual void Dispose (bool disposing) { - if (disposed) - return; - - if (mode != ZipArchiveMode.Read) - Save(); - - disposed = true; - - if (leaveStreamOpen) - return; - - if (stream != null) { - stream.Dispose(); - stream = null; - } + throw new NotImplementedException (); } public void Dispose () { - Dispose(true); - GC.SuppressFinalize(this); + throw new NotImplementedException (); } } } diff --git a/mcs/class/System.IO.Compression/ZipArchiveEntry.cs b/mcs/class/System.IO.Compression/ZipArchiveEntry.cs index 13f0dddad41..a92de5aff84 100644 --- a/mcs/class/System.IO.Compression/ZipArchiveEntry.cs +++ b/mcs/class/System.IO.Compression/ZipArchiveEntry.cs @@ -2,8 +2,7 @@ // ZipArchiveEntry.cs // // Author: -// Joao Matos -// Martin Baulig +// Martin Baulig // // Copyright (c) 2013 Xamarin Inc. (http://www.xamarin.com) // @@ -24,101 +23,50 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. +using System; namespace System.IO.Compression { + [MonoTODO] public class ZipArchiveEntry { - readonly Ionic.Zip.ZipEntry entry; - private Stream openStream; - private bool wasDeleted; - - internal ZipArchiveEntry(ZipArchive archive, Ionic.Zip.ZipEntry entry) - { - if (archive == null) - throw new ArgumentNullException("archive"); - - if (entry == null) - throw new ArgumentNullException("entry"); - - this.Archive = archive; - this.entry = entry; - } - public ZipArchive Archive { get; private set; } public long CompressedLength { - get { - if (Archive.Mode == ZipArchiveMode.Create) - throw new InvalidOperationException("Property cannot be retrieved when the mode is set to Create"); - - return entry.CompressedSize; - } + get; + private set; } public string FullName { - get { return entry.FileName; } + get; + private set; } public DateTimeOffset LastWriteTime { - get { return entry.LastModified; } - set { entry.LastModified = value.DateTime; } + get; set; } public long Length { - get { - if (Archive.Mode == ZipArchiveMode.Create) - throw new InvalidOperationException("Property cannot be retrieved when the mode is set to Create"); - - return entry.UncompressedSize; - } + get; + private set; } public string Name { - get { return Path.GetFileName(entry.FileName); } + get; + private set; } public void Delete () { - if (Archive.disposed) - throw new ObjectDisposedException("The zip archive for this entry has been disposed."); - - if (Archive.Mode != ZipArchiveMode.Update) - throw new NotSupportedException("The zip archive for this entry was opened in a mode other than Update."); - - if (openStream != null) - throw new IOException("The entry is already open for reading or writing."); - - wasDeleted = true; - Archive.zipFile.RemoveEntry(entry.FileName); + throw new NotImplementedException (); } public Stream Open () { - if (Archive.disposed) - throw new ObjectDisposedException("The zip archive for this entry has been disposed."); - - if (openStream != null && Archive.Mode == ZipArchiveMode.Update) - throw new IOException("The entry is already currently open for writing."); - - if (wasDeleted) - throw new IOException("The entry has been deleted from the archive."); - - if (Archive.Mode == ZipArchiveMode.Create && openStream != null) - throw new IOException("The archive for this entry was opened with the Create mode, and this entry has already been written to."); - - var memoryStream = new MemoryStream(); - openStream = memoryStream; - - if (Archive.Mode == ZipArchiveMode.Read || Archive.Mode == ZipArchiveMode.Update) - entry.Extract(memoryStream); - - memoryStream.Seek(0, SeekOrigin.Begin); - - return memoryStream; + throw new NotImplementedException (); } } } diff --git a/mcs/class/System.IO.Compression/archive.zip b/mcs/class/System.IO.Compression/archive.zip deleted file mode 100644 index 91ba947a36e077602bd5c447b537db912cd0a40e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 689 zcmWIWW@h1H0D;twY!@&CO0Wazq{Je!MG0V$9= z5ugYI!}=MRh5;1-&C^F12C{Kg&;K%*VSEt7K#HIi11W@Zbi0w1BRheS$({k1k5s^p zV_;B#(ok!-paP5x5)4W^n~rQEg F1^_2UkHY`} diff --git a/mcs/class/System.IO.Compression/create.zip b/mcs/class/System.IO.Compression/create.zip deleted file mode 100644 index fba5d61f55b678159ddd6d8b04b971e931e71a9a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 184 zcmWIWW@Zs#00G6aJQpwnO0YAiFr?+@>y=cLa4{%=1sNG682sl+c1^KA&xlS3cr!BT aGT=4}*=PpR3}$5mX=Vh%NFePAHVFXoLLVdm -- 2.25.1