Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

KZip Class Reference

A class for reading/writing zip archives. More...

#include <kzip.h>

Inheritance diagram for KZip:

KArchive List of all members.

Public Methods

 KZip (const QString &filename)
 KZip (QIODevice *dev)
virtual ~KZip ()
QString fileName ()
void setCompression (Compression c)
virtual bool writeFile (const QString &name, const QString &user, const QString &group, uint size, const char *data)
virtual bool prepareWriting (const QString &name, const QString &user, const QString &group, uint size)
virtual bool doneWriting (uint size)

Protected Methods

virtual bool openArchive (int mode)
virtual bool closeArchive ()
virtual bool writeDir (const QString &, const QString &, const QString &)
virtual void virtual_hook (int id, void *data)

Detailed Description

A class for reading/writing zip archives.

Author:
Holger Schroeder <holger-kde@holgis.net>
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 .
Since:
3.1

Definition at line 54 of file kzip.h.


Constructor & Destructor Documentation

KZip::KZip const QString &    filename
 

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::KZip QIODevice *    dev
 

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!

virtual KZip::~KZip   [virtual]
 

If the zip file is still opened, then it will be closed automatically by the destructor.


Member Function Documentation

virtual bool KZip::closeArchive   [protected, virtual]
 

Closes the archive. Called by close.

Implements KArchive.

virtual bool KZip::doneWriting uint    size [virtual]
 

Call doneWriting after writing the data.

See also:
prepareWriting

Implements KArchive.

QString KZip::fileName   [inline]
 

The name of the zip file, as passed to the constructor Null if you used the QIODevice constructor.

Definition at line 83 of file kzip.h.

virtual bool KZip::openArchive int    mode [protected, virtual]
 

Opens the archive for reading. Parses the directory listing of the archive and creates the KArchiveDirectory/KArchiveFile entries.

Implements KArchive.

virtual bool KZip::prepareWriting const QString &    name,
const QString &    user,
const QString &    group,
uint    size
[virtual]
 

Alternative method: call prepareWriting, writeData in small chunks, doneWriting

Parameters:
size  unused

Implements KArchive.

void KZip::setCompression Compression    c
 

Call this before writeFile or prepareWriting, to define whether the next files to be written should be compressed or not.

virtual bool KZip::writeDir const QString &   ,
const QString &   ,
const QString &   
[inline, protected, virtual]
 

If an archive is opened for writing then you can add new directories using this function. KArchive won't write one directory twice.

Implements KArchive.

Definition at line 122 of file kzip.h.

virtual bool KZip::writeFile const QString &    name,
const QString &    user,
const QString &    group,
uint    size,
const char *    data
[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.


The documentation for this class was generated from the following file:
Generated on Wed Aug 13 23:30:29 2003 for kdelibs by doxygen1.2.18