KArchive Class Reference
generic class for reading/writing archives More...
#include <karchive.h>
Inheritance diagram for KArchive:


Public Member Functions | |
virtual bool | open (int mode) |
Opens the archive for reading or writing. | |
virtual void | close () |
Closes the archive. | |
bool | isOpened () const |
int | mode () const |
QIODevice * | device () const |
The underlying device. | |
const KArchiveDirectory * | directory () const |
If an archive is opened for reading, then the contents of the archive can be accessed via this function. | |
virtual bool | writeDir (const QString &name, const QString &user, const QString &group)=0 |
If an archive is opened for writing then you can add new directories using this function. | |
virtual bool | writeFile (const QString &name, const QString &user, const QString &group, uint size, const char *data) |
If an archive is opened for writing then you can add a new file using this function. | |
virtual bool | prepareWriting (const QString &name, const QString &user, const QString &group, uint size)=0 |
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. | |
virtual bool | doneWriting (uint size)=0 |
Call doneWriting after writing the data. | |
Protected Member Functions | |
KArchive (QIODevice *dev) | |
Base constructor (protected since this is a pure virtual class). | |
virtual bool | openArchive (int mode)=0 |
Opens an archive for reading or writing. | |
virtual bool | closeArchive ()=0 |
Closes the archive. | |
virtual KArchiveDirectory * | rootDir () |
Retrieves or create the root directory. | |
KArchiveDirectory * | findOrCreate (const QString &path) |
Ensures that path exists, create otherwise. | |
void | setDevice (QIODevice *dev) |
void | setRootDir (KArchiveDirectory *rootDir) |
virtual void | virtual_hook (int id, void *data) |
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
|
Base constructor (protected since this is a pure virtual class).
Definition at line 69 of file karchive.cpp. |
Member Function Documentation
|
Opens the archive for reading or writing.
Definition at line 85 of file karchive.cpp. References close(), QIODevice::open(), and openArchive(). |
|
Closes the archive. Inherited classes might want to reimplement closeArchive instead.
Definition at line 105 of file karchive.cpp. References QIODevice::close(), and closeArchive(). Referenced by open(), KAr::~KAr(), KTar::~KTar(), and KZip::~KZip(). |
|
Definition at line 70 of file karchive.h. Referenced by KZip::prepareWriting(), KTar::prepareWriting(), KTar::setOrigFileName(), KTar::writeDir(), KAr::~KAr(), KTar::~KTar(), and KZip::~KZip(). |
|
Definition at line 75 of file karchive.h. Referenced by KZip::closeArchive(), KZip::prepareWriting(), KTar::prepareWriting(), KTar::setOrigFileName(), and KTar::writeDir(). |
|
The underlying device.
Definition at line 80 of file karchive.h. 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(). |
|
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. |
|
If an archive is opened for writing then you can add new directories using this function. KArchive won't write one directory twice. |
|
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. Definition at line 126 of file karchive.cpp. References device(), doneWriting(), KStdAccel::name(), prepareWriting(), and QIODevice::writeBlock(). |
|
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. Referenced by writeFile(). |
|
Call doneWriting after writing the data.
Implemented in KAr, KTar, and KZip. Referenced by writeFile(). |
|
Opens an archive for reading or writing. Called by open. Implemented in KAr, KTar, and KZip. Referenced by open(). |
|
Closes the archive. Called by close. Implemented in KAr, KTar, and KZip. Referenced by close(). |
|
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. Definition at line 151 of file karchive.cpp. References QFile::decodeName(), QString::fromLatin1(), and QString::number(). Referenced by findOrCreate(), KZip::openArchive(), KTar::openArchive(), KAr::openArchive(), and KZip::prepareWriting(). |
|
Ensures that This handles e.g. tar files missing directory entries, like mico-2.3.0.tar.gz :) Definition at line 166 of file karchive.cpp. References KArchiveDirectory::addEntry(), KArchiveDirectory::entry(), QString::findRev(), KArchiveEntry::isDirectory(), QString::left(), QString::mid(), and rootDir(). Referenced by KZip::openArchive(), KTar::openArchive(), and KZip::prepareWriting(). |
The documentation for this class was generated from the following files: