KTar

KDE 4.5 PyKDE API Reference

- KDE's Python API

# KTar Class Reference

`from PyKDE4.kio import *`

Inherits: KArchive

## 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, bzip2 or xz.

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

## Methods
| __init__ (self, QString filename, QString mimetype=QString())
| __init__ (self, QIODevice dev)
| __init__ (self, KTar other)
bool | closeArchive (self)
bool | createDevice (self, QIODevice.OpenMode mode)
bool | doFinishWriting (self, long size)
bool | doPrepareWriting (self, QString name, QString user, QString group, long size, long perm, long atime, long mtime, long ctime)
bool | doWriteDir (self, QString name, QString user, QString group, long perm, long atime, long mtime, long ctime)
bool | doWriteSymLink (self, QString name, QString target, QString user, QString group, long perm, long atime, long mtime, long ctime)
bool | openArchive (self, QIODevice.OpenMode mode)
| setOrigFileName (self, QByteArray fileName)

## Method Documentation

__init__ | ( | self, |
|  | QString | filename,
|  | QString | mimetype=QString()
| ) |  |  |

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", "application/x-bzip" or "application/x-xz" Do not use application/x-compressed-tar or similar - you only need to specify the compression layer ! If the mimetype is omitted, it will be determined from the filename.

__init__ | ( | self, |
|  | QIODevice | dev
| ) |  |  |

Creates an instance that operates on the given device. The device can be compressed (KFilterDev) or not (QFile, etc.).

Warning:
  Do not 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

__init__ | ( | self, |
|  | KTar | other
| ) |  |  |

bool closeArchive | ( |  | self ) |

bool createDevice | ( | self, |
|  | QIODevice.OpenMode | mode
| ) |  |  |

bool doFinishWriting | ( | self, |
|  | long | size
| ) |  |  |

bool doPrepareWriting | ( | self, |
|  | QString | name,
|  | QString | user,
|  | QString | group,
|  | long | size,
|  | long | perm,
|  | long | atime,
|  | long | mtime,
|  | long | ctime
| ) |  |  |

bool doWriteDir | ( | self, |
|  | QString | name,
|  | QString | user,
|  | QString | group,
|  | long | perm,
|  | long | atime,
|  | long | mtime,
|  | long | ctime
| ) |  |  |

bool doWriteSymLink | ( | self, |
|  | QString | name,
|  | QString | target,
|  | QString | user,
|  | QString | group,
|  | long | perm,
|  | long | atime,
|  | long | mtime,
|  | long | ctime
| ) |  |  |

bool openArchive | ( | self, |
|  | QIODevice.OpenMode | mode
| ) |  |  |

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

setOrigFileName | ( | self, |
|  | QByteArray | 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