\section{KTar Class Reference}
\label{classKTar}\index{KTar@{KTar}}
A class for reading/writing (optionnally compressed) tar archives.  


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

Inheritance diagram for KTar:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=47pt]{classKTar__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KTar:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=105pt]{classKTar__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KTar} (const  {\bf QString} \&filename, const  {\bf QString} \&mimetype=QString::null)
\begin{CompactList}\small\item\em Creates an instance that operates on the given filename. \item\end{CompactList}\item 
{\bf KTar} ({\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$KTar} ()
\begin{CompactList}\small\item\em If the tar ball 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 tar file, as passed to the constructor Null if you used the {\bf QIODevice} constructor. \item\end{CompactList}\item 
void {\bf set\-Orig\-File\-Name} (const  {\bf QCString} \&file\-Name)
\begin{CompactList}\small\item\em Special function for setting the \char`\"{}original file name\char`\"{} in the gzip header, when writing a tar.gz file. \item\end{CompactList}\item 
virtual bool {\bf write\-Dir} (const  {\bf QString} \&name, const  {\bf QString} \&user, const  {\bf QString} \&group)
\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 bool {\bf prepare\-Writing} (const  {\bf QString} \&name, const  {\bf QString} \&user, const  {\bf QString} \&group, uint size)
\begin{CompactList}\small\item\em Here's another way of writing a file into an archive: Call {\bf prepare\-Writing}{\rm (p.\,\pageref{classKTar_a6})}, then call {\bf device()}{\rm (p.\,\pageref{classKArchive_a5})}-$>$write\-Block() (for tar files) or write\-Data (for zip files) [NEW VIRTUAL METHOD NEEDED] as many times as wanted then call {\bf done\-Writing}{\rm (p.\,\pageref{classKTar_a7})}( total\-Size ) 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. \item\end{CompactList}\item 
virtual bool {\bf done\-Writing} (uint size)
\begin{CompactList}\small\item\em Call {\bf done\-Writing}{\rm (p.\,\pageref{classKTar_a7})} 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 void {\bf virtual\_\-hook} (int id, void $\ast$data)\label{classKTar_b2}

\end{CompactItemize}


\subsection{Detailed Description}
A class for reading/writing (optionnally compressed) tar archives. 

\begin{Desc}
\item[Author:]Torben Weis $<${\tt weis@kde.org}$>$, David Faure $<${\tt faure@kde.org}$>$ \end{Desc}




Definition at line 35 of file ktar.h.

\subsection{Constructor \& Destructor Documentation}
\index{KTar@{KTar}!KTar@{KTar}}
\index{KTar@{KTar}!KTar@{KTar}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KTar::KTar (const {\bf QString} \& {\em filename}, const {\bf QString} \& {\em mimetype} = QString::null)}\label{classKTar_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/weis/myfile.tgz\char`\"{}) \item[{\em mimetype}]\char`\"{}application/x-gzip\char`\"{} or \char`\"{}application/x-bzip2\char`\"{} Do not use application/x-tgz or so. Only the compression layer ! If the mimetype is ommitted, it will be determined from the filename. \end{description}
\end{Desc}


Definition at line 49 of file ktar.cpp.

References QFile::exists(), KMime\-Type::find\-By\-File\-Content(), KMime\-Type::find\-By\-Path(), QFile::getch(), KIO::mimetype(), and QFile::open().\index{KTar@{KTar}!KTar@{KTar}}
\index{KTar@{KTar}!KTar@{KTar}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KTar::KTar ({\bf QIODevice} $\ast$ {\em dev})}\label{classKTar_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 115 of file ktar.cpp.\index{KTar@{KTar}!~KTar@{$\sim$KTar}}
\index{~KTar@{$\sim$KTar}!KTar@{KTar}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KTar::$\sim${\bf KTar} ()\hspace{0.3cm}{\tt  [virtual]}}\label{classKTar_a2}


If the tar ball is still opened, then it will be closed automatically by the destructor. 



Definition at line 121 of file ktar.cpp.

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

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


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



Definition at line 67 of file ktar.h.

Referenced by prepare\-Writing().\index{KTar@{KTar}!setOrigFileName@{setOrigFileName}}
\index{setOrigFileName@{setOrigFileName}!KTar@{KTar}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KTar::set\-Orig\-File\-Name (const {\bf QCString} \& {\em file\-Name})}\label{classKTar_a4}


Special function for setting the \char`\"{}original file name\char`\"{} in the gzip header, when writing a tar.gz file. 

It appears when using in the \char`\"{}file\char`\"{} command, for instance. Should only be called if the underlying device is a KFilter\-Dev! 

Definition at line 131 of file ktar.cpp.

References KArchive::device(), KArchive::is\-Opened(), and KArchive::mode().\index{KTar@{KTar}!writeDir@{writeDir}}
\index{writeDir@{writeDir}!KTar@{KTar}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KTar::write\-Dir (const {\bf QString} \& {\em name}, const {\bf QString} \& {\em user}, const {\bf QString} \& {\em group})\hspace{0.3cm}{\tt  [virtual]}}\label{classKTar_a5}


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 342 of file ktar.cpp.

References QDir::clean\-Dir\-Path(), KArchive::device(), QFile::encode\-Name(), KArchive::is\-Opened(), QString::length(), QString::local8Bit(), KArchive::mode(), KStd\-Accel::name(), QString::right(), and QIODevice::write\-Block().\index{KTar@{KTar}!prepareWriting@{prepareWriting}}
\index{prepareWriting@{prepareWriting}!KTar@{KTar}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KTar::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{classKTar_a6}


Here's another way of writing a file into an archive: Call {\bf prepare\-Writing}{\rm (p.\,\pageref{classKTar_a6})}, then call {\bf device()}{\rm (p.\,\pageref{classKArchive_a5})}-$>$write\-Block() (for tar files) or write\-Data (for zip files) [NEW VIRTUAL METHOD NEEDED] as many times as wanted then call {\bf done\-Writing}{\rm (p.\,\pageref{classKTar_a7})}( total\-Size ) 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. 



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

Definition at line 397 of file ktar.cpp.

References QDir::clean\-Dir\-Path(), KArchive::device(), QFile::encode\-Name(), file\-Name(), KArchive::is\-Opened(), QString::length(), QString::local8Bit(), KArchive::mode(), KStd\-Accel::name(), and QIODevice::write\-Block().\index{KTar@{KTar}!doneWriting@{doneWriting}}
\index{doneWriting@{doneWriting}!KTar@{KTar}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KTar::done\-Writing (uint {\em size})\hspace{0.3cm}{\tt  [virtual]}}\label{classKTar_a7}


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

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


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

Definition at line 462 of file ktar.cpp.

References KArchive::device(), and QIODevice::write\-Block().\index{KTar@{KTar}!openArchive@{openArchive}}
\index{openArchive@{openArchive}!KTar@{KTar}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KTar::open\-Archive (int {\em mode})\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKTar_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 142 of file ktar.cpp.

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


Closes the archive. 

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

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

Definition at line 336 of file ktar.cpp.

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