public Stream GetInputStream(long entryIndex) {
if (isDisposed_) {
throw new ObjectDisposedException("ZipFile");
}
long start=LocateEntry(entries_[entryIndex]);
CompressionMethod method=entries_[entryIndex].CompressionMethod;
Stream result=new PartialInputStream(this, start, entries_[entryIndex].CompressedSize);
if (entries_[entryIndex].IsCrypted) {
result=CreateAndInitDecryptionStream(result, entries_[entryIndex]);
if (result==null) {
throw new ZipException("Unable to decrypt this entry");
}
}
switch (method) {
case CompressionMethod.Stored:
// read as is.
break;
case CompressionMethod.Deflated:
// No need to worry about ownership and closing as underlying stream close does nothing.
result=new InflaterInputStream(result, new Inflater(true));
break;
default:
throw new ZipException("Unsupported compression method "+method);
}
return result;
}