Imported Upstream version 4.4.0.40

Former-commit-id: 6427cc082e74df30afc535fd906a3494b74b0817
This commit is contained in:
Xamarin Public Jenkins
2016-03-16 12:38:19 -04:00
parent f3e3aab35a
commit a632333cc7
110 changed files with 1496 additions and 556 deletions

View File

@ -29,10 +29,96 @@ using SharpCompress.Archive;
namespace System.IO.Compression
{
internal class ZipArchiveEntryStream : Stream, IDisposable
{
private readonly ZipArchiveEntry entry;
private readonly Stream stream;
public override bool CanRead {
get {
return stream.CanRead;
}
}
public override bool CanSeek {
get {
return stream.CanSeek;
}
}
public override bool CanWrite {
get {
return stream.CanWrite;
}
}
public override long Length {
get {
return stream.Length;
}
}
public override long Position {
get {
return stream.Position;
}
set {
stream.Position = value;
}
}
public ZipArchiveEntryStream(ZipArchiveEntry entry, Stream stream)
{
this.entry = entry;
this.stream = stream;
}
public override void Flush ()
{
stream.Flush();
}
public override long Seek (long offset, SeekOrigin origin)
{
return stream.Seek(offset, origin);
}
public override void SetLength (long value)
{
stream.SetLength(value);
}
public override int Read (byte[] buffer, int offset, int count)
{
return stream.Read(buffer, offset, count);
}
public override void Write (byte[] buffer, int offset, int count)
{
stream.Write(buffer, offset, count);
}
public new void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
base.Dispose();
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
entry.openStream = null;
stream.Dispose();
}
}
}
public class ZipArchiveEntry
{
readonly SharpCompress.Archive.Zip.ZipArchiveEntry entry;
private Stream openStream;
internal ZipArchiveEntryStream openStream;
private bool wasDeleted;
internal ZipArchiveEntry(ZipArchive archive, SharpCompress.Archive.Zip.ZipArchiveEntry entry)
@ -112,7 +198,7 @@ namespace System.IO.Compression
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.");
openStream = entry.OpenEntryStream();
openStream = new ZipArchiveEntryStream(this, entry.OpenEntryStream());
return openStream;
}