AbZip  1.0.0
ZipCentralDir.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 Andy Bray
4 **
5 ** This file is part of AbZip.
6 **
7 ** AbZip is free software: you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License as published by
9 ** the Free Software Foundation, either version 3 of the License, or
10 ** (at your option) any later version.
11 **
12 ** AbZip is distributed in the hope that it will be useful,
13 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ** GNU General Public License for more details.
16 **
17 ** You should have received a copy of the GNU General Public License
18 ** along with AbZip. If not, see <http://www.gnu.org/licenses/>.
19 **
20 ****************************************************************************/
21 
22 #ifndef ZIPCENTRALDIR_H
23 #define ZIPCENTRALDIR_H
24 
25 #include "EndOfCentralDir.h"
26 #include "CentralDirFileHeader.h"
27 #include "AbZip.h"
28 #include "ZipFileInfo.h"
29 
30 #include <QList>
31 #include <QIODevice>
32 
33 
35 {
36 
37 public:
38  ZipCentralDir( );
39  ~ZipCentralDir( );
40 
41 public: //protected:
42 
43  CentralDirFileHeader* findFile( const QString& file, AbZip::ZipOptions options = AbZip::None );
44  bool read( QIODevice* ioDevice, AbZipPrivate* zip );
45  qint64 write(QIODevice* ioDevice );
46 
47  void reset();
48 
49  void setModified(){ modified = true; }
50  bool isModified(){ return modified; }
51 
52  void setOffsetToStartOfCD( qint64 pos );
53  qint64 offsetToStartOfCD();
54 
55  qint64 numberOfEntries();
56  void setNumberOfEntries( qint64 num );
57 
58  qint64 sizeOfCD();
59  void setSizeOfCD( qint64 size );
60 
61  // Adjusts relativeOffsets for when we delete a file
62  void adjustOffsets( qint64 fromOffset, qint64 size );
63 
64  ZipInfo getInfo();
65 
66 //protected:
67 
68  qint64 locateSignature( quint32 signature, QIODevice* ioDevice );
69 
70  QList<CentralDirFileHeader*> entries;
71 
72  qint64 startOfEndOfCD;
73  EndOfCentralDir endOfCentralDir; // We always have one of these
74  EndOfCentralDir64* endOfCentralDir64; // We may have one of these
75  bool modified;
76  bool isValid;
77 
78  // Iterator functions
79  QMap<QString, CentralDirFileHeader*> sortedEntries;
80  QMapIterator<QString, CentralDirFileHeader*> iteratorEntries;
81  qint64 createSortedHeader();
82 
83  CentralDirFileHeader* getFirstFile();
84  CentralDirFileHeader* getNextFile();
85  bool hasNextFile();
86 };
87 
88 #endif // ZIPCENTRALDIR_H
Definition: abzip_p.h:28
Definition: ZipFileInfo.h:10
Definition: ZipCentralDir.h:34
Definition: CentralDirFileHeader.h:39
Definition: EndOfCentralDir.h:36
Definition: EndOfCentralDir.h:77