Main Page
Related Pages
Namespaces
Classes
Files
File List
C:
Users
tdrac
AppData
Local
Temp
ZipArchive-Deploy
7cf2e453-55d1-4019-9f4f-0538167be5a7
DeflateCompressor.h
Go to the documentation of this file.
1
2
// This source file is part of the ZipArchive Library Open Source distribution
3
// and is Copyrighted 2000 - 2022 by Artpol Software - Tadeusz Dracz
4
//
5
// This program is free software; you can redistribute it and/or
6
// modify it under the terms of the GNU General Public License
7
// as published by the Free Software Foundation; either version 2
8
// of the License, or (at your option) any later version.
9
//
10
// For the licensing details refer to the License.txt file.
11
//
12
// Web Site: https://www.artpol-software.com
14
21
#if !defined(ZIPARCHIVE_DEFLATECOMPRESSOR_DOT_H)
22
#define ZIPARCHIVE_DEFLATECOMPRESSOR_DOT_H
23
24
#if _MSC_VER > 1000
25
#pragma once
26
#endif
27
28
#include "ZipExport.h"
29
#include "
BaseLibCompressor.h
"
30
#include "
ZipException.h
"
31
#include "zlib/zlib.h"
32
33
namespace
ZipArchiveLib
34
{
35
39
class
ZIP_API
CDeflateCompressor
:
public
CBaseLibCompressor
40
{
41
public
:
50
struct
ZIP_API
COptions
:
CBaseLibCompressor::COptions
51
{
52
COptions
()
53
{
54
m_bCheckLastBlock =
true
;
55
}
56
57
int
GetType()
const
58
{
59
return
typeDeflate;
60
}
61
62
CZipCompressor::COptions
* Clone()
const
63
{
64
return
new
COptions
(*
this
);
65
}
66
72
bool
m_bCheckLastBlock
;
73
74
};
75
82
CDeflateCompressor
(
CZipStorage
* pStorage);
83
84
bool
CanProcess
(WORD uMethod) {
return
uMethod == methodStore || uMethod == methodDeflate;}
85
86
void
InitCompression(
int
iLevel,
CZipFileHeader
* pFile,
CZipCryptograph
* pCryptograph);
87
void
InitDecompression(
CZipFileHeader
* pFile,
CZipCryptograph
* pCryptograph);
88
89
DWORD Decompress(
void
*pBuffer, DWORD uSize);
90
void
Compress(
const
void
*pBuffer, DWORD uSize);
91
92
void
FinishCompression(
bool
bAfterException);
93
void
FinishDecompression(
bool
bAfterException);
94
95
96
const
CZipCompressor::COptions
* GetOptions()
const
97
{
98
return
&m_options;
99
}
100
101
~
CDeflateCompressor
()
102
{
103
}
104
protected
:
105
void
UpdateOptions(
const
CZipCompressor::COptions
* pOptions)
106
{
107
m_options = *(
COptions
*)pOptions;
108
}
109
110
int
ConvertInternalError(
int
iErr)
const
111
{
112
switch
(iErr)
113
{
114
case
Z_NEED_DICT:
115
return
CZipException::needDict
;
116
case
Z_STREAM_END:
117
return
CZipException::streamEnd
;
118
case
Z_ERRNO:
119
return
CZipException::errNo
;
120
case
Z_STREAM_ERROR:
121
return
CZipException::streamError
;
122
case
Z_DATA_ERROR:
123
return
CZipException::dataError
;
124
case
Z_MEM_ERROR:
125
return
CZipException::memError
;
126
case
Z_BUF_ERROR:
127
return
CZipException::bufError
;
128
case
Z_VERSION_ERROR:
129
return
CZipException::versionError
;
130
default
:
131
return
CZipException::genericError
;
132
}
133
}
134
135
bool
IsCodeErrorOK(
int
iErr)
const
136
{
137
return
iErr == Z_OK || iErr == Z_NEED_DICT;
138
}
139
140
private
:
141
COptions m_options;
142
zarch_z_stream m_stream;
143
};
144
145
}
// namespace
146
147
#endif
148
The ZipArchive Library Copyright © 2000 - 2022 Artpol Software - Tadeusz Dracz. Generated at Sat Dec 17 2022 19:57:03.