|
|
This class implements a kioslave to acces ZIP files from KDE. you can use it in IO_ReadOnly or in IO_WriteOnly mode, and it behaves just as expected (i hope ;-) ). It can also be used in IO_ReadWrite mode, in this case one can append files to an existing zip archive. when you append new files, which are not yet in the zip, it works as expected, they are appended at the end. when you append a file, which is already in the file, the reference to the old file is dropped and the new one is added to the zip. but the old data from the file itself is not deleted, it is still in the zipfile. so when you want to have a small and garbagefree zipfile, just read the contents of the appended zipfile and write it to a new one in IO_WriteOnly mode. exspecially take care of this, when you donīt want to leak information of how intermediate versions of files in the zip were looking. for more information on the zip fileformat go to http://www.pkware.com/support/appnote.html .
KZip ( const QString& filename )
| KZip |
Creates an instance that operates on the given filename. using the compression filter associated to given mimetype.
Parameters:
filename | is a local path (e.g. "/home/holger/myfile.zip") |
KZip ( QIODevice * dev )
| KZip |
Creates an instance that operates on the given device. The device can be compressed (KFilterDev) or not (QFile, etc.). WARNING: don't assume that giving a QFile here will decompress the file, in case it's compressed!
~KZip ()
| ~KZip |
[virtual]
If the zip file is still opened, then it will be closed automatically by the destructor.
QString fileName ()
| fileName |
The name of the zip file, as passed to the constructor Null if you used the QIODevice constructor.
enum Compression { NoCompression = 0, DeflateCompression = 1 } | Compression |
void setCompression ( Compression c )
| setCompression |
Call this before writeFile or prepareWriting, to define whether the next files to be written should be compressed or not.
Compression compression ()
| compression |
[const]
bool writeFile ( const QString& name, const QString& user, const QString& group, uint size, const char* data )
| writeFile |
[virtual]
If an archive is opened for writing then you can add a new file using this function. This method takes the whole data at once.
Parameters:
name | can include subdirs e.g. path/to/the/file |
Reimplemented from KArchive.
bool prepareWriting ( const QString& name, const QString& user, const QString& group, uint size )
| prepareWriting |
[virtual]
Alternative method: call prepareWriting, writeData in small chunks, doneWriting
Parameters:
size | unused |
Reimplemented from KArchive.
bool writeData ( const char* data, uint size )
| writeData |
bool doneWriting ( uint size )
| doneWriting |
[virtual]
Reimplemented from KArchive.
bool openArchive ( int mode )
| openArchive |
[protected virtual]
Opens the archive for reading. Parses the directory listing of the archive and creates the KArchiveDirectory/KArchiveFile entries.
Reimplemented from KArchive.
bool closeArchive ()
| closeArchive |
[protected virtual]
Reimplemented from KArchive.
bool writeDir ( const QString&, const QString&, const QString& )
| writeDir |
[protected virtual]
Reimplemented from KArchive.
void virtual_hook ( int id, void* data )
| virtual_hook |
[protected virtual]
Reimplemented from KArchive.