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
QuaZipPrivate Class Reference

All the internal stuff for the QuaZip class. More...

+ Collaboration diagram for QuaZipPrivate:

Private Member Functions

QTextCodec * getDefaultFileNameCodec ()
 
 QuaZipPrivate (QuaZip *q)
 The constructor for the corresponding QuaZip constructor. More...
 
 QuaZipPrivate (QuaZip *q, const QString &zipName)
 The constructor for the corresponding QuaZip constructor. More...
 
 QuaZipPrivate (QuaZip *q, QIODevice *ioDevice)
 The constructor for the corresponding QuaZip constructor. More...
 
template<typename TFileInfo >
bool getFileInfoList (QList< TFileInfo > *result) const
 Returns either a list of file names or a list of QuaZipFileInfo. More...
 
void clearDirectoryMap ()
 Stores map of filenames and file locations for unzipping. More...
 
void addCurrentFileToDirectoryMap (const QString &fileName)
 
bool goToFirstUnmappedFile ()
 

Private Attributes

QuaZipq
 The pointer to the corresponding QuaZip instance. More...
 
QTextCodec * fileNameCodec
 The codec for file names. More...
 
QTextCodec * commentCodec
 The codec for comments. More...
 
QString zipName
 The archive file name. More...
 
QIODeviceioDevice
 The device to access the archive. More...
 
QString comment
 The global comment. More...
 
QuaZip::Mode mode
 The open mode. More...
 
union {
unzFile unzFile_f
 The internal handle for UNZIP modes. More...
 
zipFile zipFile_f
 The internal handle for ZIP modes. More...
 
}; 
 
bool hasCurrentFile_f
 Whether a current file is set. More...
 
int zipError
 The last error. More...
 
bool dataDescriptorWritingEnabled
 Whether the data descriptor writing mode is enabled. More...
 
bool zip64
 The zip64 mode. More...
 
bool autoClose
 The auto-close flag. More...
 
QHash< QString, unz64_file_posdirectoryCaseSensitive
 
QHash< QString, unz64_file_posdirectoryCaseInsensitive
 
unz64_file_pos lastMappedDirectoryEntry
 

Static Private Attributes

static QTextCodec * defaultFileNameCodec = NULL
 

Friends

class QuaZip
 

Detailed Description

This class keeps all the private stuff for the QuaZip class so it can be changed without breaking binary compatibility, according to the Pimpl idiom.

Definition at line 39 of file quazip.cpp.

Constructor & Destructor Documentation

QuaZipPrivate::QuaZipPrivate ( QuaZip q)
inlineprivate

Definition at line 81 of file quazip.cpp.

References lastMappedDirectoryEntry, unz64_file_pos_s::num_of_file, and unz64_file_pos_s::pos_in_zip_directory.

81  :
82  q(q),
84  commentCodec(QTextCodec::codecForLocale()),
85  ioDevice(NULL),
87  hasCurrentFile_f(false),
90  zip64(false),
91  autoClose(true)
92  {
95  }
QIODevice * ioDevice
The device to access the archive.
Definition: quazip.cpp:51
#define UNZ_OK
Definition: unzip.h:79
ZPOS64_T pos_in_zip_directory
Definition: unzip.h:294
ZIP file is not open. This is the initial mode.
Definition: quazip.h:95
QTextCodec * commentCodec
The codec for comments.
Definition: quazip.cpp:47
unz64_file_pos lastMappedDirectoryEntry
Definition: quazip.cpp:139
QTextCodec * getDefaultFileNameCodec()
Definition: quazip.cpp:72
ZPOS64_T num_of_file
Definition: unzip.h:295
bool dataDescriptorWritingEnabled
Whether the data descriptor writing mode is enabled.
Definition: quazip.cpp:67
int zipError
The last error.
Definition: quazip.cpp:65
bool zip64
The zip64 mode.
Definition: quazip.cpp:69
bool autoClose
The auto-close flag.
Definition: quazip.cpp:71
QuaZip * q
The pointer to the corresponding QuaZip instance.
Definition: quazip.cpp:43
bool hasCurrentFile_f
Whether a current file is set.
Definition: quazip.cpp:63
QuaZip::Mode mode
The open mode.
Definition: quazip.cpp:55
QTextCodec * fileNameCodec
The codec for file names.
Definition: quazip.cpp:45
QuaZipPrivate::QuaZipPrivate ( QuaZip q,
const QString &  zipName 
)
inlineprivate

Definition at line 97 of file quazip.cpp.

References lastMappedDirectoryEntry, unz64_file_pos_s::num_of_file, and unz64_file_pos_s::pos_in_zip_directory.

97  :
98  q(q),
100  commentCodec(QTextCodec::codecForLocale()),
101  zipName(zipName),
102  ioDevice(NULL),
104  hasCurrentFile_f(false),
105  zipError(UNZ_OK),
107  zip64(false),
108  autoClose(true)
109  {
112  }
QIODevice * ioDevice
The device to access the archive.
Definition: quazip.cpp:51
#define UNZ_OK
Definition: unzip.h:79
ZPOS64_T pos_in_zip_directory
Definition: unzip.h:294
ZIP file is not open. This is the initial mode.
Definition: quazip.h:95
QTextCodec * commentCodec
The codec for comments.
Definition: quazip.cpp:47
unz64_file_pos lastMappedDirectoryEntry
Definition: quazip.cpp:139
QTextCodec * getDefaultFileNameCodec()
Definition: quazip.cpp:72
ZPOS64_T num_of_file
Definition: unzip.h:295
bool dataDescriptorWritingEnabled
Whether the data descriptor writing mode is enabled.
Definition: quazip.cpp:67
QString zipName
The archive file name.
Definition: quazip.cpp:49
int zipError
The last error.
Definition: quazip.cpp:65
bool zip64
The zip64 mode.
Definition: quazip.cpp:69
bool autoClose
The auto-close flag.
Definition: quazip.cpp:71
QuaZip * q
The pointer to the corresponding QuaZip instance.
Definition: quazip.cpp:43
bool hasCurrentFile_f
Whether a current file is set.
Definition: quazip.cpp:63
QuaZip::Mode mode
The open mode.
Definition: quazip.cpp:55
QTextCodec * fileNameCodec
The codec for file names.
Definition: quazip.cpp:45
QuaZipPrivate::QuaZipPrivate ( QuaZip q,
QIODevice ioDevice 
)
inlineprivate

Definition at line 114 of file quazip.cpp.

References lastMappedDirectoryEntry, unz64_file_pos_s::num_of_file, and unz64_file_pos_s::pos_in_zip_directory.

114  :
115  q(q),
117  commentCodec(QTextCodec::codecForLocale()),
118  ioDevice(ioDevice),
120  hasCurrentFile_f(false),
121  zipError(UNZ_OK),
123  zip64(false),
124  autoClose(true)
125  {
128  }
QIODevice * ioDevice
The device to access the archive.
Definition: quazip.cpp:51
#define UNZ_OK
Definition: unzip.h:79
ZPOS64_T pos_in_zip_directory
Definition: unzip.h:294
ZIP file is not open. This is the initial mode.
Definition: quazip.h:95
QTextCodec * commentCodec
The codec for comments.
Definition: quazip.cpp:47
unz64_file_pos lastMappedDirectoryEntry
Definition: quazip.cpp:139
QTextCodec * getDefaultFileNameCodec()
Definition: quazip.cpp:72
ZPOS64_T num_of_file
Definition: unzip.h:295
bool dataDescriptorWritingEnabled
Whether the data descriptor writing mode is enabled.
Definition: quazip.cpp:67
int zipError
The last error.
Definition: quazip.cpp:65
bool zip64
The zip64 mode.
Definition: quazip.cpp:69
bool autoClose
The auto-close flag.
Definition: quazip.cpp:71
QuaZip * q
The pointer to the corresponding QuaZip instance.
Definition: quazip.cpp:43
bool hasCurrentFile_f
Whether a current file is set.
Definition: quazip.cpp:63
QuaZip::Mode mode
The open mode.
Definition: quazip.cpp:55
QTextCodec * fileNameCodec
The codec for file names.
Definition: quazip.cpp:45

Member Function Documentation

void QuaZipPrivate::addCurrentFileToDirectoryMap ( const QString &  fileName)
inlineprivate

Definition at line 153 of file quazip.cpp.

References directoryCaseInsensitive, directoryCaseSensitive, hasCurrentFile_f, lastMappedDirectoryEntry, unz64_file_pos_s::pos_in_zip_directory, and unzGetFilePos64().

Referenced by QuaZip::getCurrentFileInfo(), and QuaZip::getCurrentFileName().

154 {
155  if (!hasCurrentFile_f || fileName.isEmpty()) {
156  return;
157  }
158  // Adds current file to filename map as fileName
159  unz64_file_pos fileDirectoryPos;
160  unzGetFilePos64(unzFile_f, &fileDirectoryPos);
161  directoryCaseSensitive.insert(fileName, fileDirectoryPos);
162  // Only add lowercase to directory map if not already there
163  // ensures only map the first one seen
164  QString lower = fileName.toLower();
165  if (!directoryCaseInsensitive.contains(lower))
166  directoryCaseInsensitive.insert(lower, fileDirectoryPos);
167  // Mark last one
169  lastMappedDirectoryEntry = fileDirectoryPos;
170 }
QHash< QString, unz64_file_pos > directoryCaseInsensitive
Definition: quazip.cpp:138
ZPOS64_T pos_in_zip_directory
Definition: unzip.h:294
int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos *file_pos)
Definition: unzip.c:1318
unz64_file_pos lastMappedDirectoryEntry
Definition: quazip.cpp:139
QHash< QString, unz64_file_pos > directoryCaseSensitive
Definition: quazip.cpp:137
bool hasCurrentFile_f
Whether a current file is set.
Definition: quazip.cpp:63

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void QuaZipPrivate::clearDirectoryMap ( )
inlineprivate

Definition at line 145 of file quazip.cpp.

References directoryCaseInsensitive, directoryCaseSensitive, lastMappedDirectoryEntry, unz64_file_pos_s::num_of_file, and unz64_file_pos_s::pos_in_zip_directory.

Referenced by QuaZip::close().

146 {
147  directoryCaseInsensitive.clear();
148  directoryCaseSensitive.clear();
151 }
QHash< QString, unz64_file_pos > directoryCaseInsensitive
Definition: quazip.cpp:138
ZPOS64_T pos_in_zip_directory
Definition: unzip.h:294
unz64_file_pos lastMappedDirectoryEntry
Definition: quazip.cpp:139
ZPOS64_T num_of_file
Definition: unzip.h:295
QHash< QString, unz64_file_pos > directoryCaseSensitive
Definition: quazip.cpp:137

+ Here is the caller graph for this function:

QTextCodec* QuaZipPrivate::getDefaultFileNameCodec ( )
inlineprivate

Definition at line 72 of file quazip.cpp.

References defaultFileNameCodec.

73  {
74  if (defaultFileNameCodec == NULL) {
75  return QTextCodec::codecForLocale();
76  } else {
77  return defaultFileNameCodec;
78  }
79  }
static QTextCodec * defaultFileNameCodec
Definition: quazip.cpp:140
template<typename TFileInfo >
bool QuaZipPrivate::getFileInfoList ( QList< TFileInfo > *  result) const
private

Definition at line 687 of file quazip.cpp.

References QuaZip::getCurrentFileName(), QuaZip::goToFirstFile(), QuaZip::goToNextFile(), QuaZip::hasCurrentFile(), QuaZip::mdUnzip, mode, q, QuaZip::setCurrentFile(), UNZ_OK, and zipError.

Referenced by QuaZip::getFileInfoList(), QuaZip::getFileInfoList64(), and QuaZip::getFileNameList().

688 {
689  QuaZipPrivate *fakeThis=const_cast<QuaZipPrivate*>(this);
690  fakeThis->zipError=UNZ_OK;
691  if (mode!=QuaZip::mdUnzip) {
692  qWarning("QuaZip::getFileNameList/getFileInfoList(): "
693  "ZIP is not open in mdUnzip mode");
694  return false;
695  }
696  QString currentFile;
697  if (q->hasCurrentFile()) {
698  currentFile = q->getCurrentFileName();
699  }
700  if (q->goToFirstFile()) {
701  do {
702  bool ok;
703  result->append(QuaZip_getFileInfo<TFileInfo>(q, &ok));
704  if (!ok)
705  return false;
706  } while (q->goToNextFile());
707  }
708  if (zipError != UNZ_OK)
709  return false;
710  if (currentFile.isEmpty()) {
711  if (!q->goToFirstFile())
712  return false;
713  } else {
714  if (!q->setCurrentFile(currentFile))
715  return false;
716  }
717  return true;
718 }
bool goToFirstFile()
Sets the current file to the first file in the archive.
Definition: quazip.cpp:466
QString getCurrentFileName() const
Returns the current file name.
Definition: quazip.cpp:551
#define UNZ_OK
Definition: unzip.h:79
int zipError
The last error.
Definition: quazip.cpp:65
bool goToNextFile()
Sets the current file to the next file in the archive.
Definition: quazip.cpp:478
bool setCurrentFile(const QString &fileName, CaseSensitivity cs=csDefault)
Sets current file by its name.
Definition: quazip.cpp:408
ZIP file is open for reading files inside it.
Definition: quazip.h:96
QuaZip * q
The pointer to the corresponding QuaZip instance.
Definition: quazip.cpp:43
All the internal stuff for the QuaZip class.
Definition: quazip.cpp:39
bool hasCurrentFile() const
Returns true if the current file has been set.
Definition: quazip.cpp:634
QuaZip::Mode mode
The open mode.
Definition: quazip.cpp:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool QuaZipPrivate::goToFirstUnmappedFile ( )
private

Definition at line 172 of file quazip.cpp.

References hasCurrentFile_f, lastMappedDirectoryEntry, QuaZip::mdUnzip, mode, unz64_file_pos_s::pos_in_zip_directory, UNZ_END_OF_LIST_OF_FILE, UNZ_OK, unzGoToFilePos64(), unzGoToFirstFile(), unzGoToNextFile(), and zipError.

Referenced by QuaZip::setCurrentFile().

173 {
174  zipError = UNZ_OK;
175  if (mode != QuaZip::mdUnzip) {
176  qWarning("QuaZipPrivate::goToNextUnmappedFile(): ZIP is not open in mdUnzip mode");
177  return false;
178  }
179  // If not mapped anything, go to beginning
181  unzGoToFirstFile(unzFile_f);
182  } else {
183  // Goto the last one mapped, plus one
185  unzGoToNextFile(unzFile_f);
186  }
190  return hasCurrentFile_f;
191 }
int ZEXPORT unzGoToFirstFile(unzFile file)
Definition: unzip.c:1188
int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos *file_pos)
Definition: unzip.c:1348
#define UNZ_OK
Definition: unzip.h:79
ZPOS64_T pos_in_zip_directory
Definition: unzip.h:294
int ZEXPORT unzGoToNextFile(unzFile file)
Definition: unzip.c:1209
unz64_file_pos lastMappedDirectoryEntry
Definition: quazip.cpp:139
int zipError
The last error.
Definition: quazip.cpp:65
ZIP file is open for reading files inside it.
Definition: quazip.h:96
bool hasCurrentFile_f
Whether a current file is set.
Definition: quazip.cpp:63
QuaZip::Mode mode
The open mode.
Definition: quazip.cpp:55
#define UNZ_END_OF_LIST_OF_FILE
Definition: unzip.h:80

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class QuaZip
friend

Definition at line 40 of file quazip.cpp.

Field Documentation

union { ... }
bool QuaZipPrivate::autoClose
private

Definition at line 71 of file quazip.cpp.

Referenced by QuaZip::isAutoClose(), QuaZip::open(), and QuaZip::setAutoClose().

QString QuaZipPrivate::comment
private

Definition at line 53 of file quazip.cpp.

Referenced by QuaZip::close(), and QuaZip::setComment().

QTextCodec* QuaZipPrivate::commentCodec
private
bool QuaZipPrivate::dataDescriptorWritingEnabled
private
QTextCodec * QuaZipPrivate::defaultFileNameCodec = NULL
staticprivate

Definition at line 140 of file quazip.cpp.

Referenced by getDefaultFileNameCodec(), and QuaZip::setDefaultFileNameCodec().

QHash<QString, unz64_file_pos> QuaZipPrivate::directoryCaseInsensitive
private
QHash<QString, unz64_file_pos> QuaZipPrivate::directoryCaseSensitive
private
QTextCodec* QuaZipPrivate::fileNameCodec
private
bool QuaZipPrivate::hasCurrentFile_f
private
QIODevice* QuaZipPrivate::ioDevice
private
unz64_file_pos QuaZipPrivate::lastMappedDirectoryEntry
private
QuaZip* QuaZipPrivate::q
private

Definition at line 43 of file quazip.cpp.

Referenced by getFileInfoList().

bool QuaZipPrivate::zip64
private

Definition at line 69 of file quazip.cpp.

Referenced by QuaZip::isZip64Enabled(), and QuaZip::setZip64Enabled().

QString QuaZipPrivate::zipName
private

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