ckb-next  v0.2.8 at branch master
ckb-next driver for corsair devices
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
QuaGzipFile Class Reference

GZIP file. More...

#include <src/ckb/quazip/quagzipfile.h>

+ Inheritance diagram for QuaGzipFile:
+ Collaboration diagram for QuaGzipFile:

Public Member Functions

 QuaGzipFile ()
 Empty constructor. More...
 
 QuaGzipFile (QObject *parent)
 Empty constructor with a parent. More...
 
 QuaGzipFile (const QString &fileName, QObject *parent=NULL)
 Constructor. More...
 
virtual ~QuaGzipFile ()
 Destructor. More...
 
void setFileName (const QString &fileName)
 Sets the name of the GZIP file to be opened. More...
 
QString getFileName () const
 Returns the name of the GZIP file. More...
 
virtual bool isSequential () const
 Returns true. More...
 
virtual bool open (QIODevice::OpenMode mode)
 Opens the file. More...
 
virtual bool open (int fd, QIODevice::OpenMode mode)
 Opens the file. More...
 
virtual bool flush ()
 Flushes data to file. More...
 
virtual void close ()
 Closes the file. More...
 

Protected Member Functions

virtual qint64 readData (char *data, qint64 maxSize)
 Implementation of QIODevice::readData(). More...
 
virtual qint64 writeData (const char *data, qint64 maxSize)
 Implementation of QIODevice::writeData(). More...
 

Private Member Functions

 QuaGzipFile (const QuaGzipFile &that)
 
QuaGzipFileoperator= (const QuaGzipFile &that)
 

Private Attributes

QuaGzipFilePrivate * d
 

Detailed Description

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.

Definition at line 39 of file quagzipfile.h.

Constructor & Destructor Documentation

QuaGzipFile::QuaGzipFile ( )

Must call setFileName() before trying to open.

Definition at line 87 of file quagzipfile.cpp.

87  :
88 d(new QuaGzipFilePrivate())
89 {
90 }
QuaGzipFilePrivate * d
Definition: quagzipfile.h:105
QuaGzipFile::QuaGzipFile ( QObject parent)

Must call setFileName() before trying to open.

Parameters
parentThe parent object, as per QObject logic.

Definition at line 92 of file quagzipfile.cpp.

92  :
93 QIODevice(parent),
94 d(new QuaGzipFilePrivate())
95 {
96 }
QuaGzipFilePrivate * d
Definition: quagzipfile.h:105
QuaGzipFile::QuaGzipFile ( const QString &  fileName,
QObject parent = NULL 
)
Parameters
fileNameThe name of the GZIP file.
parentThe parent object, as per QObject logic.

Definition at line 98 of file quagzipfile.cpp.

98  :
99  QIODevice(parent),
100 d(new QuaGzipFilePrivate(fileName))
101 {
102 }
QuaGzipFilePrivate * d
Definition: quagzipfile.h:105
QuaGzipFile::~QuaGzipFile ( )
virtual

Definition at line 104 of file quagzipfile.cpp.

References close(), and d.

105 {
106  if (isOpen()) {
107  close();
108  }
109  delete d;
110 }
QuaGzipFilePrivate * d
Definition: quagzipfile.h:105
virtual void close()
Closes the file.

+ Here is the call graph for this function:

QuaGzipFile::QuaGzipFile ( const QuaGzipFile that)
private

Member Function Documentation

void QuaGzipFile::close ( )
virtual

Definition at line 152 of file quagzipfile.cpp.

References d.

Referenced by ~QuaGzipFile().

153 {
154  QIODevice::close();
155  gzclose(d->gzd);
156 }
QuaGzipFilePrivate * d
Definition: quagzipfile.h:105

+ Here is the caller graph for this function:

bool QuaGzipFile::flush ( )
virtual

The data is written using Z_SYNC_FLUSH mode. Doesn't make any sense when reading.

Definition at line 147 of file quagzipfile.cpp.

References d.

148 {
149  return gzflush(d->gzd, Z_SYNC_FLUSH) == Z_OK;
150 }
QuaGzipFilePrivate * d
Definition: quagzipfile.h:105
QString QuaGzipFile::getFileName ( ) const

Definition at line 117 of file quagzipfile.cpp.

References d.

118 {
119  return d->fileName;
120 }
QuaGzipFilePrivate * d
Definition: quagzipfile.h:105
bool QuaGzipFile::isSequential ( ) const
virtual

Strictly speaking, zlib supports seeking for GZIP files, but it is poorly implemented, because there is no way to implement it properly. For reading, seeking backwards is very slow, and for writing, it is downright impossible. Therefore, QuaGzipFile does not support seeking at all.

Definition at line 122 of file quagzipfile.cpp.

123 {
124  return true;
125 }
bool QuaGzipFile::open ( QIODevice::OpenMode  mode)
virtual
Parameters
modeCan be either QIODevice::Write or QIODevice::Read. ReadWrite and Append aren't supported.

Definition at line 127 of file quagzipfile.cpp.

References d.

128 {
129  QString error;
130  if (!d->open(d->fileName, mode, error)) {
131  setErrorString(error);
132  return false;
133  }
134  return QIODevice::open(mode);
135 }
QuaGzipFilePrivate * d
Definition: quagzipfile.h:105
bool QuaGzipFile::open ( int  fd,
QIODevice::OpenMode  mode 
)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
fdThe file descriptor to read/write the GZIP file from/to.
modeCan be either QIODevice::Write or QIODevice::Read. ReadWrite and Append aren't supported.

Definition at line 137 of file quagzipfile.cpp.

References d.

138 {
139  QString error;
140  if (!d->open(fd, mode, error)) {
141  setErrorString(error);
142  return false;
143  }
144  return QIODevice::open(mode);
145 }
QuaGzipFilePrivate * d
Definition: quagzipfile.h:105
QuaGzipFile& QuaGzipFile::operator= ( const QuaGzipFile that)
private
qint64 QuaGzipFile::readData ( char *  data,
qint64  maxSize 
)
protectedvirtual

Definition at line 158 of file quagzipfile.cpp.

References d.

159 {
160  return gzread(d->gzd, (voidp)data, (unsigned)maxSize);
161 }
QuaGzipFilePrivate * d
Definition: quagzipfile.h:105
void QuaGzipFile::setFileName ( const QString &  fileName)

Definition at line 112 of file quagzipfile.cpp.

References d.

113 {
114  d->fileName = fileName;
115 }
QuaGzipFilePrivate * d
Definition: quagzipfile.h:105
qint64 QuaGzipFile::writeData ( const char *  data,
qint64  maxSize 
)
protectedvirtual

Definition at line 163 of file quagzipfile.cpp.

References d.

164 {
165  if (maxSize == 0)
166  return 0;
167  int written = gzwrite(d->gzd, (voidp)data, (unsigned)maxSize);
168  if (written == 0)
169  return -1;
170  else
171  return written;
172 }
QuaGzipFilePrivate * d
Definition: quagzipfile.h:105

Field Documentation

QuaGzipFilePrivate* QuaGzipFile::d
private

Definition at line 105 of file quagzipfile.h.

Referenced by close(), flush(), getFileName(), open(), readData(), setFileName(), writeData(), and ~QuaGzipFile().


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