@@ -44,21 +44,71 @@ class QUAZIP_EXPORT JlCompress {
4444public:
4545 class Options {
4646 public:
47- explicit Options (const QDateTime& dateTime = QDateTime())
48- : m_dateTime(dateTime) {}
47+ /* *
48+ * The enum values refer to the comments in the open function of the quazipfile.h file.
49+ *
50+ * The value is represented by two hexadecimal characters,
51+ * the left character indicating the compression method,
52+ * and the right character indicating the compression level.
53+ *
54+ * method == 0 indicates that the file is not compressed but rather stored as is.
55+ * method == 8(Z_DEFLATED) indicates that zlib compression is used.
56+ *
57+ * A higher value of level indicates a smaller size of the compressed file,
58+ * although it also implies more time consumed during the compression process.
59+ */
60+ enum CompressionStrategy
61+ {
62+ // / Storage without compression
63+ Storage = 0x00 , // Z_NO_COMPRESSION 0
64+ // / The fastest compression speed
65+ Fastest = 0x81 , // Z_BEST_SPEED 1
66+ // / Relatively fast compression speed
67+ Faster = 0x83 ,
68+ // / Standard compression speed and ratio
69+ Standard = 0x86 ,
70+ // / Better compression ratio
71+ Better = 0x87 ,
72+ // / The best compression ratio
73+ Best = 0x89 , // Z_BEST_COMPRESSION 9
74+ // / The default compression strategy, according to the open function of quazipfile.h,
75+ // / the value of method is Z_DEFLATED, and the value of level is Z_DEFAULT_COMPRESSION -1 (equals lvl 6)
76+ Default = 0xff
77+ };
4978
50- QDateTime getDateTime () const {
51- return m_dateTime;
52- }
79+ public:
80+ explicit Options (const QDateTime& dateTime = QDateTime(), const CompressionStrategy& strategy = Default)
81+ : m_dateTime(dateTime), m_compressionStrategy(strategy) {}
82+
83+ QDateTime getDateTime () const {
84+ return m_dateTime;
85+ }
86+
87+ void setDateTime (const QDateTime &dateTime) {
88+ m_dateTime = dateTime;
89+ }
90+
91+ CompressionStrategy getCompressionStrategy () const {
92+ return m_compressionStrategy;
93+ }
94+
95+ int getCompressionMethod () const {
96+ return m_compressionStrategy != Default ? m_compressionStrategy >> 4 : Z_DEFLATED;
97+ }
98+
99+ int getCompressionLevel () const {
100+ return m_compressionStrategy != Default ? m_compressionStrategy & 0x0f : Z_DEFAULT_COMPRESSION;
101+ }
53102
54- void setDateTime (const QDateTime &dateTime ) {
55- m_dateTime = dateTime ;
56- }
103+ void setCompressionStrategy (const CompressionStrategy &strategy ) {
104+ m_compressionStrategy = strategy ;
105+ }
57106
58107 private:
59- // If set, used as last modified on file inside the archive.
60- // If compressing a directory, used for all files.
61- QDateTime m_dateTime;
108+ // If set, used as last modified on file inside the archive.
109+ // If compressing a directory, used for all files.
110+ QDateTime m_dateTime;
111+ CompressionStrategy m_compressionStrategy;
62112 };
63113
64114 static bool copyData (QIODevice &inFile, QIODevice &outFile);
@@ -287,7 +337,7 @@ class QUAZIP_EXPORT JlCompress {
287337 list of the entries, including both files and directories if they
288338 are present separately.
289339 */
290- static QStringList getFileList (QIODevice *ioDevice);
340+ static QStringList getFileList (QIODevice *ioDevice);
291341};
292342
293343#endif /* JLCOMPRESSFOLDER_H_ */
0 commit comments