kio Library: KTar Class Reference (kio Library)

| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# KTar Class Reference

A class for reading / writing (optionally compressed) tar archives. More...

`#include <ktar.h>`

Inheritance diagram for KTar:

[legend]
Collaboration diagram for KTar:

[legend]
List of all members.

## Public Member Functions
| KTar (const QString &filename, const QString &mimetype=QString::null)
| KTar (QIODevice *dev)
virtual | ~KTar ()
QString | fileName ()
void | setOrigFileName (const QCString &fileName)
bool | writeSymLink (const QString &name, const QString &target, const QString &user, const QString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)
virtual bool | writeDir (const QString &name, const QString &user, const QString &group)
bool | writeDir (const QString &name, const QString &user, const QString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)
virtual bool | prepareWriting (const QString &name, const QString &user, const QString &group, uint size)
bool | prepareWriting (const QString &name, const QString &user, const QString &group, uint size, mode_t perm, time_t atime, time_t mtime, time_t ctime)
virtual bool | doneWriting (uint size)
## Protected Member Functions
virtual bool | openArchive (int mode)
virtual bool | closeArchive ()
virtual void | virtual_hook (int id, void *data)
bool | prepareWriting_impl (const QString &name, const QString &user, const QString &group, uint size, mode_t perm, time_t atime, time_t mtime, time_t ctime)
bool | writeDir_impl (const QString &name, const QString &user, const QString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)
bool | writeSymLink_impl (const QString &name, const QString &target, const QString &user, const QString &group, mode_t perm, time_t atime, time_t mtime, time_t ctime)

## Detailed Description

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.

Author:
  Torben Weis <weis@kde.org>, David Faure <faure@kde.org>

Definition at line 40 of file ktar.h.

## Constructor & Destructor Documentation

KTar::KTar | ( | const QString & | filename,
|  | const QString & | mimetype = `QString::null`
| ) |

  | Creates an instance that operates on the given filename using the compression filter associated to given mimetype. Parameters:
  | filename | is a local path (e.g. "/home/weis/myfile.tgz")
  | mimetype | "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.
Definition at line 59 of file ktar.cpp. References QFile::close(), endl(), KMimeType::findByFileContent(), KMimeType::findByPath(), QFile::getch(), QString::isEmpty(), kdDebug(), and QFile::open().

KTar::KTar | ( | QIODevice * | dev | ) |

  | Creates an instance that operates on the given device. The device can be compressed (KFilterDev) or not (QFile, etc.). WARNING: don't assume that giving a QFile here will decompress the file, in case it's compressed! Parameters:
  | dev | the device to read from. If the source is compressed, the QIODevice must take care of decompression
Definition at line 144 of file ktar.cpp.

KTar::~KTar | ( |  | ) | `[virtual]`

| If the tar ball is still opened, then it will be closed automatically by the destructor. Definition at line 150 of file ktar.cpp. References KArchive::close(), KArchive::device(), QString::isEmpty(), and KArchive::isOpened().

## Member Function Documentation

QString KTar::fileName | ( |  | ) | `[inline]`

| The name of the tar file, as passed to the constructor Null if you used the QIODevice constructor. Returns: the name of the file, or QString::null if unknown Definition at line 76 of file ktar.h. Referenced by setOrigFileName().

void KTar::setOrigFileName | ( | const QCString & | fileName | ) |

  | Special function for setting the "original file name" in the gzip header, when writing a tar.gz file. It appears when using in the "file" command, for instance. Should only be called if the underlying device is a KFilterDev! Parameters:
  | fileName | the original file name
Definition at line 165 of file ktar.cpp. References fileName(), KArchive::isOpened(), kdWarning(), and KArchive::mode().

bool KTar::writeSymLink | ( | const QString & | name,
|  | const QString & | target,
|  | const QString & | user,
|  | const QString & | group,
|  | mode_t | perm,
|  | time_t | atime,
|  | time_t | mtime,
|  | time_t | ctime
| ) |

  | Writes a symbolic link to the archive if the archive must be opened for writing. Parameters:
  | name | name of symbolic link
  | target | target of symbolic link
  | user | the user that owns the directory
  | group | the group that owns the directory
  | perm | permissions of the directory
  | atime | time the file was last accessed
  | mtime | modification time of the file
  | ctime | creation time of the file
Since: 3.2 // TODO(BIC) make virtual. For now it must be implemented by virtual_hook. Reimplemented from KArchive. Definition at line 869 of file ktar.cpp. References KArchive::writeSymLink().

bool KTar::writeDir | ( | const QString & | name,
|  | const QString & | user,
|  | const QString & | group
| ) | `[virtual]`

  | If an archive is opened for writing then you can add new directories using this function. KArchive won't write one directory twice. Parameters:
  | name | the name of the directory
  | user | the user that owns the directory
  | group | 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
Implements KArchive. Definition at line 542 of file ktar.cpp. References QIODevice::at(), KArchive::device(), KArchive::isOpened(), kdWarning(), QString::length(), QString::local8Bit(), KArchive::mode(), QString::right(), and QIODevice::writeBlock().

bool KTar::writeDir | ( | const QString & | name,
|  | const QString & | user,
|  | const QString & | group,
|  | mode_t | perm,
|  | time_t | atime,
|  | time_t | mtime,
|  | time_t | ctime
| ) |

  | If an archive is opened for writing then you can add new directories using this function. KArchive won't write one directory twice. This method also allows some file metadata to be set. However, depending on the archive type not all metadata might be regarded. Parameters:
  | name | the name of the directory
  | user | the user that owns the directory
  | group | the group that owns the directory
  | perm | permissions of the directory
  | atime | time the file was last accessed
  | mtime | modification time of the file
  | ctime | creation time of the file
Since: 3.2 // TODO(BIC): make this virtual. For now use virtual hook Reimplemented from KArchive. Definition at line 806 of file ktar.cpp. References KArchive::writeDir().

bool KTar::prepareWriting | ( | const QString & | name,
|  | const QString & | user,
|  | const QString & | group,
|  | uint | size
| ) | `[virtual]`

  | Here's another way of writing a file into an archive: Call prepareWriting, then call writeData() as many times as wanted then call doneWriting( totalSize ). 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. Parameters:
  | name | the name of the file
  | user | the user that owns the file
  | group | the group that owns the file
  | size | 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.
Implements KArchive. Definition at line 604 of file ktar.cpp.

bool KTar::prepareWriting | ( | const QString & | name,
|  | const QString & | user,
|  | const QString & | group,
|  | uint | size,
|  | mode_t | perm,
|  | time_t | atime,
|  | time_t | mtime,
|  | time_t | ctime
| ) |

  | Here's another way of writing a file into an archive: Call prepareWriting, then call writeData() 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. This method also allows some file metadata to be set. However, depending on the archive type not all metadata might be regarded. Parameters:
  | name | the name of the file
  | user | the user that owns the file
  | group | the group that owns the file
  | size | the size of the file
  | perm | permissions of the file
  | atime | time the file was last accessed
  | mtime | modification time of the file
  | ctime | creation time of the file
Since: 3.2 // TODO(BIC): make this virtual. For now use virtual hook. Reimplemented from KArchive. Definition at line 735 of file ktar.cpp. References KArchive::prepareWriting().

bool KTar::doneWriting | ( | uint | size | ) | `[virtual]`

  | Call doneWriting after writing the data. Parameters:
  | size | the size of the file
See also: prepareWriting() Implements KArchive. Definition at line 612 of file ktar.cpp. References QIODevice::at(), KArchive::device(), KArchive::mode(), and QIODevice::writeBlock().

bool KTar::openArchive | ( | int | mode | ) | `[protected, virtual]`

  | Opens the archive for reading. Parses the directory listing of the archive and creates the KArchiveDirectory/KArchiveFile entries. Parameters:
  | mode | the mode of the file
Implements KArchive. Definition at line 326 of file ktar.cpp. 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().

bool KTar::closeArchive | ( |  | ) | `[protected, virtual]`

| Closes the archive. Called by close. Implements KArchive. Definition at line 529 of file ktar.cpp. References KArchive::mode().

The documentation for this class was generated from the following files:

- ktar.h
- ktar.cpp

This file is part of the documentation for kio Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:25:28 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003