Quark
0.1
|
A class representing a Zip archive. More...
#include <ZipFile.h++>
Public Member Functions | |
ZipFile (const QString &file) | |
Constructs a new ZipFile for the given file path. More... | |
virtual | ~ZipFile () |
Destructor. More... | |
bool | open (QIODevice::OpenMode openMode, const QString &password=QString()) |
Opens the Zip archive. More... | |
bool | close () |
Closes the Zip archive. More... | |
bool | isOpen () const |
Tests if the Zip archive is currently open. More... | |
QString | archiveComment () |
Returns the Zip archive's comment. More... | |
bool | setArchiveComment (const QString &comment) |
Sets the Zip archive's comment. More... | |
qint64 | numEntries () |
Returns the number of entries in the Zip archive. More... | |
QString | getEntryPath (qint64 index) |
Returns the file path for the entry at the specified index. More... | |
bool | getEntry (qint64 index, ZipEntry &entry) |
Retrieves the entry at the specified index in the Zip archive. More... | |
bool | getEntry (const QString &path, ZipEntry &entry, bool ignoreCase=false) |
Retrieves the entry with the specified file path in the Zip archive. More... | |
QString | getEntryComment (qint64 index) |
Retrieves the comment for the entry at the specified index in the Zip archive. More... | |
bool | setEntryComment (qint64 index, const QString &comment) |
Sets the comment for the entry at the specified index in the Zip archive. More... | |
bool | removeEntry (qint64 index) |
Removes the entry at the specified index from the Zip archive. More... | |
bool | renameEntry (qint64 index, const QString &newPath) |
Changes the file path of the entry at the specified index in the Zip archive. More... | |
bool | openEntry (qint64 index) |
Opens the entry at the specified index in the Zip archive. More... | |
bool | isEntryOpen () const |
Tests if an entry is currently opened. More... | |
int | readEntry (char *buf, int count) |
Reads (and decompresses) data from the currently opened entry. More... | |
void | closeEntry () |
Closes the currently opened entry, if any. More... | |
bool | extractEntry (const ZipEntry &entry, const QString &outputPath) |
Extracts the contents of a file entry from the Zip archive. More... | |
bool | addDirectory (const QString &zipPath) |
Adds a directory entry to the Zip archive. More... | |
bool | addFile (const QString &path, const QString &zipPath) |
Adds a file entry to the Zip archive. More... | |
QString | error () const |
Returns the most recently generated Zip error message. More... | |
Friends | |
class | ZipEntry |
A class representing a Zip archive.
The class can be used to both read and write Zip archives.
|
virtual |
Destructor.
Closes the file if it is open.
bool addDirectory | ( | const QString & | zipPath | ) |
Adds a directory entry to the Zip archive.
zipPath | The file path for the new entry. |
true
if the entry was successfully added, false
otherwise. bool addFile | ( | const QString & | path, |
const QString & | zipPath | ||
) |
Adds a file entry to the Zip archive.
path | The path of the file which should be written into the Zip archive. |
zipPath | The file path for the new entry. |
true
if the entry was successfully added, false
otherwise. QString archiveComment | ( | ) |
Returns the Zip archive's comment.
bool close | ( | ) |
Closes the Zip archive.
Note that when writing a Zip archive, the file may not actually be created and written to the filesystem until it is closed.
true
if the file was successfully opened, false
otherwise. void closeEntry | ( | ) |
Closes the currently opened entry, if any.
|
inline |
Returns the most recently generated Zip error message.
bool extractEntry | ( | const ZipEntry & | entry, |
const QString & | outputPath | ||
) |
Extracts the contents of a file entry from the Zip archive.
entry | The entry to be extracted. |
outputPath | The path to which the decompressed file data should be written. |
true
if the entry was successfully extracted, false
otherwise. bool getEntry | ( | qint64 | index, |
ZipEntry & | entry | ||
) |
Retrieves the entry at the specified index in the Zip archive.
index | The index |
entry | The ZipEntry object in which to place details about the entry. |
true
if the entry was successfully retrieved, false
otherwise. bool getEntry | ( | const QString & | path, |
ZipEntry & | entry, | ||
bool | ignoreCase = false |
||
) |
Retrieves the entry with the specified file path in the Zip archive.
path | filePath |
entry | The ZipEntry object in which to place details about the entry. |
ignoreCase | A flag indicating whether the search for a matching file path in the archive should be case-insensitive. |
true
if the entry was successfully retrieved, false
otherwise. QString getEntryComment | ( | qint64 | index | ) |
Retrieves the comment for the entry at the specified index in the Zip archive.
index | The index. |
QString getEntryPath | ( | qint64 | index | ) |
Returns the file path for the entry at the specified index.
index | The index. |
bool isEntryOpen | ( | ) | const |
Tests if an entry is currently opened.
bool isOpen | ( | ) | const |
Tests if the Zip archive is currently open.
qint64 numEntries | ( | ) |
Returns the number of entries in the Zip archive.
bool open | ( | QIODevice::OpenMode | openMode, |
const QString & | password = QString() |
||
) |
Opens the Zip archive.
openMode | The open mode. Must be either QIODevice::ReadOnly or QIODevice::WriteOnly. |
password | The password for the archive, if any. |
true
if the file was successfully opened, false
otherwise. bool openEntry | ( | qint64 | index | ) |
Opens the entry at the specified index in the Zip archive.
An entry must be opened before it can be read from. Only one entry can be opened at any given time.
index | The index. |
true
if the entry was successfully opened, false
otherwise. int readEntry | ( | char * | buf, |
int | count | ||
) |
Reads (and decompresses) data from the currently opened entry.
buf | The buffer to read the data into. |
count | The maximum number of bytes to read. |
bool removeEntry | ( | qint64 | index | ) |
Removes the entry at the specified index from the Zip archive.
index | The index. |
true
if the entry was successfully removed, false
otherwise. bool renameEntry | ( | qint64 | index, |
const QString & | newPath | ||
) |
Changes the file path of the entry at the specified index in the Zip archive.
index | The index. |
newPath | The new file path. |
true
if the entry was successfully updated, false
otherwise. bool setArchiveComment | ( | const QString & | comment | ) |
Sets the Zip archive's comment.
comment | The new comment. |
true
if the comment was successfully set, false
otherwise. bool setEntryComment | ( | qint64 | index, |
const QString & | comment | ||
) |
Sets the comment for the entry at the specified index in the Zip archive.
index | The index. |
true
if the comment was successfully set, false
otherwise.
|
friend |