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:

ICSharpCode::SharpZipLib::Zip::Compression::Streams::InflaterInputStream List of all members.

Public Member Functions

 ZipInputStream (Stream baseInputStream)
 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[] destination, int index, int count)
 Read a block of bytes from the stream.
int BodyRead (byte[] b, int off, int len)
 Reads a block of bytes from the current zip entry.
override void Close ()
 Closes the zip input stream.

Properties

string Password
 Optional password used for encryption when non-null.
bool CanDecompressEntry
 Gets a value indicating if the entry can be decompressed.
override int Available
 Returns 1 if there is an entry available Otherwise returns 0.

Private Member Functions

delegate int ReaderDelegate (byte[] b, int offset, int length)
void ReadDataDescriptor ()
int InitialRead (byte[] destination, int offset, int count)

Private Attributes

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

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;
            
            using ICSharpCode.SharpZipLib.Zip;
            
            class MainClass
            {
                public static void Main(string[] args)
                {
                        ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]));
                        
                        ZipEntry theEntry;
                        while ((theEntry = s.GetNextEntry()) != null) {
                                int size = 2048;
                                byte[] data = new byte[2048];
                                
                                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;
                                                }
                                        }
                                }
                        }
                        s.Close();
                }
            }   

Definition at line 97 of file ZipInputStream.cs.


Constructor & Destructor Documentation

ICSharpCode::SharpZipLib::Zip::ZipInputStream::ZipInputStream Stream  baseInputStream  )  [inline]
 

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

Definition at line 118 of file ZipInputStream.cs.


Member Function Documentation

int ICSharpCode::SharpZipLib::Zip::ZipInputStream::BodyRead byte[]  b,
int  off,
int  len
[inline]
 

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.

Definition at line 443 of file ZipInputStream.cs.

override void ICSharpCode::SharpZipLib::Zip::ZipInputStream::Close  )  [inline]
 

Closes the zip input stream.

Reimplemented from ICSharpCode::SharpZipLib::Zip::Compression::Streams::InflaterInputStream.

Definition at line 515 of file ZipInputStream.cs.

void ICSharpCode::SharpZipLib::Zip::ZipInputStream::CloseEntry  )  [inline]
 

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

Exceptions:
InvalidOperationException The stream is closed
ZipException The Zip stream ends early

Definition at line 285 of file ZipInputStream.cs.

ZipEntry ICSharpCode::SharpZipLib::Zip::ZipInputStream::GetNextEntry  )  [inline]
 

Advances to the next entry in the archive.

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

If the previous entry is still open CloseEntryCloseEntry 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

Definition at line 167 of file ZipInputStream.cs.

int ICSharpCode::SharpZipLib::Zip::ZipInputStream::InitialRead byte[]  destination,
int  offset,
int  count
[inline, private]
 

Definition at line 365 of file ZipInputStream.cs.

References ICSharpCode::SharpZipLib::Encryption::PkzipClassicManaged::CreateDecryptor().

override int ICSharpCode::SharpZipLib::Zip::ZipInputStream::Read byte[]  destination,
int  index,
int  count
[inline]
 

Read a block of bytes from the stream.

Parameters:
destination The destination for the bytes.
index 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.

Reimplemented from ICSharpCode::SharpZipLib::Zip::Compression::Streams::InflaterInputStream.

Definition at line 423 of file ZipInputStream.cs.

override int ICSharpCode::SharpZipLib::Zip::ZipInputStream::ReadByte  )  [inline]
 

Reads a byte from the current zip entry.

Returns:
The byte or -1 if end of stream is reached.
An i/o error occured.

The deflated stream is corrupted.

Definition at line 354 of file ZipInputStream.cs.

void ICSharpCode::SharpZipLib::Zip::ZipInputStream::ReadDataDescriptor  )  [inline, private]
 

Definition at line 262 of file ZipInputStream.cs.

delegate int ICSharpCode::SharpZipLib::Zip::ZipInputStream::ReaderDelegate byte[]  b,
int  offset,
int  length
[private]
 


Member Data Documentation

Crc32 ICSharpCode::SharpZipLib::Zip::ZipInputStream::crc = new Crc32() [private]
 

Definition at line 107 of file ZipInputStream.cs.

ZipEntry ICSharpCode::SharpZipLib::Zip::ZipInputStream::entry = null [private]
 

Definition at line 108 of file ZipInputStream.cs.

int ICSharpCode::SharpZipLib::Zip::ZipInputStream::flags [private]
 

Definition at line 112 of file ZipInputStream.cs.

ReaderDelegate ICSharpCode::SharpZipLib::Zip::ZipInputStream::internalReader [private]
 

The current reader this instance.

Definition at line 105 of file ZipInputStream.cs.

int ICSharpCode::SharpZipLib::Zip::ZipInputStream::method [private]
 

Definition at line 111 of file ZipInputStream.cs.

string ICSharpCode::SharpZipLib::Zip::ZipInputStream::password = null [private]
 

Definition at line 113 of file ZipInputStream.cs.

long ICSharpCode::SharpZipLib::Zip::ZipInputStream::size [private]
 

Definition at line 110 of file ZipInputStream.cs.


Property Documentation

override int ICSharpCode::SharpZipLib::Zip::ZipInputStream::Available [get]
 

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

Reimplemented from ICSharpCode::SharpZipLib::Zip::Compression::Streams::InflaterInputStream.

Definition at line 336 of file ZipInputStream.cs.

bool ICSharpCode::SharpZipLib::Zip::ZipInputStream::CanDecompressEntry [get]
 

Gets a value indicating if the entry can be decompressed.

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

Definition at line 145 of file ZipInputStream.cs.

string ICSharpCode::SharpZipLib::Zip::ZipInputStream::Password [get, set]
 

Optional password used for encryption when non-null.

Definition at line 128 of file ZipInputStream.cs.


The documentation for this class was generated from the following file:
Generated on Fri Jun 23 21:50:07 2006 for OblivionModTranslator by  doxygen 1.4.6-NO