Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
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:
[legend]

Classes

struct  ZipEntry

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 , VerifyOnly = 0x0004 , NoSilentDirectoryCreation = 0x0008 }
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 verifyArchive ()
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

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.

Member Enumeration Documentation

◆ CompressionMethod

Enumerator
NoCompression 
Deflated 
UnknownCompression 

◆ ErrorCode

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

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

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

◆ ExtractionOption

Enumerator
ExtractPaths 
SkipPaths 
VerifyOnly 
NoSilentDirectoryCreation 

◆ FileType

Enumerator
File 
Directory 

Constructor & Destructor Documentation

◆ UnZip()

UnZip::UnZip ( )

Creates a new Zip file decompressor.

Here is the caller graph for this function:

◆ ~UnZip()

UnZip::~UnZip ( )
virtual

Closes any open archive and releases used resources.

Here is the call graph for this function:

Member Function Documentation

◆ archiveComment()

QString UnZip::archiveComment ( ) const

◆ closeArchive()

void UnZip::closeArchive ( )

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

Here is the caller graph for this function:

◆ contains()

bool UnZip::contains ( const QString & file) const

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

◆ entryList()

QList< UnZip::ZipEntry > UnZip::entryList ( ) const

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

Here is the call graph for this function:

◆ extractAll() [1/2]

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

Extracts the whole archive to a directory. Stops extraction at the first error.

Here is the call graph for this function:

◆ extractAll() [2/2]

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

Extracts the whole archive to a directory.

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

◆ extractFile() [1/3]

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

Extracts a single file to a directory.

◆ extractFile() [2/3]

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

Extracts a single file to a directory.

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

◆ extractFile() [3/3]

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

Extracts a single file to a directory.

◆ extractFiles() [1/2]

UnZip::ErrorCode UnZip::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).

Here is the call graph for this function:

◆ extractFiles() [2/2]

UnZip::ErrorCode UnZip::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).

Here is the call graph for this function:

◆ fileList()

QStringList UnZip::fileList ( ) const

Returns complete paths of files and directories in this archive.

Here is the caller graph for this function:

◆ formatError()

QString UnZip::formatError ( UnZip::ErrorCode c) const

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

Here is the caller graph for this function:

◆ isOpen()

bool UnZip::isOpen ( ) const

Returns true if there is an open archive.

◆ openArchive() [1/2]

UnZip::ErrorCode UnZip::openArchive ( const QString & filename)

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

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

◆ openArchive() [2/2]

UnZip::ErrorCode UnZip::openArchive ( QIODevice * device)

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

Warning
The class takes DOES NOT take ownership of the device.
Here is the call graph for this function:

◆ setPassword()

void UnZip::setPassword ( const QString & pwd)

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

◆ verifyArchive()

UnZip::ErrorCode UnZip::verifyArchive ( )

Extracts the whole archive to a directory.

Here is the call graph for this function:

Member Data Documentation

◆ d

UnzipPrivate* UnZip::d
private

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