Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

KArchive Class Reference

generic class for reading/writing archives More...

#include <karchive.h>

Inheritance diagram for KArchive:

KAr KTar KZip List of all members.

Public Methods

virtual bool open (int mode)
virtual void close ()
bool isOpened () const
int mode () const
QIODevice * device () const
const KArchiveDirectorydirectory () const
virtual bool writeDir (const QString &name, const QString &user, const QString &group)=0
virtual bool writeFile (const QString &name, const QString &user, const QString &group, uint size, const char *data)
virtual bool prepareWriting (const QString &name, const QString &user, const QString &group, uint size)=0
virtual bool doneWriting (uint size)=0

Protected Methods

 KArchive (QIODevice *dev)
virtual bool openArchive (int mode)=0
virtual bool closeArchive ()=0
virtual KArchiveDirectoryrootDir ()
KArchiveDirectoryfindOrCreate (const QString &path)

Detailed Description

generic class for reading/writing archives

Author:
David Faure <faure@kde.org>

Definition at line 38 of file karchive.h.


Constructor & Destructor Documentation

KArchive::KArchive QIODevice *    dev [protected]
 

Base constructor (protected since this is a pure virtual class).

Parameters:
dev  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.


Member Function Documentation

virtual void KArchive::close   [virtual]
 

Closes the archive. Inherited classes might want to reimplement closeArchive instead.

See also:
open

virtual bool KArchive::closeArchive   [protected, pure virtual]
 

Closes the archive. Called by close.

Implemented in KAr, KTar, and KZip.

QIODevice* KArchive::device   const [inline]
 

The underlying device.

Definition at line 80 of file karchive.h.

const KArchiveDirectory* KArchive::directory  
 

If an archive is opened for reading, then the contents of the archive can be accessed via this function.

virtual bool KArchive::doneWriting uint    size [pure virtual]
 

Call doneWriting after writing the data.

See also:
prepareWriting

Implemented in KAr, KTar, and KZip.

KArchiveDirectory* KArchive::findOrCreate const QString &    path [protected]
 

Ensures that path exists, create otherwise. This handles e.g. tar files missing directory entries, like mico-2.3.0.tar.gz :)

bool KArchive::isOpened   const [inline]
 

Returns:
true if the archive is opened

Definition at line 70 of file karchive.h.

int KArchive::mode   const [inline]
 

Returns:
the mode in which the archive was opened (IO_ReadOnly or IO_WriteOnly)

Definition at line 75 of file karchive.h.

virtual bool KArchive::open int    mode [virtual]
 

Opens the archive for reading or writing.

Parameters:
mode  may be IO_ReadOnly or IO_WriteOnly Inherited classes might want to reimplement openArchive instead.
See also:
close

virtual bool KArchive::openArchive int    mode [protected, pure virtual]
 

Opens an archive for reading or writing. Called by open.

Implemented in KAr, KTar, and KZip.

virtual bool KArchive::prepareWriting const QString &    name,
const QString &    user,
const QString &    group,
uint    size
[pure virtual]
 

Here's another way of writing a file into an archive: Call prepareWriting, then call device()->writeBlock() (for tar files) or writeData (for zip files) [NEW VIRTUAL METHOD NEEDED] as many times as wanted then call doneWriting( 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 KAr, KTar, and KZip.

virtual KArchiveDirectory* KArchive::rootDir   [protected, virtual]
 

Retrieves or create the root directory. The default implementation assumes that openArchive() 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.

virtual bool KArchive::writeDir const QString &    name,
const QString &    user,
const QString &    group
[pure virtual]
 

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 KAr, KTar, and KZip.

virtual bool KArchive::writeFile const QString &    name,
const QString &    user,
const QString &    group,
uint    size,
const char *    data
[virtual]
 

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 KZip.


The documentation for this class was generated from the following file:
Generated on Wed Aug 13 23:30:05 2003 for kdelibs by doxygen1.2.18