UnZip Class Reference

PKZip 2.0 file decompression. Compatibility with later versions is not ensured as they may use unsupported compression algorithms. Versions after 2.7 may have an incompatible header format and thus be completely incompatible. More...

#include <unzip.h>

Collaboration diagram for UnZip:

Collaboration graph
[legend]
List of all members.

Public Types

enum  ErrorCode {
  Ok, ZlibInit, ZlibError, OpenFailed,
  PartiallyCorrupted, Corrupted, WrongPassword, NoOpenArchive,
  FileNotFound, ReadFailed, WriteFailed, SeekFailed,
  CreateDirFailed, InvalidDevice, InvalidArchive, HeaderConsistencyError,
  Skip, SkipAll
}
enum  ExtractionOption { ExtractPaths = 0x0001, SkipPaths = 0x0002 }
enum  CompressionMethod { NoCompression, Deflated, UnknownCompression }
enum  FileType { File, Directory }

Public Member Functions

 UnZip ()
virtual ~UnZip ()
bool isOpen () const
ErrorCode openArchive (const QString &filename)
ErrorCode openArchive (QIODevice *device)
void closeArchive ()
QString archiveComment () const
QString formatError (UnZip::ErrorCode c) const
bool contains (const QString &file) const
QStringList fileList () const
QList< ZipEntryentryList () const
ErrorCode extractAll (const QString &dirname, ExtractionOptions options=ExtractPaths)
ErrorCode extractAll (const QDir &dir, ExtractionOptions options=ExtractPaths)
ErrorCode extractFile (const QString &filename, const QString &dirname, ExtractionOptions options=ExtractPaths)
ErrorCode extractFile (const QString &filename, const QDir &dir, ExtractionOptions options=ExtractPaths)
ErrorCode extractFile (const QString &filename, QIODevice *device, ExtractionOptions options=ExtractPaths)
ErrorCode extractFiles (const QStringList &filenames, const QString &dirname, ExtractionOptions options=ExtractPaths)
ErrorCode extractFiles (const QStringList &filenames, const QDir &dir, ExtractionOptions options=ExtractPaths)
void setPassword (const QString &pwd)

Private Attributes

UnzipPrivated

Classes

struct  ZipEntry

Detailed Description

PKZip 2.0 file decompression. Compatibility with later versions is not ensured as they may use unsupported compression algorithms. Versions after 2.7 may have an incompatible header format and thus be completely incompatible.

Definition at line 45 of file unzip.h.


Member Enumeration Documentation

enum ErrorCode

The result of a decompression operation. UnZip::Ok No error occurred. UnZip::ZlibInit Failed to init or load the zlib library. UnZip::ZlibError The zlib library returned some error. UnZip::OpenFailed Unable to create or open a device. UnZip::PartiallyCorrupted Corrupted zip archive - some files could be extracted. UnZip::Corrupted Corrupted or invalid zip archive. UnZip::WrongPassword Unable to decrypt a password protected file. UnZip::NoOpenArchive No archive has been opened yet. UnZip::FileNotFound Unable to find the requested file in the archive. UnZip::ReadFailed Reading of a file failed. UnZip::WriteFailed Writing of a file failed. UnZip::SeekFailed Seek failed. UnZip::CreateDirFailed Could not create a directory. UnZip::InvalidDevice A null device has been passed as parameter. UnZip::InvalidArchive This is not a valid (or supported) ZIP archive. UnZip::HeaderConsistencyError Local header record info does not match with the central directory record info. The archive may be corrupted.

UnZip::Skip Internal use only. UnZip::SkipAll Internal use only.

Enumerator:
Ok 
ZlibInit 
ZlibError 
OpenFailed 
PartiallyCorrupted 
Corrupted 
WrongPassword 
NoOpenArchive 
FileNotFound 
ReadFailed 
WriteFailed 
SeekFailed 
CreateDirFailed 
InvalidDevice 
InvalidArchive 
HeaderConsistencyError 
Skip 
SkipAll 

Definition at line 48 of file unzip.h.

enum ExtractionOption

Enumerator:
ExtractPaths  Extracts paths (default).
SkipPaths  Ignores paths and extracts all the files to the same directory.

Definition at line 70 of file unzip.h.

enum CompressionMethod

Enumerator:
NoCompression 
Deflated 
UnknownCompression 

Definition at line 79 of file unzip.h.

enum FileType

Enumerator:
File 
Directory 

Definition at line 84 of file unzip.h.


Constructor & Destructor Documentation

UnZip (  ) 

Creates a new Zip file decompressor.

Definition at line 165 of file unzip.cpp.

~UnZip (  )  [virtual]

Closes any open archive and releases used resources.

Definition at line 173 of file unzip.cpp.


Member Function Documentation

bool isOpen (  )  const

Returns true if there is an open archive.

Definition at line 182 of file unzip.cpp.

UnZip::ErrorCode openArchive ( const QString &  filename  ) 

Opens a zip archive and reads the files list. Closes any previously opened archive.

Definition at line 190 of file unzip.cpp.

Referenced by decompress(), listFiles(), and RegData::loadInput().

Here is the caller graph for this function:

UnZip::ErrorCode openArchive ( QIODevice *  device  ) 

Opens a zip archive and reads the entries list. Closes any previously opened archive.

Warning:
The class takes ownership of the device so don't delete it!

Definition at line 212 of file unzip.cpp.

void closeArchive (  ) 

Closes the archive and releases all the used resources (like cached passwords).

Definition at line 226 of file unzip.cpp.

Referenced by decompress(), listFiles(), RegData::loadInput(), and ~UnZip().

Here is the caller graph for this function:

QString archiveComment (  )  const

Definition at line 231 of file unzip.cpp.

Referenced by listFiles().

Here is the caller graph for this function:

QString formatError ( UnZip::ErrorCode  c  )  const

Returns a locale translated error string for a given error code.

Definition at line 241 of file unzip.cpp.

Referenced by decompress(), listFiles(), and RegData::loadInput().

Here is the caller graph for this function:

bool contains ( const QString &  file  )  const

Returns true if the archive contains a file with the given path and name.

Definition at line 270 of file unzip.cpp.

QStringList fileList (  )  const

Returns complete paths of files and directories in this archive.

Definition at line 281 of file unzip.cpp.

QList< UnZip::ZipEntry > entryList (  )  const

Returns information for each (correctly parsed) entry of this archive.

Definition at line 289 of file unzip.cpp.

Referenced by listFiles().

Here is the caller graph for this function:

UnZip::ErrorCode extractAll ( const QString &  dirname,
ExtractionOptions  options = ExtractPaths 
)

Extracts the whole archive to a directory.

Definition at line 325 of file unzip.cpp.

Referenced by decompress(), and RegData::loadInput().

Here is the caller graph for this function:

UnZip::ErrorCode extractAll ( const QDir &  dir,
ExtractionOptions  options = ExtractPaths 
)

Extracts the whole archive to a directory.

Definition at line 333 of file unzip.cpp.

UnZip::ErrorCode extractFile ( const QString &  filename,
const QString &  dirname,
ExtractionOptions  options = ExtractPaths 
)

Extracts a single file to a directory.

Definition at line 380 of file unzip.cpp.

Referenced by extractFiles().

Here is the caller graph for this function:

UnZip::ErrorCode extractFile ( const QString &  filename,
const QDir &  dir,
ExtractionOptions  options = ExtractPaths 
)

Extracts a single file to a directory.

Definition at line 388 of file unzip.cpp.

UnZip::ErrorCode extractFile ( const QString &  filename,
QIODevice *  dev,
ExtractionOptions  options = ExtractPaths 
)

Extracts a single file to a directory.

Definition at line 404 of file unzip.cpp.

UnZip::ErrorCode extractFiles ( const QStringList &  filenames,
const QString &  dirname,
ExtractionOptions  options = ExtractPaths 
)

Extracts a list of files. Stops extraction at the first error (but continues if a file does not exist in the archive).

Definition at line 423 of file unzip.cpp.

UnZip::ErrorCode extractFiles ( const QStringList &  filenames,
const QDir &  dir,
ExtractionOptions  options = ExtractPaths 
)

Extracts a list of files. Stops extraction at the first error (but continues if a file does not exist in the archive).

Definition at line 444 of file unzip.cpp.

void setPassword ( const QString &  pwd  ) 

Remove/replace this method to add your own password retrieval routine.

Definition at line 463 of file unzip.cpp.

Referenced by decompress(), and listFiles().

Here is the caller graph for this function:


Member Data Documentation

UnzipPrivate* d [private]

Definition at line 139 of file unzip.h.

Referenced by archiveComment(), closeArchive(), contains(), entryList(), extractAll(), extractFile(), fileList(), isOpen(), openArchive(), setPassword(), UnZip(), and ~UnZip().


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