.TH "KZip" 3 "28 Jan 2004" "kio Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KZip \- A class for reading/writing zip archives.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <kzip.h>\fP
.PP
Inherits \fBKArchive\fP.
.PP
.SS "Public Types"

.in +1c
.ti -1c
.RI "enum \fBCompression\fP { \fBNoCompression\fP =  0, \fBDeflateCompression\fP =  1 }"
.br
.in -1c
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKZip\fP (const  \fBQString\fP &filename)"
.br
.RI "\fICreates an instance that operates on the given filename. \fP"
.ti -1c
.RI "\fBKZip\fP (\fBQIODevice\fP *dev)"
.br
.RI "\fICreates an instance that operates on the given device. \fP"
.ti -1c
.RI "virtual \fB~KZip\fP ()"
.br
.RI "\fIIf the zip file is still opened, then it will be closed automatically by the destructor. \fP"
.ti -1c
.RI "\fBQString\fP \fBfileName\fP ()"
.br
.RI "\fIThe name of the zip file, as passed to the constructor Null if you used the \fBQIODevice\fP constructor. \fP"
.ti -1c
.RI "void \fBsetCompression\fP (Compression c)"
.br
.RI "\fICall this before writeFile or prepareWriting, to define whether the next files to be written should be compressed or not. \fP"
.ti -1c
.RI "Compression \fBcompression\fP () const "
.br
.ti -1c
.RI "virtual bool \fBwriteFile\fP (const  \fBQString\fP &name, const  \fBQString\fP &user, const  \fBQString\fP &group, uint size, const  char *data)"
.br
.RI "\fIIf an archive is opened for writing then you can add a new file using this function. \fP"
.ti -1c
.RI "virtual bool \fBprepareWriting\fP (const  \fBQString\fP &name, const  \fBQString\fP &user, const  \fBQString\fP &group, uint size)"
.br
.RI "\fIAlternative method: call prepareWriting, writeData in small chunks, doneWriting. \fP"
.ti -1c
.RI "bool \fBwriteData\fP (const  char *data, uint size)"
.br
.ti -1c
.RI "virtual bool \fBdoneWriting\fP (uint size)"
.br
.RI "\fICall \fBdoneWriting\fP after writing the data. \fP"
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "virtual bool \fBopenArchive\fP (int mode)"
.br
.RI "\fIOpens the archive for reading. \fP"
.ti -1c
.RI "virtual bool \fBcloseArchive\fP ()"
.br
.RI "\fICloses the archive. \fP"
.ti -1c
.RI "virtual bool \fBwriteDir\fP (const  \fBQString\fP &, const  \fBQString\fP &, const  \fBQString\fP &)"
.br
.RI "\fIIf an archive is opened for writing then you can add new directories using this function. \fP"
.ti -1c
.RI "virtual void \fBvirtual_hook\fP (int id, void *data)"
.br
.in -1c
.SH "Detailed Description"
.PP 
A class for reading/writing zip archives. 

\fBAuthor:\fP
.RS 4
Holger Schroeder <holger-kde@holgis.net>
.RE
.PP
This class implements a kioslave to acces ZIP files from \fBKDE\fP. 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 . 
.PP
\fBSince:\fP
.RS 4
3.1 
.RE
.PP

.PP
Definition at line 54 of file kzip.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KZip::KZip (const \fBQString\fP & filename)"
.PP
Creates an instance that operates on the given filename. using the compression filter associated to given mimetype.
.PP
\fBParameters:\fP
.RS 4
\fIfilename\fP is a local path (e.g. '/home/holger/myfile.zip') 
.RE
.PP
Definition at line 120 of file kzip.cpp.
.SS "KZip::KZip (\fBQIODevice\fP * dev)"
.PP
Creates an instance that operates on the given device. The device can be compressed (\fBKFilterDev\fP) or not (\fBQFile\fP, etc.). WARNING: don't assume that giving a \fBQFile\fP here will decompress the file, in case it's compressed! Definition at line 129 of file kzip.cpp.
.SS "KZip::~\fBKZip\fP ()\fC [virtual]\fP"
.PP
If the zip file is still opened, then it will be closed automatically by the destructor. Definition at line 136 of file kzip.cpp.
.PP
References KArchive::close(), KArchive::device(), QString::isEmpty(), and KArchive::isOpened().
.SH "Member Function Documentation"
.PP 
.SS "\fBQString\fP KZip::fileName ()\fC [inline]\fP"
.PP
The name of the zip file, as passed to the constructor Null if you used the \fBQIODevice\fP constructor. Definition at line 83 of file kzip.h.
.PP
Referenced by prepareWriting().
.SS "void KZip::setCompression (Compression c)"
.PP
Call this before writeFile or prepareWriting, to define whether the next files to be written should be compressed or not. Definition at line 762 of file kzip.cpp.
.SS "bool KZip::writeFile (const \fBQString\fP & name, const \fBQString\fP & user, const \fBQString\fP & group, uint size, const char * data)\fC [virtual]\fP"
.PP
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. 
.PP
\fBParameters:\fP
.RS 4
\fIname\fP can include subdirs e.g. path/to/the/file 
.RE
.PP
Reimplemented from \fBKArchive\fP.
.PP
Definition at line 553 of file kzip.cpp.
.PP
References QIODevice::at(), KArchive::device(), doneWriting(), KStdAccel::name(), and prepareWriting().
.SS "bool KZip::prepareWriting (const \fBQString\fP & name, const \fBQString\fP & user, const \fBQString\fP & group, uint size)\fC [virtual]\fP"
.PP
Alternative method: call prepareWriting, writeData in small chunks, doneWriting. \fBParameters:\fP
.RS 4
\fIsize\fP unused 
.RE
.PP
Implements \fBKArchive\fP.
.PP
Definition at line 580 of file kzip.cpp.
.PP
References KArchiveDirectory::addEntry(), QPtrListIterator::current(), KFilterDev::device(), KArchive::device(), QFile::encodeName(), fileName(), KArchive::findOrCreate(), QString::findRev(), KArchive::isOpened(), QString::left(), QCString::length(), QString::length(), QString::mid(), KArchive::mode(), KStdAccel::name(), KArchive::rootDir(), and QIODevice::writeBlock().
.PP
Referenced by writeFile().
.SS "bool KZip::doneWriting (uint size)\fC [virtual]\fP"
.PP
Call \fBdoneWriting\fP after writing the data. \fBSee also:\fP
.RS 4
\fBprepareWriting\fP 
.RE
.PP
Implements \fBKArchive\fP.
.PP
Definition at line 710 of file kzip.cpp.
.PP
References QIODevice::at(), and KArchive::device().
.PP
Referenced by writeFile().
.SS "bool KZip::openArchive (int mode)\fC [protected, virtual]\fP"
.PP
Opens the archive for reading. Parses the directory listing of the archive and creates the KArchiveDirectory/KArchiveFile entries. Implements \fBKArchive\fP.
.PP
Definition at line 147 of file kzip.cpp.
.PP
References KArchiveDirectory::addEntry(), QIODevice::at(), QDir::cleanDirPath(), KArchive::device(), QString::endsWith(), KArchiveDirectory::entry(), KArchive::findOrCreate(), QString::findRev(), QString::fromLocal8Bit(), KArchiveEntry::isDirectory(), QString::isEmpty(), QString::left(), QString::length(), QString::mid(), KStdAccel::name(), QIODevice::readBlock(), and KArchive::rootDir().
.SS "bool KZip::closeArchive ()\fC [protected, virtual]\fP"
.PP
Closes the archive. Called by \fBclose\fP. Implements \fBKArchive\fP.
.PP
Definition at line 392 of file kzip.cpp.
.PP
References QIODevice::at(), QPtrListIterator::current(), KArchive::device(), QFile::encodeName(), QCString::length(), KArchive::mode(), QPtrListIterator::toFirst(), and QIODevice::writeBlock().
.SS "virtual bool KZip::writeDir (const \fBQString\fP &, const \fBQString\fP &, const \fBQString\fP &)\fC [inline, protected, virtual]\fP"
.PP
If an archive is opened for writing then you can add new directories using this function. \fBKArchive\fP won't write one directory twice. Implements \fBKArchive\fP.
.PP
Definition at line 122 of file kzip.h.

.SH "Author"
.PP 
Generated automatically by Doxygen for kio Library from the source code.
