AbZip  1.0.0
abzip_p.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 ABZIP_P_H
23 #define ABZIP_P_H
24 
25 #include "ZipCentralDir.h"
26 
27 
29 {
30  friend class ZipArcive;
31  friend class ZipCentralDir;
32 
33 public:
34  AbZipPrivate();
35  AbZipPrivate(const QString& _zipName);
36  AbZipPrivate(QIODevice *_ioDevice);
37 
38  virtual ~AbZipPrivate();
39 
40  bool open( AbZip::Mode mode, AbZip::ZipOptions options = AbZip::None );
41  void close();
42  void flushAndClose();
43  bool isOpen()const;
44  bool checkAutoOpenWrite();
45  bool checkAutoOpenRead();
46 
47  bool backupOrDeleteCurrentZip( AbZip::ZipOptions options );
48 
49  bool addFile(const QString& file, const QString& root = QString(), AbZip::ZipOptions options = AbZip::AddRelativePaths, int level = -1 );
50  bool addFile(const QFileInfo& srcFileInfo, const QString& arcFile, AbZip::ZipOptions options, int level = -1);
51 
52  bool addDirectory(const QString& srcPath, const QString& root = QString(), AbZip::ZipOptions options = AbZip::AddRelativePaths, int level = -1 );
53 
54  quint32 getBestCompressionMethod( QFile& srcFileInfo, AbZip::ZipOptions options );
55 
56  bool extractFile(const QString& filename, const QString& dirname, AbZip::ZipOptions options = AbZip::ExtractPaths);
57  bool extractFile( CentralDirFileHeader* header, const QString& destPath, AbZip::ZipOptions options = AbZip::ExtractPaths);
58  bool extractAll( AbZip& zip, const QString& destPath, const QString& fromRoot, AbZip::ZipOptions options);
59 
60 
61  bool deleteFile(AbZip& zip, const QString& filename, AbZip::ZipOptions options = AbZip::None);
62  bool deleteFile(CentralDirFileHeader* header );
63 
64  QList<ZipFileInfo> findFile( AbZip& zip, const QString& filename, const QString& root, AbZip::ZipOptions options = AbZip::Recursive );
65 
66  bool checkIntegrity();
67 
68  bool setError( int err, QString msg = QString() );
69 
70  ZipInfo getInfo();
71 
72  void init();
73 
74  // The archive file name.
75  QString zipName;
76 
77  // Command stats
78  qint32 filesAdded;
79  qint32 filesExtracted;
80  qint32 filesDeleted;
81  qint32 errorCount;
82 
83 
84  // The io device to access the archive
85  QIODevice *ioDevice;
86 
87  QString password;
88 
89  QStringList nameFilters;
90 
91  int errorCode;
92  QString errorMsg;
93 
94  ZipCentralDir* centralDir;
95 
96  bool commitDeletedFiles();
97  bool writeToTempFile( QIODevice* );
98 
99  QList<CentralDirFileHeader*> deletedEntries;
100 
101  QStringList storeTheseTypes;
102 };
103 
104 #endif // ABZIP_P_H
Definition: abzip_p.h:28
When searching or adding directories, recurse into all sub folders.
Definition: AbZip.h:101
Mode
Definition: AbZip.h:57
Definition: ZipFileInfo.h:10
Definition: ZipCentralDir.h:34
Recreate the relative path from the archive when extracting files.
Definition: AbZip.h:110
Definition: CentralDirFileHeader.h:39
Add files including relative paths.
Definition: AbZip.h:112
Definition: AbZip.h:35