Imported Upstream version 4.4.2.4

Former-commit-id: 92904c9c5915c37244316e42ba99e7b934ed7ee2
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2016-07-21 09:40:10 +00:00
parent 589d484eee
commit 0b4a830db1
343 changed files with 9849 additions and 688 deletions

View File

@@ -82,10 +82,14 @@ namespace SharpCompress.Archive
{
key = key.Substring(1);
}
// .NET allows duplicate entries when saving and loading Zip files.
// The following lines are disabled from upstream SharpCompress to allow this.
#if ZIP_ALLOW_DUPLICATE_KEYS
if (DoesKeyMatchExisting(key))
{
throw new ArchiveException("Cannot add entry with duplicate key: " + key);
}
#endif
var entry = CreateEntry(key, source, size, modified, closeStream);
newEntries.Add(entry);
RebuildModifiedCollection();
@@ -101,7 +105,8 @@ namespace SharpCompress.Archive
{
p = p.Substring(1);
}
return string.Equals(p, key, StringComparison.OrdinalIgnoreCase);
if (string.Equals(p, key, StringComparison.OrdinalIgnoreCase))
return true;
}
return false;
}

View File

@@ -32,5 +32,10 @@ namespace SharpCompress.Archive.Zip
{
get { return (Parts.Single() as SeekableZipFilePart).Comment; }
}
public override string ToString()
{
return this.Key;
}
}
}

View File

@@ -16,6 +16,13 @@ namespace SharpCompress.Common.Zip
this.filePart = filePart;
lastModifiedTime = Utility.DosDateToDateTime(filePart.Header.LastModifiedDate,
filePart.Header.LastModifiedTime);
if (lastModifiedTime == default(DateTime))
{
// On .NET on Windows, for zip entries that don't have a last write time,
// the return value for ZipArchiveEntry.LastWriteTime is:
// 1/1/1980 12:00:00 AM, Ticks=624511296000000000
lastModifiedTime = new DateTime(624511296000000000);
}
}
}

View File

@@ -16,6 +16,7 @@ namespace SharpCompress.IO
{
stream.Position = origin.Value;
}
length = bytesToRead;
BytesLeftToRead = bytesToRead;
}
@@ -27,6 +28,8 @@ namespace SharpCompress.IO
}
}
private long length;
private long BytesLeftToRead { get; set; }
public Stream Stream { get; private set; }
@@ -53,12 +56,12 @@ namespace SharpCompress.IO
public override long Length
{
get { throw new System.NotImplementedException(); }
get { return length; }
}
public override long Position
{
get { throw new System.NotImplementedException(); }
get { return Length - BytesLeftToRead; }
set { throw new System.NotImplementedException(); }
}