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...
|
| | 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.
|
| | 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.
|
|
| 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.
|
| 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.
|
|
| 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.
|
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)
{
@iverbatim
byte[] data = new byte[2048];
Console.Write("Show contents (y/n) ?");
if (Console.ReadLine() == "y") {
while (true) {
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
Definition Deflater.cs:43
◆ ZipInputStream() [1/2]
| ICSharpCode.SharpZipLib.Zip.ZipInputStream.ZipInputStream |
( |
Stream | baseInputStream | ) |
|
Creates a new Zip input stream, for reading a zip archive.
- Parameters
-
| baseInputStream | The underlying Stream providing data. |
◆ ZipInputStream() [2/2]
| ICSharpCode.SharpZipLib.Zip.ZipInputStream.ZipInputStream |
( |
Stream | baseInputStream, |
|
|
int | bufferSize ) |
Creates a new Zip input stream, for reading a zip archive.
- Parameters
-
| baseInputStream | The underlying Stream providing data. |
| bufferSize | Size of the buffer. |
◆ 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
-
| ZipException | The deflated stream is corrupted. |
| InvalidOperationException | The stream is not open. |
◆ Close()
| override void ICSharpCode.SharpZipLib.Zip.ZipInputStream.Close |
( |
| ) |
|
Closes the zip input stream.
◆ CloseEntry()
| void ICSharpCode.SharpZipLib.Zip.ZipInputStream.CloseEntry |
( |
| ) |
|
Closes the current zip entry and moves to the next one.
- Exceptions
-
| InvalidOperationException | The stream is closed |
| ZipException | The Zip stream ends early |
◆ CompleteCloseEntry()
| void ICSharpCode.SharpZipLib.Zip.ZipInputStream.CompleteCloseEntry |
( |
bool | testCrc | ) |
|
|
private |
Complete cleanup as the final part of closing.
- Parameters
-
| testCrc | True if the crc value should be tested |
◆ 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
-
| InvalidOperationException | Input stream is closed |
| ZipException | Password is not set, password is invalid, compression method is invalid, version required to extract is not supported |
◆ 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
-
| destination | The destination to fill with data read. |
| offset | The offset to start reading at. |
| count | The maximum number of bytes to read. |
- Returns
- The actual number of bytes read.
◆ Read()
| override int ICSharpCode.SharpZipLib.Zip.ZipInputStream.Read |
( |
byte[] | buffer, |
|
|
int | offset, |
|
|
int | count ) |
Read a block of bytes from the stream.
- Parameters
-
| buffer | The destination for the bytes. |
| offset | The index to start storing data. |
| count | The number of bytes to attempt to read. |
- Returns
- Returns the number of bytes read.
Zero bytes read means end of stream.
◆ 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.
◆ ReadDataDescriptor()
| void ICSharpCode.SharpZipLib.Zip.ZipInputStream.ReadDataDescriptor |
( |
| ) |
|
|
private |
Read data descriptor at the end of compressed data.
◆ ReadDataHandler()
| delegate int ICSharpCode.SharpZipLib.Zip.ZipInputStream.ReadDataHandler |
( |
byte[] | b, |
|
|
int | offset, |
|
|
int | length ) |
|
private |
Delegate for reading bytes from a stream.
◆ ReadingNotAvailable()
| int ICSharpCode.SharpZipLib.Zip.ZipInputStream.ReadingNotAvailable |
( |
byte[] | destination, |
|
|
int | offset, |
|
|
int | count ) |
|
private |
Handle attempts to read by throwing an InvalidOperationException.
- Parameters
-
| destination | The destination array to store data in. |
| offset | The offset at which data read should be stored. |
| count | The maximum number of bytes to read. |
- Returns
- Returns the number of bytes actually read.
◆ 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.
◆ 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
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 |
◆ 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
-
| ZipException | Thrown if the entry size is not known. |
| InvalidOperationException | Thrown 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: