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
-
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
+++ /dev/null
-System.IO.Compression/ZipTest.cs
+++ /dev/null
-//
-// ZipTests.cs
-//
-// Author:
-// Joao Matos <joao.matos@xamarin.com>
-//
-// 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();
- }
- }
- }
-}
// ZipArchive.cs
//
// Author:
-// Martin Baulig <martin.baulig@xamarin.com>
-// Joao Matos <joao.matos@xamarin.com>
+// Martin Baulig <martin.baulig@xamarin.com>
//
// Copyright (c) 2013 Xamarin Inc. (http://www.xamarin.com)
//
// 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<string, ZipArchiveEntry> 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<string, ZipArchiveEntry>();
- if (Mode != ZipArchiveMode.Create) {
- foreach (var entry in zipFile.Entries) {
- var zipEntry = new ZipArchiveEntry(this, entry);
- entries[entry.FileName] = zipEntry;
- }
- }
}
public ReadOnlyCollection<ZipArchiveEntry> 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<ZipArchiveEntry>(new List<ZipArchiveEntry>());
-
- return new ReadOnlyCollection<ZipArchiveEntry>(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 ();
}
}
}
// ZipArchiveEntry.cs
//
// Author:
-// Joao Matos <joao.matos@xamarin.com>
-// Martin Baulig <martin.baulig@xamarin.com>
+// Martin Baulig <martin.baulig@xamarin.com>
//
// Copyright (c) 2013 Xamarin Inc. (http://www.xamarin.com)
//
// 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 ();
}
}
}