Pages
API Documentation
On this page

KTar Class

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

  • Header: #include <KTar>
  • CMake: find_package(KF6 REQUIRED COMPONENTS Archive)
    target_link_libraries(mytarget PRIVATE KF6::Archive)
  • Inherits: KArchive

List of all members, including inherited members

Public Functions

Detailed Description

KTar allows you to read and write tar archives, including those that are compressed using gzip, bzip2, xz or lzip.

Member Function Documentation

[explicit] KTar::KTar(QIODevice *dev)

Creates an instance that operates on the given device.

The device can be compressed (KCompressionDevice) or not (QFile, etc.).

Warning: Do not assume that giving a QFile here will decompress the file, in case it's compressed!

dev the device to read from. If the source is compressed, the QIODevice must take care of decompression

[explicit] KTar::KTar(const QString &filename, const QString &mimetype = QString())

Creates an instance that operates on the given filename using the compression filter associated to given mimetype.

filename is a local path (e.g. "/home/weis/myfile.tgz")

mimetype "application/gzip" (before 5.85: "application/x-gzip"), "application/x-bzip", "application/x-xz", "application/zstd" (since 5.82) "application/x-lzip" (since 6.15) 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.

[override virtual noexcept] KTar::~KTar()

If the tar ball is still opened, then it will be closed automatically by the destructor.

void KTar::setOrigFileName(const 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 KCompressionDevice!

fileName the original file name

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.