AbZip  1.0.0
CentralDirFileHeader.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 CENTRALDIRFILEHEADER_H
23 #define CENTRALDIRFILEHEADER_H
24 
25 #include "zipglobal.h"
26 #include "LocalFileHeader.h"
27 
28 #include <QObject>
29 #include <QIODevice>
30 #include <QFileInfo>
31 #include <QFile>
32 #include <QDateTime>
33 
34 #define CD_FILE_HEADER_SIZE 46
35 #define CD_FILE_HEADER_SIGNATURE 0x02014b50
36 
37 
38 
40 {
41  Q_OBJECT
42 public:
43  explicit CentralDirFileHeader(QObject *parent = 0);
44  virtual ~CentralDirFileHeader();
45 
46  virtual void initFromFile( const QFileInfo& file );
47 
48 
49  virtual bool read(QIODevice* ioDevice);
50  virtual qint64 write(QIODevice* ioDevice);
51 
52  void setPermissions( QFile::Permissions perm, bool isDir);
53  QFile::Permissions getPermissions();
54 
55  virtual void setSizes( qint64 uncompSize, qint64 compSize, qint64 offset);
56 
57  virtual quint64 getRelativeOffset();
58 
59  virtual bool isDirectory( );
60  bool isValid()
61  {
62  return signature == CD_FILE_HEADER_SIGNATURE;
63  }
64 
65  virtual quint32 size() { return CD_FILE_HEADER_SIZE + fileName.size() + extraField.size() + comment.size(); }
66 
67  virtual ZipFileInfo getFileInfo();
68 
69  void setFileName( const QString& filename );
70 
71  quint16 versionMadeBy;
72  quint16 fileCommentLength;
73  quint16 diskNumberStart;
74  quint16 internalFileAttr;
75  quint32 externalFileAttr;
76  quint32 relativeOffset;
77  QByteArray comment;
78 
79  // Additional members
80  QString sFileName; // A QString version of the QByteArray filename - just for convienience
81 };
82 
83 
84 #endif // CENTRALDIRFILEHEADER_H
Definition: LocalFileHeader.h:52
Definition: CentralDirFileHeader.h:39
Definition: ZipFileInfo.h:35