class KArchive

# class KArchive | generic class for reading/writing archives. More...
Contains pure virtuals
Definition | `#include <karchive.h>`
Inherited by | KAr, KTar, KZip
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- virtual ~KArchive ()
- virtual bool open ( int mode )
- virtual void close ()
- bool isOpened () const
- int mode () const
- QIODevice * device () const
- const KArchiveDirectory* directory () const
- virtual bool writeDir ( const QString& name, const QString& user, const QString& group )
- 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 )
- virtual bool doneWriting ( uint size )

#### Protected Methods

- KArchive ( QIODevice * dev )
- virtual bool openArchive ( int mode )
- virtual bool closeArchive ()
- virtual KArchiveDirectory* rootDir ()
- KArchiveDirectory * findOrCreate ( const QString & path )
- void setDevice ( QIODevice *dev )
- void setRootDir ( KArchiveDirectory *rootDir )
- virtual void virtual_hook ( int id, void* data )

## Detailed Description

KArchive ( QIODevice * dev ) | ### KArchive

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

~KArchive () | ### ~KArchive

[virtual]

bool open ( int mode ) | ### open

[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

void close () | ### close

[virtual]

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

See also: open

bool isOpened () | ### isOpened

[const]

Returns: true if the archive is opened

int mode () | ### mode

[const]

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

QIODevice * device () | ### device

[const]

The underlying device.

const KArchiveDirectory* directory () | ### directory

[const]

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

bool writeDir ( const QString& name, const QString& user, const QString& group ) | ### writeDir

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

bool writeFile ( const QString& name, const QString& user, const QString& group, uint size, const char* data ) | ### writeFile

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

bool prepareWriting ( const QString& name, const QString& user, const QString& group, uint size ) | ### prepareWriting

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

bool doneWriting ( uint size ) | ### doneWriting

[pure virtual]

Call doneWriting after writing the data.

See also: prepareWriting

bool openArchive ( int mode ) | ### openArchive

[protected pure virtual]

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

bool closeArchive () | ### closeArchive

[protected pure virtual]

Closes the archive. Called by close.

KArchiveDirectory* rootDir () | ### 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.

KArchiveDirectory * findOrCreate ( const QString & path ) | ### findOrCreate

[protected]

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

void setDevice ( QIODevice *dev ) | ### setDevice

[protected]

void setRootDir ( KArchiveDirectory *rootDir ) | ### setRootDir

[protected]

void virtual_hook ( int id, void* data ) | ### virtual_hook

[protected virtual]

- Author: David Faure
- Generated: root on macppc.ports.openbsd.org on Sat Sep 6 10:36:57 2003, using kdoc 2.0a54.