.TH "KZip" kde3 "11 Jun 2005" "Version Version 3.4.1" "kio Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KZip \- This class implements a kioslave to access zip files from \fBKDE\fP. 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 \fBExtraField\fP { \fBNoExtraField\fP =  0, \fBModificationTime\fP =  1, \fBDefaultExtraField\fP =  1 }"
.br
.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
.ti -1c
.RI "\fBKZip\fP (\fBQIODevice\fP *dev)"
.br
.ti -1c
.RI "virtual \fB~KZip\fP ()"
.br
.ti -1c
.RI "\fBQString\fP \fBfileName\fP ()"
.br
.ti -1c
.RI "void \fBsetExtraField\fP (\fBExtraField\fP ef)"
.br
.ti -1c
.RI "\fBExtraField\fP \fBextraField\fP () const "
.br
.ti -1c
.RI "void \fBsetCompression\fP (\fBCompression\fP c)"
.br
.ti -1c
.RI "\fBCompression\fP \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
.ti -1c
.RI "virtual bool \fBprepareWriting\fP (const \fBQString\fP &name, const \fBQString\fP &user, const \fBQString\fP &group, uint size)"
.br
.ti -1c
.RI "bool \fBwriteSymLink\fP (const \fBQString\fP &name, const \fBQString\fP &target, const \fBQString\fP &user, const \fBQString\fP &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)"
.br
.ti -1c
.RI "bool \fBprepareWriting\fP (const \fBQString\fP &name, const \fBQString\fP &user, const \fBQString\fP &group, uint size, mode_t perm, time_t atime, time_t mtime, time_t ctime)"
.br
.ti -1c
.RI "bool \fBwriteFile\fP (const \fBQString\fP &name, const \fBQString\fP &user, const \fBQString\fP &group, uint size, mode_t perm, time_t atime, time_t mtime, time_t ctime, const char *data)"
.br
.ti -1c
.RI "bool \fBwriteData\fP (const char *data, uint size)"
.br
.ti -1c
.RI "virtual bool \fBdoneWriting\fP (uint size)"
.br
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "virtual bool \fBopenArchive\fP (int mode)"
.br
.ti -1c
.RI "virtual bool \fBcloseArchive\fP ()"
.br
.ti -1c
.RI "virtual bool \fBwriteDir\fP (const \fBQString\fP &, const \fBQString\fP &, const \fBQString\fP &)"
.br
.ti -1c
.RI "virtual void \fBvirtual_hook\fP (int id, void *data)"
.br
.ti -1c
.RI "bool \fBwriteData_impl\fP (const char *data, uint size)"
.br
.ti -1c
.RI "bool \fBprepareWriting_impl\fP (const \fBQString\fP &name, const \fBQString\fP &user, const \fBQString\fP &group, uint size, mode_t perm, time_t atime, time_t mtime, time_t ctime)"
.br
.ti -1c
.RI "bool \fBwriteSymLink_impl\fP (const \fBQString\fP &name, const \fBQString\fP &target, const \fBQString\fP &user, const \fBQString\fP &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)"
.br
.in -1c
.SH "Detailed Description"
.PP 
This class implements a kioslave to access zip files from \fBKDE\fP. A class for reading/writing zip archives. 

You can use it in IO_ReadOnly or in IO_WriteOnly mode, and it behaves just as expected. 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, i.e. the files 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 garbage-free zipfile, just read the contents of the appended zip file and write it to a new one in IO_WriteOnly mode. This is especially important 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/products/enterprise/white_papers/appnote.html 
.PP
\fBAuthor:\fP
.RS 4
Holger Schroeder <holger-kde@holgis.net> 
.RE
.PP
\fBSince:\fP
.RS 4
3.1 
.RE
.PP

.PP
Definition at line 53 of file kzip.h.
.SH "Member Enumeration Documentation"
.PP 
.SS "enum \fBKZip::ExtraField\fP"
.PP
Describes the contents of the 'extra field' for a given file in the Zip archive. 
.PP
\fBEnumeration values: \fP
.in +1c
.TP
\fB\fIModificationTime \fP\fP
No extra field. 
.TP
\fB\fIDefaultExtraField \fP\fP
Modification time ('extended timestamp' header). 
.PP
Definition at line 89 of file kzip.h.
.SS "enum \fBKZip::Compression\fP"
.PP
Describes the compression type for a given file in the Zip archive. 
.PP
\fBEnumeration values: \fP
.in +1c
.TP
\fB\fINoCompression \fP\fP
Uncompressed. 
.TP
\fB\fIDeflateCompression \fP\fP
Deflate compression method. 
.PP
Definition at line 112 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. 
.PP
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

.PP
Definition at line 335 of file kzip.cpp.
.SS "KZip::KZip (\fBQIODevice\fP * dev)"
.PP
Creates an instance that operates on the given device. 
.PP
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! 
.PP
\fBParameters:\fP
.RS 4
\fIdev\fP the device to access 
.RE
.PP

.PP
Definition at line 347 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. 
.PP
Definition at line 354 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. 
.PP
Null if you used the \fBQIODevice\fP constructor. 
.PP
\fBReturns:\fP
.RS 4
the zip's file name, or null if a \fBQIODevice\fP is used 
.RE
.PP

.PP
Definition at line 84 of file kzip.h.
.SS "void KZip::setExtraField (\fBExtraField\fP ef)"
.PP
Call this before writeFile or prepareWriting, to define what the next file to be written should have in its extra field. 
.PP
\fBParameters:\fP
.RS 4
\fIef\fP the type of 'extra field' 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBextraField()\fP 
.RE
.PP

.PP
Definition at line 1350 of file kzip.cpp.
.SS "\fBKZip::ExtraField\fP KZip::extraField () const"
.PP
The current type of 'extra field' that will be used for new files. 
.PP
\fBReturns:\fP
.RS 4
the current type of 'extra field' 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBsetExtraField()\fP 
.RE
.PP

.PP
Definition at line 1355 of file kzip.cpp.
.SS "void KZip::setCompression (\fBCompression\fP c)"
.PP
Call this before writeFile or prepareWriting, to define whether the next files to be written should be compressed or not. 
.PP
\fBParameters:\fP
.RS 4
\fIc\fP the new compression mode 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBcompression()\fP 
.RE
.PP

.PP
Definition at line 1340 of file kzip.cpp.
.PP
References NoCompression.
.SS "\fBKZip::Compression\fP KZip::compression () const"
.PP
The current compression mode that will be used for new files. 
.PP
\fBReturns:\fP
.RS 4
the current compression mode 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBsetCompression()\fP 
.RE
.PP

.PP
Definition at line 1345 of file kzip.cpp.
.PP
References DeflateCompression, and NoCompression.
.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. 
.PP
This method takes the whole data at once. 
.PP
\fBParameters:\fP
.RS 4
\fIname\fP can include subdirs e.g. path/to/the/file 
.br
\fIuser\fP the user owning the file 
.br
\fIgroup\fP the group owning the file 
.br
\fIsize\fP the size of the file 
.br
\fIdata\fP a pointer to the data 
.RE
.PP
\fBReturns:\fP
.RS 4
true if successful, false otherwise 
.RE
.PP

.PP
Reimplemented from \fBKArchive\fP.
.PP
Definition at line 1001 of file kzip.cpp.
.PP
References KArchive::writeFile().
.SS "bool KZip::prepareWriting (const \fBQString\fP & name, const \fBQString\fP & user, const \fBQString\fP & group, uint size)\fC [virtual]\fP"
.PP
Alternative method for writing: call \fBprepareWriting()\fP, then feed the data in small chunks using \fBwriteData()\fP, and call \fBdoneWriting()\fP when done. 
.PP
\fBParameters:\fP
.RS 4
\fIname\fP can include subdirs e.g. path/to/the/file 
.br
\fIuser\fP the user owning the file 
.br
\fIgroup\fP the group owning the file 
.br
\fIsize\fP unused argument 
.RE
.PP
\fBReturns:\fP
.RS 4
true if successful, false otherwise 
.RE
.PP

.PP
Implements \fBKArchive\fP.
.PP
Definition at line 1019 of file kzip.cpp.
.SS "bool KZip::writeSymLink (const \fBQString\fP & name, const \fBQString\fP & target, const \fBQString\fP & user, const \fBQString\fP & group, mode_t perm, time_t atime, time_t mtime, time_t ctime)"
.PP
Writes a symbolic link to the archive if the archive must be opened for writing. 
.PP
\fBParameters:\fP
.RS 4
\fIname\fP name of symbolic link 
.br
\fItarget\fP target of symbolic link 
.br
\fIuser\fP the user that owns the directory 
.br
\fIgroup\fP the group that owns the directory 
.br
\fIperm\fP permissions of the directory 
.br
\fIatime\fP time the file was last accessed 
.br
\fImtime\fP modification time of the file 
.br
\fIctime\fP creation time of the file 
.RE
.PP
\fBSince:\fP
.RS 4
3.2 // TODO(BIC) make virtual. For now it must be implemented by virtual_hook. 
.RE
.PP

.PP
Reimplemented from \fBKArchive\fP.
.PP
Definition at line 1247 of file kzip.cpp.
.PP
References KArchive::writeSymLink().
.SS "bool KZip::prepareWriting (const \fBQString\fP & name, const \fBQString\fP & user, const \fBQString\fP & group, uint size, mode_t perm, time_t atime, time_t mtime, time_t ctime)"
.PP
Here's another way of writing a file into an archive: Call prepareWriting, then call \fBwriteData()\fP as many times as wanted then call doneWriting( totalSize ). 
.PP
For tar.gz files, you need to know the size before hand, it is needed in the header! For zip files, size isn't used.
.PP
This method also allows some file metadata to be set. However, depending on the archive type not all metadata might be regarded. 
.PP
\fBParameters:\fP
.RS 4
\fIname\fP the name of the file 
.br
\fIuser\fP the user that owns the file 
.br
\fIgroup\fP the group that owns the file 
.br
\fIsize\fP the size of the file 
.br
\fIperm\fP permissions of the file 
.br
\fIatime\fP time the file was last accessed 
.br
\fImtime\fP modification time of the file 
.br
\fIctime\fP creation time of the file 
.RE
.PP
\fBSince:\fP
.RS 4
3.2 // TODO(BIC): make this virtual. For now use virtual hook. 
.RE
.PP

.PP
Reimplemented from \fBKArchive\fP.
.PP
Definition at line 1028 of file kzip.cpp.
.PP
References KArchive::prepareWriting().
.SS "bool KZip::writeFile (const \fBQString\fP & name, const \fBQString\fP & user, const \fBQString\fP & group, uint size, mode_t perm, time_t atime, time_t mtime, time_t ctime, const char * data)"
.PP
If an archive is opened for writing then you can add a new file using this function. 
.PP
If the file name is for example 'mydir/test1' then the directory 'mydir' is automatically appended first if that did not happen yet.
.PP
This method also allows some file metadata to be set. However, depending on the archive type not all metadata might be regarded. 
.PP
\fBParameters:\fP
.RS 4
\fIname\fP the name of the file 
.br
\fIuser\fP the user that owns the file 
.br
\fIgroup\fP the group that owns the file 
.br
\fIsize\fP the size of the file 
.br
\fIperm\fP permissions of the file 
.br
\fIatime\fP time the file was last accessed 
.br
\fImtime\fP modification time of the file 
.br
\fIctime\fP creation time of the file 
.br
\fIdata\fP the data to write (\fCsize\fP bytes) 
.RE
.PP
\fBSince:\fP
.RS 4
3.2 // TODO(BIC): make virtual. For now use virtual hook 
.RE
.PP

.PP
Reimplemented from \fBKArchive\fP.
.PP
Definition at line 1010 of file kzip.cpp.
.PP
References KArchive::writeFile().
.SS "bool KZip::writeData (const char * data, uint size)"
.PP
Write data to a file that has been created using \fBprepareWriting()\fP. 
.PP
\fBParameters:\fP
.RS 4
\fIdata\fP a pointer to the data 
.br
\fIsize\fP the size of the chunk 
.RE
.PP
\fBReturns:\fP
.RS 4
true if successful, false otherwise 
.RE
.PP

.PP
Reimplemented from \fBKArchive\fP.
.PP
Definition at line 1314 of file kzip.cpp.
.PP
References KArchive::writeData().
.SS "bool KZip::doneWriting (uint size)\fC [virtual]\fP"
.PP
Write data to a file that has been created using \fBprepareWriting()\fP. 
.PP
\fBParameters:\fP
.RS 4
\fIsize\fP the size of the file 
.RE
.PP
\fBReturns:\fP
.RS 4
true if successful, false otherwise 
.RE
.PP

.PP
Implements \fBKArchive\fP.
.PP
Definition at line 1210 of file kzip.cpp.
.PP
References QIODevice::at(), KArchive::device(), ModificationTime, and QIODevice::writeBlock().
.SS "bool KZip::openArchive (int mode)\fC [protected, virtual]\fP"
.PP
Opens the archive for reading. 
.PP
Parses the directory listing of the archive and creates the KArchiveDirectory/KArchiveFile entries. 
.PP
\fBParameters:\fP
.RS 4
\fImode\fP the mode of the file 
.RE
.PP

.PP
Implements \fBKArchive\fP.
.PP
Definition at line 369 of file kzip.cpp.
.PP
References KArchiveDirectory::addEntry(), QIODevice::at(), QDir::cleanDirPath(), QFile::decodeName(), KArchive::device(), endl(), QString::endsWith(), KArchiveDirectory::entry(), KArchive::findOrCreate(), QString::findRev(), QAsciiDict::insert(), KArchiveEntry::isDirectory(), QString::isEmpty(), kdDebug(), kdWarning(), QString::left(), QString::length(), QString::mid(), NoCompression, KArchive::open(), QIODevice::readBlock(), KArchive::rootDir(), QAsciiDict::setAutoDelete(), and QIODevice::size().
.SS "bool KZip::closeArchive ()\fC [protected, virtual]\fP"
.PP
Closes the archive. 
.PP
Implements \fBKArchive\fP.
.PP
Definition at line 801 of file kzip.cpp.
.PP
References QIODevice::at(), QIODevice::close(), KArchive::device(), QFile::encodeName(), endl(), k_funcinfo, kdDebug(), QCString::length(), KArchive::mode(), QIODevice::size(), 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. 
.PP
\fBKArchive\fP won't write one directory twice.
.PP
\fBParameters:\fP
.RS 4
\fIname\fP the name of the directory 
.br
\fIuser\fP the user that owns the directory 
.br
\fIgroup\fP the group that owns the directory // TODO(BIC): make this a thin wrapper around // writeDir(name,user,group,perm,atime,mtime,ctime) // or elimitate it 
.RE
.PP

.PP
Implements \fBKArchive\fP.
.PP
Definition at line 197 of file kzip.h.

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