fix tricky regression noticed by Vyacheslav Tokarev on Google Reader.
[kdelibs.git] / kio / kio / ktar.h
blobb3dd5e593b863d27dc54b47e1c02e5b638097864
1 /* This file is part of the KDE libraries
2 Copyright (C) 2000-2005 David Faure <faure@kde.org>
3 Copyright (C) 2003 Leo Savernik <l.savernik@aon.at>
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
19 #ifndef KTAR_H
20 #define KTAR_H
22 #include <karchive.h>
24 /**
25 * A class for reading / writing (optionally compressed) tar archives.
27 * KTar allows you to read and write tar archives, including those
28 * that are compressed using gzip or bzip2.
30 * @author Torben Weis <weis@kde.org>, David Faure <faure@kde.org>
32 class KIO_EXPORT KTar : public KArchive
34 public:
35 /**
36 * Creates an instance that operates on the given filename
37 * using the compression filter associated to given mimetype.
39 * @param filename is a local path (e.g. "/home/weis/myfile.tgz")
40 * @param mimetype "application/x-gzip" or "application/x-bzip"
41 * Do not use application/x-compressed-tar or similar - you only need to
42 * specify the compression layer ! If the mimetype is omitted, it
43 * will be determined from the filename.
45 explicit KTar( const QString& filename,
46 const QString& mimetype = QString() );
48 /**
49 * Creates an instance that operates on the given device.
50 * The device can be compressed (KFilterDev) or not (QFile, etc.).
51 * @warning Do not assume that giving a QFile here will decompress the file,
52 * in case it's compressed!
53 * @param dev the device to read from. If the source is compressed, the
54 * QIODevice must take care of decompression
56 explicit KTar( QIODevice * dev );
58 /**
59 * If the tar ball is still opened, then it will be
60 * closed automatically by the destructor.
62 virtual ~KTar();
64 /**
65 * Special function for setting the "original file name" in the gzip header,
66 * when writing a tar.gz file. It appears when using in the "file" command,
67 * for instance. Should only be called if the underlying device is a KFilterDev!
68 * @param fileName the original file name
70 void setOrigFileName( const QByteArray & fileName );
72 protected:
74 /// Reimplemented from KArchive
75 virtual bool doWriteSymLink(const QString &name, const QString &target,
76 const QString &user, const QString &group,
77 mode_t perm, time_t atime, time_t mtime, time_t ctime);
78 /// Reimplemented from KArchive
79 virtual bool doWriteDir( const QString& name, const QString& user, const QString& group,
80 mode_t perm, time_t atime, time_t mtime, time_t ctime );
81 /// Reimplemented from KArchive
82 virtual bool doPrepareWriting( const QString& name, const QString& user,
83 const QString& group, qint64 size, mode_t perm,
84 time_t atime, time_t mtime, time_t ctime );
85 /// Reimplemented from KArchive
86 virtual bool doFinishWriting( qint64 size );
88 /**
89 * Opens the archive for reading.
90 * Parses the directory listing of the archive
91 * and creates the KArchiveDirectory/KArchiveFile entries.
92 * @param mode the mode of the file
94 virtual bool openArchive( QIODevice::OpenMode mode );
95 virtual bool closeArchive();
97 virtual bool createDevice( QIODevice::OpenMode mode );
99 private:
101 protected:
102 virtual void virtual_hook( int id, void* data );
103 private:
104 class KTarPrivate;
105 KTarPrivate* const d;
108 #endif