.TH "KTar" kde3 "11 Jun 2005" "Version Version 3.4.1" "kio Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KTar \- A class for reading / writing (optionally 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
.ti -1c
.RI "\fBKTar\fP (\fBQIODevice\fP *dev)"
.br
.ti -1c
.RI "virtual \fB~KTar\fP ()"
.br
.ti -1c
.RI "\fBQString\fP \fBfileName\fP ()"
.br
.ti -1c
.RI "void \fBsetOrigFileName\fP (const \fBQCString\fP &fileName)"
.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 "virtual bool \fBwriteDir\fP (const \fBQString\fP &name, const \fBQString\fP &user, const \fBQString\fP &group)"
.br
.ti -1c
.RI "bool \fBwriteDir\fP (const \fBQString\fP &name, const \fBQString\fP &user, const \fBQString\fP &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)"
.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 \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 "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 void \fBvirtual_hook\fP (int id, void *data)"
.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 \fBwriteDir_impl\fP (const \fBQString\fP &name, 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 \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 
A class for reading / writing (optionally compressed) tar archives. 

KTar allows you to read and write tar archives, including those that are compressed using gzip or bzip2.
.PP
\fBAuthor:\fP
.RS 4
Torben Weis <weis@kde.org>, David Faure <faure@kde.org> 
.RE
.PP

.PP
Definition at line 40 of file ktar.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KTar::KTar (const \fBQString\fP & filename, const \fBQString\fP & mimetype = \fCQString::null\fP)"
.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 similar - you only need to specify the compression layer ! If the mimetype is omitted, it will be determined from the filename. 
.RE
.PP

.PP
Definition at line 59 of file ktar.cpp.
.PP
References QFile::close(), endl(), KMimeType::findByFileContent(), KMimeType::findByPath(), QFile::getch(), QString::isEmpty(), kdDebug(), and QFile::open().
.SS "KTar::KTar (\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 read from. If the source is compressed, the \fBQIODevice\fP must take care of decompression 
.RE
.PP

.PP
Definition at line 144 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. 
.PP
Definition at line 150 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. 
.PP
\fBReturns:\fP
.RS 4
the name of the file, or QString::null if unknown 
.RE
.PP

.PP
Definition at line 76 of file ktar.h.
.PP
Referenced by setOrigFileName().
.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. 
.PP
It appears when using in the 'file' command, for instance. Should only be called if the underlying device is a KFilterDev! 
.PP
\fBParameters:\fP
.RS 4
\fIfileName\fP the original file name 
.RE
.PP

.PP
Definition at line 165 of file ktar.cpp.
.PP
References fileName(), KArchive::isOpened(), kdWarning(), and KArchive::mode().
.SS "bool KTar::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 869 of file ktar.cpp.
.PP
References KArchive::writeSymLink().
.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. 
.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 542 of file ktar.cpp.
.PP
References QIODevice::at(), KArchive::device(), KArchive::isOpened(), kdWarning(), QString::length(), QString::local8Bit(), KArchive::mode(), QString::right(), and QIODevice::writeBlock().
.SS "bool KTar::writeDir (const \fBQString\fP & name, const \fBQString\fP & user, const \fBQString\fP & group, mode_t perm, time_t atime, time_t mtime, time_t ctime)"
.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
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 directory 
.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 this virtual. For now use virtual hook 
.RE
.PP

.PP
Reimplemented from \fBKArchive\fP.
.PP
Definition at line 806 of file ktar.cpp.
.PP
References KArchive::writeDir().
.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 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, since it is needed in the header. For zip files, size isn't used.
.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 // TODO(BIC): make this a thin non-virtual wrapper around // prepareWriting(name,user,group,size,perm,atime,mtime,ctime) or eliminate it. 
.RE
.PP

.PP
Implements \fBKArchive\fP.
.PP
Definition at line 604 of file ktar.cpp.
.SS "bool KTar::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 735 of file ktar.cpp.
.PP
References KArchive::prepareWriting().
.SS "bool KTar::doneWriting (uint size)\fC [virtual]\fP"
.PP
Call doneWriting after writing the data. 
.PP
\fBParameters:\fP
.RS 4
\fIsize\fP the size of the file 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBprepareWriting()\fP 
.RE
.PP

.PP
Implements \fBKArchive\fP.
.PP
Definition at line 612 of file ktar.cpp.
.PP
References QIODevice::at(), KArchive::device(), KArchive::mode(), and QIODevice::writeBlock().
.SS "bool KTar::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 326 of file ktar.cpp.
.PP
References KArchiveDirectory::addEntry(), QIODevice::at(), QDir::cleanDirPath(), KArchive::device(), endl(), KArchive::findOrCreate(), QString::findRev(), kdDebug(), kdWarning(), QString::left(), QString::length(), QString::mid(), QString::right(), and KArchive::rootDir().
.SS "bool KTar::closeArchive ()\fC [protected, virtual]\fP"
.PP
Closes the archive. 
.PP
Called by close. 
.PP
Implements \fBKArchive\fP.
.PP
Definition at line 529 of file ktar.cpp.
.PP
References KArchive::mode().

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