source: Vago/Libs/quazip-0.7.2/quazip/quagzipfile.h@ 1064

Last change on this file since 1064 was 1050, checked in by s10k, 8 years ago
File size: 3.7 KB
Line 
1#ifndef QUAZIP_QUAGZIPFILE_H
2#define QUAZIP_QUAGZIPFILE_H
3
4/*
5Copyright (C) 2005-2014 Sergey A. Tachenov
6
7This file is part of QuaZIP.
8
9QuaZIP is free software: you can redistribute it and/or modify
10it under the terms of the GNU Lesser General Public License as published by
11the Free Software Foundation, either version 2.1 of the License, or
12(at your option) any later version.
13
14QuaZIP is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License
20along with QuaZIP. If not, see <http://www.gnu.org/licenses/>.
21
22See COPYING file for the full LGPL text.
23
24Original ZIP package is copyrighted by Gilles Vollant and contributors,
25see quazip/(un)zip.h files for details. Basically it's the zlib license.
26*/
27
28#include <QIODevice>
29#include "quazip_global.h"
30
31#include <zlib.h>
32
33class QuaGzipFilePrivate;
34
35/// GZIP file
36/**
37 This class is a wrapper around GZIP file access functions in zlib. Unlike QuaZip classes, it doesn't allow reading from a GZIP file opened as QIODevice, for example, if your GZIP file is in QBuffer. It only provides QIODevice access to a GZIP file contents, but the GZIP file itself must be identified by its name on disk or by descriptor id.
38 */
39class QUAZIP_EXPORT QuaGzipFile: public QIODevice {
40 Q_OBJECT
41public:
42 /// Empty constructor.
43 /**
44 Must call setFileName() before trying to open.
45 */
46 QuaGzipFile();
47 /// Empty constructor with a parent.
48 /**
49 Must call setFileName() before trying to open.
50 \param parent The parent object, as per QObject logic.
51 */
52 QuaGzipFile(QObject *parent);
53 /// Constructor.
54 /**
55 \param fileName The name of the GZIP file.
56 \param parent The parent object, as per QObject logic.
57 */
58 QuaGzipFile(const QString &fileName, QObject *parent = NULL);
59 /// Destructor.
60 virtual ~QuaGzipFile();
61 /// Sets the name of the GZIP file to be opened.
62 void setFileName(const QString& fileName);
63 /// Returns the name of the GZIP file.
64 QString getFileName() const;
65 /// Returns true.
66 /**
67 Strictly speaking, zlib supports seeking for GZIP files, but it is
68 poorly implemented, because there is no way to implement it
69 properly. For reading, seeking backwards is very slow, and for
70 writing, it is downright impossible. Therefore, QuaGzipFile does not
71 support seeking at all.
72 */
73 virtual bool isSequential() const;
74 /// Opens the file.
75 /**
76 \param mode Can be either QIODevice::Write or QIODevice::Read.
77 ReadWrite and Append aren't supported.
78 */
79 virtual bool open(QIODevice::OpenMode mode);
80 /// Opens the file.
81 /**
82 \overload
83 \param fd The file descriptor to read/write the GZIP file from/to.
84 \param mode Can be either QIODevice::Write or QIODevice::Read.
85 ReadWrite and Append aren't supported.
86 */
87 virtual bool open(int fd, QIODevice::OpenMode mode);
88 /// Flushes data to file.
89 /**
90 The data is written using Z_SYNC_FLUSH mode. Doesn't make any sense
91 when reading.
92 */
93 virtual bool flush();
94 /// Closes the file.
95 virtual void close();
96protected:
97 /// Implementation of QIODevice::readData().
98 virtual qint64 readData(char *data, qint64 maxSize);
99 /// Implementation of QIODevice::writeData().
100 virtual qint64 writeData(const char *data, qint64 maxSize);
101private:
102 // not implemented by design to disable copy
103 QuaGzipFile(const QuaGzipFile &that);
104 QuaGzipFile& operator=(const QuaGzipFile &that);
105 QuaGzipFilePrivate *d;
106};
107
108#endif // QUAZIP_QUAGZIPFILE_H
Note: See TracBrowser for help on using the repository browser.