\section{KZip Class Reference}
\label{classKZip}\index{KZip@{KZip}}
A class for reading/writing zip archives.  


{\tt \#include $<$kzip.h$>$}

Inheritance diagram for KZip:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=47pt]{classKZip__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KZip:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=105pt]{classKZip__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Types}
\begin{CompactItemize}
\item 
enum {\bf Compression} \{ {\bf No\-Compression} =  0, 
{\bf Deflate\-Compression} =  1
 \}
\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KZip} (const  {\bf QString} \&filename)
\begin{CompactList}\small\item\em Creates an instance that operates on the given filename. \item\end{CompactList}\item 
{\bf KZip} ({\bf QIODevice} $\ast$dev)
\begin{CompactList}\small\item\em Creates an instance that operates on the given device. \item\end{CompactList}\item 
virtual {\bf $\sim$KZip} ()
\begin{CompactList}\small\item\em If the zip file is still opened, then it will be closed automatically by the destructor. \item\end{CompactList}\item 
{\bf QString} {\bf file\-Name} ()
\begin{CompactList}\small\item\em The name of the zip file, as passed to the constructor Null if you used the {\bf QIODevice} constructor. \item\end{CompactList}\item 
void {\bf set\-Compression} (Compression c)
\begin{CompactList}\small\item\em Call this before write\-File or prepare\-Writing, to define whether the next files to be written should be compressed or not. \item\end{CompactList}\item 
Compression {\bf compression} () const \label{classKZip_a5}

\item 
virtual bool {\bf write\-File} (const  {\bf QString} \&name, const  {\bf QString} \&user, const  {\bf QString} \&group, uint size, const  char $\ast$data)
\begin{CompactList}\small\item\em If an archive is opened for writing then you can add a new file using this function. \item\end{CompactList}\item 
virtual bool {\bf prepare\-Writing} (const  {\bf QString} \&name, const  {\bf QString} \&user, const  {\bf QString} \&group, uint size)
\begin{CompactList}\small\item\em Alternative method: call prepare\-Writing, write\-Data in small chunks, done\-Writing. \item\end{CompactList}\item 
bool {\bf write\-Data} (const  char $\ast$data, uint size)\label{classKZip_a8}

\item 
virtual bool {\bf done\-Writing} (uint size)
\begin{CompactList}\small\item\em Call {\bf done\-Writing}{\rm (p.\,\pageref{classKZip_a9})} after writing the data. \item\end{CompactList}\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual bool {\bf open\-Archive} (int mode)
\begin{CompactList}\small\item\em Opens the archive for reading. \item\end{CompactList}\item 
virtual bool {\bf close\-Archive} ()
\begin{CompactList}\small\item\em Closes the archive. \item\end{CompactList}\item 
virtual bool {\bf write\-Dir} (const  {\bf QString} \&, const  {\bf QString} \&, const  {\bf QString} \&)
\begin{CompactList}\small\item\em If an archive is opened for writing then you can add new directories using this function. \item\end{CompactList}\item 
virtual void {\bf virtual\_\-hook} (int id, void $\ast$data)\label{classKZip_b3}

\end{CompactItemize}


\subsection{Detailed Description}
A class for reading/writing zip archives. 

\begin{Desc}
\item[Author:]Holger Schroeder $<${\tt holger-kde@holgis.net}$>$\end{Desc}
This class implements a kioslave to acces ZIP files from {\bf KDE}. you can use it in IO\_\-Read\-Only or in IO\_\-Write\-Only mode, and it behaves just as expected (i hope ;-) ). It can also be used in IO\_\-Read\-Write 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\_\-Write\-Only mode. exspecially take care of this, when you don180t want to leak information of how intermediate versions of files in the zip were looking. for more information on the zip fileformat go to {\tt http://www.pkware.com/support/appnote.html} . \begin{Desc}
\item[Since:]3.1 \end{Desc}




Definition at line 54 of file kzip.h.

\subsection{Constructor \& Destructor Documentation}
\index{KZip@{KZip}!KZip@{KZip}}
\index{KZip@{KZip}!KZip@{KZip}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KZip::KZip (const {\bf QString} \& {\em filename})}\label{classKZip_a0}


Creates an instance that operates on the given filename. 

using the compression filter associated to given mimetype.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em filename}]is a local path (e.g. \char`\"{}/home/holger/myfile.zip\char`\"{}) \end{description}
\end{Desc}


Definition at line 120 of file kzip.cpp.\index{KZip@{KZip}!KZip@{KZip}}
\index{KZip@{KZip}!KZip@{KZip}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KZip::KZip ({\bf QIODevice} $\ast$ {\em dev})}\label{classKZip_a1}


Creates an instance that operates on the given device. 

The device can be compressed ({\bf KFilter\-Dev}{\rm (p.\,\pageref{classKFilterDev})}) or not ({\bf QFile}, etc.). WARNING: don't assume that giving a {\bf QFile} here will decompress the file, in case it's compressed! 

Definition at line 129 of file kzip.cpp.\index{KZip@{KZip}!~KZip@{$\sim$KZip}}
\index{~KZip@{$\sim$KZip}!KZip@{KZip}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KZip::$\sim${\bf KZip} ()\hspace{0.3cm}{\tt  [virtual]}}\label{classKZip_a2}


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



Definition at line 136 of file kzip.cpp.

References KArchive::close(), KArchive::device(), QString::is\-Empty(), and KArchive::is\-Opened().

\subsection{Member Function Documentation}
\index{KZip@{KZip}!fileName@{fileName}}
\index{fileName@{fileName}!KZip@{KZip}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString} KZip::file\-Name ()\hspace{0.3cm}{\tt  [inline]}}\label{classKZip_a3}


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



Definition at line 83 of file kzip.h.

Referenced by prepare\-Writing().\index{KZip@{KZip}!setCompression@{setCompression}}
\index{setCompression@{setCompression}!KZip@{KZip}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KZip::set\-Compression (Compression {\em c})}\label{classKZip_a4}


Call this before write\-File or prepare\-Writing, to define whether the next files to be written should be compressed or not. 



Definition at line 762 of file kzip.cpp.\index{KZip@{KZip}!writeFile@{writeFile}}
\index{writeFile@{writeFile}!KZip@{KZip}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KZip::write\-File (const {\bf QString} \& {\em name}, const {\bf QString} \& {\em user}, const {\bf QString} \& {\em group}, uint {\em size}, const char $\ast$ {\em data})\hspace{0.3cm}{\tt  [virtual]}}\label{classKZip_a6}


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. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em name}]can include subdirs e.g. path/to/the/file \end{description}
\end{Desc}


Reimplemented from {\bf KArchive} {\rm (p.\,\pageref{classKArchive_a8})}.

Definition at line 553 of file kzip.cpp.

References QIODevice::at(), KArchive::device(), done\-Writing(), KStd\-Accel::name(), and prepare\-Writing().\index{KZip@{KZip}!prepareWriting@{prepareWriting}}
\index{prepareWriting@{prepareWriting}!KZip@{KZip}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KZip::prepare\-Writing (const {\bf QString} \& {\em name}, const {\bf QString} \& {\em user}, const {\bf QString} \& {\em group}, uint {\em size})\hspace{0.3cm}{\tt  [virtual]}}\label{classKZip_a7}


Alternative method: call prepare\-Writing, write\-Data in small chunks, done\-Writing. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em size}]unused \end{description}
\end{Desc}


Implements {\bf KArchive} {\rm (p.\,\pageref{classKArchive_a9})}.

Definition at line 580 of file kzip.cpp.

References KArchive\-Directory::add\-Entry(), QPtr\-List\-Iterator::current(), KFilter\-Dev::device(), KArchive::device(), QFile::encode\-Name(), file\-Name(), KArchive::find\-Or\-Create(), QString::find\-Rev(), KArchive::is\-Opened(), QString::left(), QCString::length(), QString::length(), QString::mid(), KArchive::mode(), KStd\-Accel::name(), KArchive::root\-Dir(), and QIODevice::write\-Block().

Referenced by write\-File().\index{KZip@{KZip}!doneWriting@{doneWriting}}
\index{doneWriting@{doneWriting}!KZip@{KZip}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KZip::done\-Writing (uint {\em size})\hspace{0.3cm}{\tt  [virtual]}}\label{classKZip_a9}


Call {\bf done\-Writing}{\rm (p.\,\pageref{classKZip_a9})} after writing the data. 

\begin{Desc}
\item[See also:]{\bf prepare\-Writing}{\rm (p.\,\pageref{classKZip_a7})} \end{Desc}


Implements {\bf KArchive} {\rm (p.\,\pageref{classKArchive_a10})}.

Definition at line 710 of file kzip.cpp.

References QIODevice::at(), and KArchive::device().

Referenced by write\-File().\index{KZip@{KZip}!openArchive@{openArchive}}
\index{openArchive@{openArchive}!KZip@{KZip}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KZip::open\-Archive (int {\em mode})\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKZip_b0}


Opens the archive for reading. 

Parses the directory listing of the archive and creates the KArchive\-Directory/KArchive\-File entries. 

Implements {\bf KArchive} {\rm (p.\,\pageref{classKArchive_b1})}.

Definition at line 147 of file kzip.cpp.

References KArchive\-Directory::add\-Entry(), QIODevice::at(), QDir::clean\-Dir\-Path(), KArchive::device(), QString::ends\-With(), KArchive\-Directory::entry(), KArchive::find\-Or\-Create(), QString::find\-Rev(), QString::from\-Local8Bit(), KArchive\-Entry::is\-Directory(), QString::is\-Empty(), QString::left(), QString::length(), QString::mid(), KStd\-Accel::name(), QIODevice::read\-Block(), and KArchive::root\-Dir().\index{KZip@{KZip}!closeArchive@{closeArchive}}
\index{closeArchive@{closeArchive}!KZip@{KZip}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KZip::close\-Archive ()\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKZip_b1}


Closes the archive. 

Called by {\bf close}{\rm (p.\,\pageref{classKArchive_a2})}. 

Implements {\bf KArchive} {\rm (p.\,\pageref{classKArchive_b2})}.

Definition at line 392 of file kzip.cpp.

References QIODevice::at(), QPtr\-List\-Iterator::current(), KArchive::device(), QFile::encode\-Name(), QCString::length(), KArchive::mode(), QPtr\-List\-Iterator::to\-First(), and QIODevice::write\-Block().\index{KZip@{KZip}!writeDir@{writeDir}}
\index{writeDir@{writeDir}!KZip@{KZip}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}virtual bool KZip::write\-Dir (const {\bf QString} \&, const {\bf QString} \&, const {\bf QString} \&)\hspace{0.3cm}{\tt  [inline, protected, virtual]}}\label{classKZip_b2}


If an archive is opened for writing then you can add new directories using this function. 

{\bf KArchive}{\rm (p.\,\pageref{classKArchive})} won't write one directory twice. 

Implements {\bf KArchive} {\rm (p.\,\pageref{classKArchive_a7})}.

Definition at line 122 of file kzip.h.

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
kzip.h\item 
kzip.cpp\end{CompactItemize}
