Revert commit that caused all non-zip files to be read entirely upon
opening.
IsZipArchive() would read and process the entire file looking for a zip
header.
This commit is contained in:
benshoof
2015-12-15 07:28:50 -09:00
parent ce6e1d26f4
commit 231b78e096
3 changed files with 13 additions and 12 deletions

View File

@@ -116,7 +116,7 @@ namespace SharpCompress.Archive.Zip
try
{
ZipHeader header =
headerFactory.ReadStreamHeader(stream).FirstOrDefault(x => x != null && x.ZipHeaderType != ZipHeaderType.Split);
headerFactory.ReadStreamHeader(stream).FirstOrDefault(x => x.ZipHeaderType != ZipHeaderType.Split);
if (header == null)
{
return false;

View File

@@ -45,17 +45,18 @@ namespace SharpCompress.Common.Zip
lastEntryHeader = null;
uint headerBytes = reader.ReadUInt32();
header = ReadHeader(headerBytes, reader);
if (header != null) {
// entry could be zero bytes so we need to know that.
if(header.ZipHeaderType == ZipHeaderType.LocalEntry) {
bool isRecording = rewindableStream.IsRecording;
if (!isRecording) {
rewindableStream.StartRecording();
}
uint nextHeaderBytes = reader.ReadUInt32();
header.HasData = !IsHeader(nextHeaderBytes);
rewindableStream.Rewind(!isRecording);
//entry could be zero bytes so we need to know that.
if (header.ZipHeaderType == ZipHeaderType.LocalEntry)
{
bool isRecording = rewindableStream.IsRecording;
if (!isRecording)
{
rewindableStream.StartRecording();
}
uint nextHeaderBytes = reader.ReadUInt32();
header.HasData = !IsHeader(nextHeaderBytes);
rewindableStream.Rewind(!isRecording);
}
yield return header;
}

View File

@@ -87,7 +87,7 @@ namespace SharpCompress.Common.Zip
return entry;
}
default:
return null;
throw new NotSupportedException("Unknown header: " + headerBytes);
}
}