// ZipArchiveEntry.cs
//
// Author:
-// Joao Matos <joao.matos@xamarin.com>
-// 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)
//
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
+using SharpCompress.Archive;
+
namespace System.IO.Compression
{
public class ZipArchiveEntry
{
- readonly Ionic.Zip.ZipEntry entry;
+ readonly SharpCompress.Archive.Zip.ZipArchiveEntry entry;
private Stream openStream;
private bool wasDeleted;
- internal ZipArchiveEntry(ZipArchive archive, Ionic.Zip.ZipEntry entry)
+ internal ZipArchiveEntry(ZipArchive archive, SharpCompress.Archive.Zip.ZipArchiveEntry entry)
{
if (archive == null)
throw new ArgumentNullException("archive");
if (entry == null)
throw new ArgumentNullException("entry");
- this.Archive = archive;
+ Archive = archive;
this.entry = entry;
}
}
public string FullName {
- get { return entry.FileName; }
+ get { return entry.Key; }
}
public DateTimeOffset LastWriteTime {
- get { return entry.LastModified; }
- set { entry.LastModified = value.DateTime; }
+ get { return entry.LastModifiedTime.GetValueOrDefault(); }
+ set { entry.LastModifiedTime = value.DateTime; }
}
public long Length {
if (Archive.Mode == ZipArchiveMode.Create)
throw new InvalidOperationException("Property cannot be retrieved when the mode is set to Create");
- return entry.UncompressedSize;
+ return entry.Size;
}
}
public string Name {
- get { return Path.GetFileName(entry.FileName); }
+ get { return Path.GetFileName(entry.Key); }
}
- public void Delete ()
+ public void Delete()
{
if (Archive.disposed)
throw new ObjectDisposedException("The zip archive for this entry has been disposed.");
- if (Archive.Mode != ZipArchiveMode.Update)
+ 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.");
+ throw new IOException("The entry is already open for reading or writing.");
wasDeleted = true;
- Archive.zipFile.RemoveEntry(entry.FileName);
+ Archive.zipFile.RemoveEntry(entry);
}
- public Stream Open ()
+ public Stream Open()
{
if (Archive.disposed)
throw new ObjectDisposedException("The zip archive for this entry has been disposed.");
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);
+ openStream = entry.OpenEntryStream();
- return memoryStream;
+ return openStream;
}
}
}