.TH "KArchive" 3 "28 Jan 2004" "kio Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KArchive \- generic class for reading/writing archives  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <karchive.h>\fP
.PP
Inherited by \fBKAr\fP, \fBKTar\fP, and \fBKZip\fP.
.PP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "virtual bool \fBopen\fP (int mode)"
.br
.RI "\fIOpens the archive for reading or writing. \fP"
.ti -1c
.RI "virtual void \fBclose\fP ()"
.br
.RI "\fICloses the archive. \fP"
.ti -1c
.RI "bool \fBisOpened\fP () const "
.br
.ti -1c
.RI "int \fBmode\fP () const "
.br
.ti -1c
.RI "\fBQIODevice\fP * \fBdevice\fP () const "
.br
.RI "\fIThe underlying device. \fP"
.ti -1c
.RI "const  \fBKArchiveDirectory\fP * \fBdirectory\fP () const "
.br
.RI "\fIIf an archive is opened for reading, then the contents of the archive can be accessed via this function. \fP"
.ti -1c
.RI "virtual bool \fBwriteDir\fP (const  \fBQString\fP &name, const  \fBQString\fP &user, const  \fBQString\fP &group)=0"
.br
.RI "\fIIf an archive is opened for writing then you can add new directories using this function. \fP"
.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
.RI "\fIIf an archive is opened for writing then you can add a new file 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)=0"
.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)=0"
.br
.RI "\fICall \fBdoneWriting\fP after writing the data. \fP"
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "\fBKArchive\fP (\fBQIODevice\fP *dev)"
.br
.RI "\fIBase constructor (protected since this is a pure virtual class). \fP"
.ti -1c
.RI "virtual bool \fBopenArchive\fP (int mode)=0"
.br
.RI "\fIOpens an archive for reading or writing. \fP"
.ti -1c
.RI "virtual bool \fBcloseArchive\fP ()=0"
.br
.RI "\fICloses the archive. \fP"
.ti -1c
.RI "virtual \fBKArchiveDirectory\fP * \fBrootDir\fP ()"
.br
.RI "\fIRetrieves or create the root directory. \fP"
.ti -1c
.RI "\fBKArchiveDirectory\fP * \fBfindOrCreate\fP (const  \fBQString\fP &path)"
.br
.RI "\fIEnsures that \fCpath\fP exists, create otherwise. \fP"
.ti -1c
.RI "void \fBsetDevice\fP (\fBQIODevice\fP *dev)"
.br
.ti -1c
.RI "void \fBsetRootDir\fP (\fBKArchiveDirectory\fP *rootDir)"
.br
.ti -1c
.RI "virtual void \fBvirtual_hook\fP (int id, void *data)"
.br
.in -1c
.SH "Detailed Description"
.PP 
generic class for reading/writing archives 

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

.PP
Definition at line 38 of file karchive.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KArchive::KArchive (\fBQIODevice\fP * dev)\fC [protected]\fP"
.PP
Base constructor (protected since this is a pure virtual class). \fBParameters:\fP
.RS 4
\fIdev\fP the I/O device where the archive reads its data Note that this can be a file, but also a data buffer, a compression filter, etc. 
.RE
.PP
Definition at line 69 of file karchive.cpp.
.SH "Member Function Documentation"
.PP 
.SS "bool KArchive::open (int mode)\fC [virtual]\fP"
.PP
Opens the archive for reading or writing. \fBParameters:\fP
.RS 4
\fImode\fP may be IO_ReadOnly or IO_WriteOnly Inherited classes might want to reimplement openArchive instead. 
.RE
.PP
\fBSee also:\fP
.RS 4
\fBclose\fP 
.RE
.PP
Definition at line 85 of file karchive.cpp.
.PP
References close(), QIODevice::open(), and openArchive().
.SS "void KArchive::close ()\fC [virtual]\fP"
.PP
Closes the archive. Inherited classes might want to reimplement closeArchive instead.
.PP
\fBSee also:\fP
.RS 4
\fBopen\fP 
.RE
.PP
Definition at line 105 of file karchive.cpp.
.PP
References QIODevice::close(), and closeArchive().
.PP
Referenced by open(), KAr::~KAr(), KTar::~KTar(), and KZip::~KZip().
.SS "bool KArchive::isOpened () const\fC [inline]\fP"
.PP
\fBReturns:\fP
.RS 4
true if the archive is opened 
.RE
.PP
Definition at line 70 of file karchive.h.
.PP
Referenced by KZip::prepareWriting(), KTar::prepareWriting(), KTar::setOrigFileName(), KTar::writeDir(), KAr::~KAr(), KTar::~KTar(), and KZip::~KZip().
.SS "int KArchive::mode () const\fC [inline]\fP"
.PP
\fBReturns:\fP
.RS 4
the mode in which the archive was opened (IO_ReadOnly or IO_WriteOnly) 
.RE
.PP
Definition at line 75 of file karchive.h.
.PP
Referenced by KZip::closeArchive(), KZip::prepareWriting(), KTar::prepareWriting(), KTar::setOrigFileName(), and KTar::writeDir().
.SS "\fBQIODevice\fP* KArchive::device () const\fC [inline]\fP"
.PP
The underlying device. Definition at line 80 of file karchive.h.
.PP
Referenced by KZip::closeArchive(), KArchiveFile::data(), KZip::doneWriting(), KTar::doneWriting(), KZip::openArchive(), KTar::openArchive(), KAr::openArchive(), KZip::prepareWriting(), KTar::prepareWriting(), KTar::setOrigFileName(), KTar::writeDir(), KZip::writeFile(), writeFile(), KAr::~KAr(), KTar::~KTar(), and KZip::~KZip().
.SS "const  \fBKArchiveDirectory\fP * KArchive::directory () const"
.PP
If an archive is opened for reading, then the contents of the archive can be accessed via this function. Definition at line 120 of file karchive.cpp.
.SS "virtual bool KArchive::writeDir (const \fBQString\fP & name, const \fBQString\fP & user, const \fBQString\fP & group)\fC [pure virtual]\fP"
.PP
If an archive is opened for writing then you can add new directories using this function. KArchive won't write one directory twice. Implemented in \fBKAr\fP, \fBKTar\fP, and \fBKZip\fP.
.SS "bool KArchive::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. If the file name is for example 'mydir/test1' then the directory 'mydir' is automatically appended first if that did not happen yet. Reimplemented in \fBKZip\fP.
.PP
Definition at line 126 of file karchive.cpp.
.PP
References device(), doneWriting(), KStdAccel::name(), prepareWriting(), and QIODevice::writeBlock().
.SS "virtual bool KArchive::prepareWriting (const \fBQString\fP & name, const \fBQString\fP & user, const \fBQString\fP & group, uint size)\fC [pure 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. Implemented in \fBKAr\fP, \fBKTar\fP, and \fBKZip\fP.
.PP
Referenced by writeFile().
.SS "virtual bool KArchive::doneWriting (uint size)\fC [pure virtual]\fP"
.PP
Call \fBdoneWriting\fP after writing the data. \fBSee also:\fP
.RS 4
\fBprepareWriting\fP 
.RE
.PP
Implemented in \fBKAr\fP, \fBKTar\fP, and \fBKZip\fP.
.PP
Referenced by writeFile().
.SS "virtual bool KArchive::openArchive (int mode)\fC [protected, pure virtual]\fP"
.PP
Opens an archive for reading or writing. Called by \fBopen\fP. Implemented in \fBKAr\fP, \fBKTar\fP, and \fBKZip\fP.
.PP
Referenced by open().
.SS "virtual bool KArchive::closeArchive ()\fC [protected, pure virtual]\fP"
.PP
Closes the archive. Called by \fBclose\fP. Implemented in \fBKAr\fP, \fBKTar\fP, and \fBKZip\fP.
.PP
Referenced by close().
.SS "\fBKArchiveDirectory\fP * KArchive::rootDir ()\fC [protected, virtual]\fP"
.PP
Retrieves or create the root directory. The default implementation assumes that \fBopenArchive()\fP did the parsing, so it creates a dummy rootdir if none was set (write mode, or no '/' in the archive). Reimplement this to provide parsing/listing on demand. Definition at line 151 of file karchive.cpp.
.PP
References QFile::decodeName(), QString::fromLatin1(), and QString::number().
.PP
Referenced by findOrCreate(), KZip::openArchive(), KTar::openArchive(), KAr::openArchive(), and KZip::prepareWriting().
.SS "\fBKArchiveDirectory\fP * KArchive::findOrCreate (const \fBQString\fP & path)\fC [protected]\fP"
.PP
Ensures that \fCpath\fP exists, create otherwise. This handles e.g. tar files missing directory entries, like mico-2.3.0.tar.gz :) Definition at line 166 of file karchive.cpp.
.PP
References KArchiveDirectory::addEntry(), KArchiveDirectory::entry(), QString::findRev(), KArchiveEntry::isDirectory(), QString::left(), QString::mid(), and rootDir().
.PP
Referenced by KZip::openArchive(), KTar::openArchive(), and KZip::prepareWriting().

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