Fingerprint_Card
Loading...
Searching...
No Matches
ICSharpCode.SharpZipLib.Zip.ZipInputStream Class Reference

This is an InflaterInputStream that reads the files baseInputStream an zip archive one after another. It has a special method to get the zip entry of the next file. The zip entry contains information about the file name size, compressed size, Crc, etc. It includes support for Stored and Deflated entries.

Author of the original java version : Jochen Hoenicke. More...

Inheritance diagram for ICSharpCode.SharpZipLib.Zip.ZipInputStream:
Collaboration diagram for ICSharpCode.SharpZipLib.Zip.ZipInputStream:

Public Member Functions

 ZipInputStream (Stream baseInputStream)
 Creates a new Zip input stream, for reading a zip archive.
 ZipInputStream (Stream baseInputStream, int bufferSize)
 Creates a new Zip input stream, for reading a zip archive.
ZipEntry GetNextEntry ()
 Advances to the next entry in the archive.
void CloseEntry ()
 Closes the current zip entry and moves to the next one.
override int ReadByte ()
 Reads a byte from the current zip entry.
override int Read (byte[] buffer, int offset, int count)
 Read a block of bytes from the stream.
override void Close ()
 Closes the zip input stream.
Public Member Functions inherited from ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream
 InflaterInputStream (Stream baseInputStream)
 Create an InflaterInputStream with the default decompressor and a default buffer size of 4KB.
 InflaterInputStream (Stream baseInputStream, Inflater inf)
 Create an InflaterInputStream with the specified decompressor and a default buffer size of 4KB.
 InflaterInputStream (Stream baseInputStream, Inflater inflater, int bufferSize)
 Create an InflaterInputStream with the specified decompressor and the specified buffer size.
long Skip (long count)
 Skip specified number of bytes of uncompressed data.
override void Flush ()
 Flushes the baseInputStream.
override long Seek (long offset, SeekOrigin origin)
 Sets the position within the current stream Always throws a NotSupportedException.
override void SetLength (long value)
 Set the length of the current stream Always throws a NotSupportedException.
override void Write (byte[] buffer, int offset, int count)
 Writes a sequence of bytes to stream and advances the current position This method always throws a NotSupportedException.
override void WriteByte (byte value)
 Writes one byte to the current stream and advances the current position Always throws a NotSupportedException.
override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback callback, object state)
 Entry point to begin an asynchronous write. Always throws a NotSupportedException.
override void Close ()
 Closes the input stream. When IsStreamOwner is true the underlying stream is also closed.
override int Read (byte[] buffer, int offset, int count)
 Reads decompressed data into the provided buffer byte array.

Properties

string Password [get, set]
 Optional password used for encryption when non-null.
bool CanDecompressEntry [get]
 Gets a value indicating if there is a current entry and it can be decompressed.
override int Available [get]
 Returns 1 if there is an entry available Otherwise returns 0.
override long Length [get]
 Returns the current size that can be read from the current entry if available.
Properties inherited from ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream
bool IsStreamOwner [get, set]
 Get/set flag indicating ownership of underlying stream. When the flag is true Close will close the underlying stream also.
virtual int Available [get]
 Returns 0 once the end of the stream (EOF) has been reached. Otherwise returns 1.
override bool CanRead [get]
 Gets a value indicating whether the current stream supports reading.
override bool CanSeek [get]
 Gets a value of false indicating seeking is not supported for this stream.
override bool CanWrite [get]
 Gets a value of false indicating that this stream is not writeable.
override long Length [get]
 A value representing the length of the stream in bytes.
override long Position [get, set]
 The current position within the stream. Throws a NotSupportedException when attempting to set the position.

Private Member Functions

delegate int ReadDataHandler (byte[] b, int offset, int length)
 Delegate for reading bytes from a stream.
void ReadDataDescriptor ()
 Read data descriptor at the end of compressed data.
void CompleteCloseEntry (bool testCrc)
 Complete cleanup as the final part of closing.
int ReadingNotAvailable (byte[] destination, int offset, int count)
 Handle attempts to read by throwing an InvalidOperationException.
int ReadingNotSupported (byte[] destination, int offset, int count)
 Handle attempts to read from this entry by throwing an exception.
int InitialRead (byte[] destination, int offset, int count)
 Perform the initial read on an entry which may include reading encryption headers and setting up inflation.
int BodyRead (byte[] buffer, int offset, int count)
 Reads a block of bytes from the current zip entry.

Private Attributes

ReadDataHandler internalReader
 The current reader this instance.
Crc32 crc = new Crc32()
ZipEntry entry
long size
int method
int flags
string password

Additional Inherited Members

Protected Member Functions inherited from ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream
void StopDecrypting ()
 Clear any cryptographic state.
void Fill ()
 Fills the buffer with more data to decompress.
Protected Attributes inherited from ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream
Inflater inf
 Decompressor for this stream.
InflaterInputBuffer inputBuffer
 Input buffer for this stream.
long csize
 The compressed size.

Detailed Description

This is an InflaterInputStream that reads the files baseInputStream an zip archive one after another. It has a special method to get the zip entry of the next file. The zip entry contains information about the file name size, compressed size, Crc, etc. It includes support for Stored and Deflated entries.

Author of the original java version : Jochen Hoenicke.

This sample shows how to read a zip file

using System;
using System.Text;
using System.IO;
class MainClass
{
public static void Main(string[] args)
{
using ( ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]))) {
@iverbatim
ZipEntry theEntry;
const int size = 2048;
byte[] data = new byte[2048];
while ((theEntry = s.GetNextEntry()) != null) {
if ( entry.IsFile ) {
Console.Write("Show contents (y/n) ?");
if (Console.ReadLine() == "y") {
while (true) {
size = s.Read(data, 0, data.Length);
if (size > 0) {
Console.Write(new ASCIIEncoding().GetString(data, 0, size));
} else {
break;
}
}
}
}
}
@endiverbatim }
}
}
Zwipe.Test.Tools.Entities.File File
Definition ExportsTest.cs:6
This class represents an entry in a zip archive. This can be a file or a directory ZipFile and ZipInp...
Definition ZipEntry.cs:151
ZipInputStream(Stream baseInputStream)
Creates a new Zip input stream, for reading a zip archive.
Definition ZipInputStream.cs:132
ZipEntry GetNextEntry()
Advances to the next entry in the archive.
Definition ZipInputStream.cs:194
ZipEntry entry
Definition ZipInputStream.cs:119
override int Read(byte[] buffer, int offset, int count)
Read a block of bytes from the stream.
Definition ZipInputStream.cs:550
long size
Definition ZipInputStream.cs:121
Definition Deflater.cs:43

Constructor & Destructor Documentation

◆ ZipInputStream() [1/2]

ICSharpCode.SharpZipLib.Zip.ZipInputStream.ZipInputStream ( Stream baseInputStream)

Creates a new Zip input stream, for reading a zip archive.

Parameters
baseInputStreamThe underlying Stream providing data.
Here is the call graph for this function:

◆ ZipInputStream() [2/2]

ICSharpCode.SharpZipLib.Zip.ZipInputStream.ZipInputStream ( Stream baseInputStream,
int bufferSize )

Creates a new Zip input stream, for reading a zip archive.

Parameters
baseInputStreamThe underlying Stream providing data.
bufferSizeSize of the buffer.
Here is the call graph for this function:

Member Function Documentation

◆ BodyRead()

int ICSharpCode.SharpZipLib.Zip.ZipInputStream.BodyRead ( byte[] buffer,
int offset,
int count )
private

Reads a block of bytes from the current zip entry.

Returns
The number of bytes read (this may be less than the length requested, even before the end of stream), or 0 on end of stream.

An i/o error occured.

Exceptions
ZipExceptionThe deflated stream is corrupted.
InvalidOperationExceptionThe stream is not open.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Close()

override void ICSharpCode.SharpZipLib.Zip.ZipInputStream.Close ( )

Closes the zip input stream.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CloseEntry()

void ICSharpCode.SharpZipLib.Zip.ZipInputStream.CloseEntry ( )

Closes the current zip entry and moves to the next one.

Exceptions
InvalidOperationExceptionThe stream is closed
ZipExceptionThe Zip stream ends early
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CompleteCloseEntry()

void ICSharpCode.SharpZipLib.Zip.ZipInputStream.CompleteCloseEntry ( bool testCrc)
private

Complete cleanup as the final part of closing.

Parameters
testCrcTrue if the crc value should be tested
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNextEntry()

ZipEntry ICSharpCode.SharpZipLib.Zip.ZipInputStream.GetNextEntry ( )

Advances to the next entry in the archive.

Returns
The next entry in the archive or null if there are no more entries.

If the previous entry is still open CloseEntry is called.

Exceptions
InvalidOperationExceptionInput stream is closed
ZipExceptionPassword is not set, password is invalid, compression method is invalid, version required to extract is not supported
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitialRead()

int ICSharpCode.SharpZipLib.Zip.ZipInputStream.InitialRead ( byte[] destination,
int offset,
int count )
private

Perform the initial read on an entry which may include reading encryption headers and setting up inflation.

Parameters
destinationThe destination to fill with data read.
offsetThe offset to start reading at.
countThe maximum number of bytes to read.
Returns
The actual number of bytes read.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Read()

override int ICSharpCode.SharpZipLib.Zip.ZipInputStream.Read ( byte[] buffer,
int offset,
int count )

Read a block of bytes from the stream.

Parameters
bufferThe destination for the bytes.
offsetThe index to start storing data.
countThe number of bytes to attempt to read.
Returns
Returns the number of bytes read.

Zero bytes read means end of stream.

Here is the caller graph for this function:

◆ ReadByte()

override int ICSharpCode.SharpZipLib.Zip.ZipInputStream.ReadByte ( )

Reads a byte from the current zip entry.

Returns
The byte or -1 if end of stream is reached.
Here is the call graph for this function:

◆ ReadDataDescriptor()

void ICSharpCode.SharpZipLib.Zip.ZipInputStream.ReadDataDescriptor ( )
private

Read data descriptor at the end of compressed data.

Here is the caller graph for this function:

◆ ReadDataHandler()

delegate int ICSharpCode.SharpZipLib.Zip.ZipInputStream.ReadDataHandler ( byte[] b,
int offset,
int length )
private

Delegate for reading bytes from a stream.

Here is the caller graph for this function:

◆ ReadingNotAvailable()

int ICSharpCode.SharpZipLib.Zip.ZipInputStream.ReadingNotAvailable ( byte[] destination,
int offset,
int count )
private

Handle attempts to read by throwing an InvalidOperationException.

Parameters
destinationThe destination array to store data in.
offsetThe offset at which data read should be stored.
countThe maximum number of bytes to read.
Returns
Returns the number of bytes actually read.
Here is the caller graph for this function:

◆ ReadingNotSupported()

int ICSharpCode.SharpZipLib.Zip.ZipInputStream.ReadingNotSupported ( byte[] destination,
int offset,
int count )
private

Handle attempts to read from this entry by throwing an exception.

Here is the caller graph for this function:

Member Data Documentation

◆ crc

Crc32 ICSharpCode.SharpZipLib.Zip.ZipInputStream.crc = new Crc32()
private

◆ entry

ZipEntry ICSharpCode.SharpZipLib.Zip.ZipInputStream.entry
private

◆ flags

int ICSharpCode.SharpZipLib.Zip.ZipInputStream.flags
private

◆ internalReader

ReadDataHandler ICSharpCode.SharpZipLib.Zip.ZipInputStream.internalReader
private

The current reader this instance.

◆ method

int ICSharpCode.SharpZipLib.Zip.ZipInputStream.method
private

◆ password

string ICSharpCode.SharpZipLib.Zip.ZipInputStream.password
private

◆ size

long ICSharpCode.SharpZipLib.Zip.ZipInputStream.size
private

Property Documentation

◆ Available

override int ICSharpCode.SharpZipLib.Zip.ZipInputStream.Available
get

Returns 1 if there is an entry available Otherwise returns 0.

◆ CanDecompressEntry

bool ICSharpCode.SharpZipLib.Zip.ZipInputStream.CanDecompressEntry
get

Gets a value indicating if there is a current entry and it can be decompressed.

The entry can only be decompressed if the library supports the zip features required to extract it. See the ZipEntry Version property for more details.

◆ Length

override long ICSharpCode.SharpZipLib.Zip.ZipInputStream.Length
get

Returns the current size that can be read from the current entry if available.

Exceptions
ZipExceptionThrown if the entry size is not known.
InvalidOperationExceptionThrown if no entry is currently available.

◆ Password

string ICSharpCode.SharpZipLib.Zip.ZipInputStream.Password
getset

Optional password used for encryption when non-null.

A password for all encrypted entries in this ZipInputStream


The documentation for this class was generated from the following file: