.TH "KTar" 3 "28 Jan 2004" "kio Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KTar \- A class for reading/writing (optionnally compressed) tar archives.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <ktar.h>\fP
.PP
Inherits \fBKArchive\fP.
.PP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKTar\fP (const  \fBQString\fP &filename, const  \fBQString\fP &mimetype=QString::null)"
.br
.RI "\fICreates an instance that operates on the given filename. \fP"
.ti -1c
.RI "\fBKTar\fP (\fBQIODevice\fP *dev)"
.br
.RI "\fICreates an instance that operates on the given device. \fP"
.ti -1c
.RI "virtual \fB~KTar\fP ()"
.br
.RI "\fIIf the tar ball 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 tar file, as passed to the constructor Null if you used the \fBQIODevice\fP constructor. \fP"
.ti -1c
.RI "void \fBsetOrigFileName\fP (const  \fBQCString\fP &fileName)"
.br
.RI "\fISpecial function for setting the 'original file name' in the gzip header, when writing a tar.gz file. \fP"
.ti -1c
.RI "virtual bool \fBwriteDir\fP (const  \fBQString\fP &name, const  \fBQString\fP &user, const  \fBQString\fP &group)"
.br
.RI "\fIIf an archive is opened for writing then you can add new directories 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 "\fIHere's another way of writing a file into an archive: Call \fBprepareWriting\fP, then call \fBdevice()\fP->writeBlock() (for tar files) or writeData (for zip files) [NEW VIRTUAL METHOD NEEDED] as many times as wanted then call \fBdoneWriting\fP( totalSize ) 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. \fP"
.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 void \fBvirtual_hook\fP (int id, void *data)"
.br
.in -1c
.SH "Detailed Description"
.PP 
A class for reading/writing (optionnally compressed) tar archives. 

\fBAuthor:\fP
.RS 4
Torben Weis <weis@kde.org>, David Faure <faure@kde.org> 
.RE
.PP

.PP
Definition at line 35 of file ktar.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KTar::KTar (const \fBQString\fP & filename, const \fBQString\fP & mimetype = QString::null)"
.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/weis/myfile.tgz') 
.br
\fImimetype\fP 'application/x-gzip' or 'application/x-bzip2' Do not use application/x-tgz or so. Only the compression layer ! If the mimetype is ommitted, it will be determined from the filename. 
.RE
.PP
Definition at line 49 of file ktar.cpp.
.PP
References QFile::exists(), KMimeType::findByFileContent(), KMimeType::findByPath(), QFile::getch(), KIO::mimetype(), and QFile::open().
.SS "KTar::KTar (\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 115 of file ktar.cpp.
.SS "KTar::~\fBKTar\fP ()\fC [virtual]\fP"
.PP
If the tar ball is still opened, then it will be closed automatically by the destructor. Definition at line 121 of file ktar.cpp.
.PP
References KArchive::close(), KArchive::device(), QString::isEmpty(), and KArchive::isOpened().
.SH "Member Function Documentation"
.PP 
.SS "\fBQString\fP KTar::fileName ()\fC [inline]\fP"
.PP
The name of the tar file, as passed to the constructor Null if you used the \fBQIODevice\fP constructor. Definition at line 67 of file ktar.h.
.PP
Referenced by prepareWriting().
.SS "void KTar::setOrigFileName (const \fBQCString\fP & fileName)"
.PP
Special function for setting the 'original file name' in the gzip header, when writing a tar.gz file. It appears when using in the 'file' command, for instance. Should only be called if the underlying device is a KFilterDev! Definition at line 131 of file ktar.cpp.
.PP
References KArchive::device(), KArchive::isOpened(), and KArchive::mode().
.SS "bool KTar::writeDir (const \fBQString\fP & name, const \fBQString\fP & user, const \fBQString\fP & group)\fC [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 342 of file ktar.cpp.
.PP
References QDir::cleanDirPath(), KArchive::device(), QFile::encodeName(), KArchive::isOpened(), QString::length(), QString::local8Bit(), KArchive::mode(), KStdAccel::name(), QString::right(), and QIODevice::writeBlock().
.SS "bool KTar::prepareWriting (const \fBQString\fP & name, const \fBQString\fP & user, const \fBQString\fP & group, uint size)\fC [virtual]\fP"
.PP
Here's another way of writing a file into an archive: Call \fBprepareWriting\fP, then call \fBdevice()\fP->writeBlock() (for tar files) or writeData (for zip files) [NEW VIRTUAL METHOD NEEDED] as many times as wanted then call \fBdoneWriting\fP( totalSize ) 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 \fBKArchive\fP.
.PP
Definition at line 397 of file ktar.cpp.
.PP
References QDir::cleanDirPath(), KArchive::device(), QFile::encodeName(), fileName(), KArchive::isOpened(), QString::length(), QString::local8Bit(), KArchive::mode(), KStdAccel::name(), and QIODevice::writeBlock().
.SS "bool KTar::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 462 of file ktar.cpp.
.PP
References KArchive::device(), and QIODevice::writeBlock().
.SS "bool KTar::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 142 of file ktar.cpp.
.PP
References KArchiveDirectory::addEntry(), QIODevice::at(), QDir::cleanDirPath(), KArchive::device(), KArchive::findOrCreate(), QString::findRev(), QString::fromLocal8Bit(), QString::left(), QString::length(), QCString::length(), QString::mid(), KStdAccel::name(), QIODevice::readBlock(), QString::right(), KArchive::rootDir(), QCString::sprintf(), and KIO::symlink().
.SS "bool KTar::closeArchive ()\fC [protected, virtual]\fP"
.PP
Closes the archive. Called by \fBclose\fP. Implements \fBKArchive\fP.
.PP
Definition at line 336 of file ktar.cpp.

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