| 1 |
{**************************************************************************************************} |
| 2 |
{ } |
| 3 |
{ Project JEDI Code Library (JCL) } |
| 4 |
{ } |
| 5 |
{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); } |
| 6 |
{ you may not use this file except in compliance with the License. You may obtain a copy of the } |
| 7 |
{ License at http://www.mozilla.org/MPL/ } |
| 8 |
{ } |
| 9 |
{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF } |
| 10 |
{ ANY KIND, either express or implied. See the License for the specific language governing rights } |
| 11 |
{ and limitations under the License. } |
| 12 |
{ } |
| 13 |
{ The Original Code is JclCompression.pas. } |
| 14 |
{ } |
| 15 |
{ The Initial Developer of the Original Code is Matthias Thoma. } |
| 16 |
{ All Rights Reserved. } |
| 17 |
{ } |
| 18 |
{ Contributors: } |
| 19 |
{ Olivier Sannier (obones) } |
| 20 |
{ Florent Ouchet (outchy) } |
| 21 |
{ Jan Goyvaerts (jgsoft) } |
| 22 |
{ Uwe Schuster (uschuster) } |
| 23 |
{ } |
| 24 |
{**************************************************************************************************} |
| 25 |
{ } |
| 26 |
{ Alternatively, the contents of this file may be used under the terms of the GNU Lesser General } |
| 27 |
{ Public License (the "LGPL License"), in which case the provisions of the LGPL License are } |
| 28 |
{ applicable instead of those above. If you wish to allow use of your version of this file only } |
| 29 |
{ under the terms of the LGPL License and not to allow others to use your version of this file } |
| 30 |
{ under the MPL, indicate your decision by deleting the provisions above and replace them with the } |
| 31 |
{ notice and other provisions required by the LGPL License. If you do not delete the provisions } |
| 32 |
{ above, a recipient may use your version of this file under either the MPL or the LGPL License. } |
| 33 |
{ } |
| 34 |
{ For more information about the LGPL: } |
| 35 |
{ http://www.gnu.org/copyleft/lesser.html } |
| 36 |
{ } |
| 37 |
{**************************************************************************************************} |
| 38 |
{ } |
| 39 |
{ Last modified: $Date:: $ } |
| 40 |
{ Revision: $Rev:: $ } |
| 41 |
{ Author: $Author:: $ } |
| 42 |
{ } |
| 43 |
{**************************************************************************************************} |
| 44 |
|
| 45 |
unit JclCompression; |
| 46 |
|
| 47 |
{$mode delphi} |
| 48 |
|
| 49 |
interface |
| 50 |
|
| 51 |
uses |
| 52 |
{$IFDEF UNITVERSIONING} |
| 53 |
JclUnitVersioning, |
| 54 |
{$ENDIF UNITVERSIONING} |
| 55 |
{$IFDEF HAS_UNIT_LIBC} |
| 56 |
Libc, |
| 57 |
{$ENDIF HAS_UNIT_LIBC} |
| 58 |
{$IFDEF HAS_UNITSCOPE} |
| 59 |
{$IFDEF MSWINDOWS} |
| 60 |
Winapi.Windows, Sevenzip, Winapi.ActiveX, |
| 61 |
{$ENDIF MSWINDOWS} |
| 62 |
System.Types, |
| 63 |
System.SysUtils, System.Classes, System.Contnrs, |
| 64 |
{$IFDEF ZLIB_RTL} |
| 65 |
System.ZLib, |
| 66 |
{$ENDIF ZLIB_RTL} |
| 67 |
{$ELSE ~HAS_UNITSCOPE} |
| 68 |
{$IFDEF MSWINDOWS} |
| 69 |
Windows, Sevenzip, ActiveX, |
| 70 |
{$ENDIF MSWINDOWS} |
| 71 |
Types, |
| 72 |
SysUtils, Classes, Contnrs, |
| 73 |
{$IFDEF ZLIB_RTL} |
| 74 |
ZLib, |
| 75 |
{$ENDIF ZLIB_RTL} |
| 76 |
{$ENDIF ~HAS_UNITSCOPE} |
| 77 |
{$IFNDEF FPC} |
| 78 |
zlibh, bzip2, |
| 79 |
{$ENDIF FPC} |
| 80 |
DCJclAlternative; // Must be after Classes, SysUtils, Windows |
| 81 |
|
| 82 |
{$IFDEF RTL230_UP} |
| 83 |
{$HPPEMIT '// To avoid ambiguity with System::Zlib::z_stream_s we force using ours'} |
| 84 |
{$HPPEMIT '#define z_stream_s Zlibh::z_stream_s'} |
| 85 |
{$ENDIF RTL230_UP} |
| 86 |
|
| 87 |
{************************************************************************************************** |
| 88 |
Class hierarchy |
| 89 |
|
| 90 |
TJclCompressionStream |
| 91 |
| |
| 92 |
|-- TJclCompressStream |
| 93 |
| | |
| 94 |
| |-- TJclZLibCompressStream handled by zlib http://www.zlib.net/ |
| 95 |
| |-- TJclBZIP2CompressStream handled by bzip2 http://www.bzip.net/ |
| 96 |
| |-- TJclGZIPCompressStream handled by zlib http://www.zlib.net/ + JCL |
| 97 |
| |
| 98 |
|-- TJclDecompressStream |
| 99 |
| |
| 100 |
|-- TJclZLibDecompressStream handled by zlib http://www.zlib.net/ |
| 101 |
|-- TBZIP2DecompressStream handled by bzip2 http://www.bzip.net/ |
| 102 |
|-- TGZIPDecompressStream handled by zlib http://www.zlib.net/ + JCL |
| 103 |
|
| 104 |
TJclCompressionArchive |
| 105 |
| |
| 106 |
|-- TJclCompressArchive |
| 107 |
| | |
| 108 |
| |-- TJclSevenzipCompressArchive |
| 109 |
| | |
| 110 |
| |-- TJclZipCompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 111 |
| |-- TJclBZ2CompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 112 |
| |-- TJcl7zCompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 113 |
| |-- TJclTarCompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 114 |
| |-- TJclGZipCompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 115 |
| |-- TJclXzCompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 116 |
| |-- TJclSwfcCompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 117 |
| |-- TJclWimCompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 118 |
| |
| 119 |
|-- TJclDecompressArchive |
| 120 |
| | |
| 121 |
| |-- TJclSevenZipDecompressArchive |
| 122 |
| | |
| 123 |
| |-- TJclZipDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 124 |
| |-- TJclBZ2DecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 125 |
| |-- TJclRarDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 126 |
| |-- TJclArjDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 127 |
| |-- TJclZDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 128 |
| |-- TJclLzhDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 129 |
| |-- TJcl7zDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 130 |
| |-- TJclCabDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 131 |
| |-- TJclNsisDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 132 |
| |-- TJclLzmaDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 133 |
| |-- TJclLzma86DecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 134 |
| |-- TJclPeDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 135 |
| |-- TJclElfDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 136 |
| |-- TJclMachoDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 137 |
| |-- TJclUdfDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 138 |
| |-- TJclXarDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 139 |
| |-- TJclMubDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 140 |
| |-- TJclHfsDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 141 |
| |-- TJclDmgDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 142 |
| |-- TJclCompoundDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 143 |
| |-- TJclWimDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 144 |
| |-- TJclIsoDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 145 |
| |-- TJclBkfDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 146 |
| |-- TJclChmDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 147 |
| |-- TJclSplitDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 148 |
| |-- TJclRpmDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 149 |
| |-- TJclDebDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 150 |
| |-- TJclCpioDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 151 |
| |-- TJclTarDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 152 |
| |-- TJclGZipDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 153 |
| |-- TJclXzDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 154 |
| |-- TJclNtfsDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 155 |
| |-- TJclFatDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 156 |
| |-- TJclMbrDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 157 |
| |-- TJclVhdDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 158 |
| |-- TJclMslzDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 159 |
| |-- TJclFlvDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 160 |
| |-- TJclSwfDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 161 |
| |-- TJclSwfcDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 162 |
| |-- TJclAPMDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 163 |
| |-- TJclPpmdDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 164 |
| |-- TJclTEDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 165 |
| |-- TJclUEFIcDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 166 |
| |-- TJclUEFIsDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 167 |
| |-- TJclSquashFSDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 168 |
| |-- TJclCramFSDecompressArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 169 |
| |
| 170 |
|-- TJclUpdateArchive |
| 171 |
| |
| 172 |
|-- TJclSevenzipUpdateArchive |
| 173 |
| |
| 174 |
|-- TJclZipUpdateArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 175 |
|-- TJclBZ2UpdateArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 176 |
|-- TJcl7zUpdateArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 177 |
|-- TJclTarUpdateArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 178 |
|-- TJclGZipUpdateArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 179 |
|-- TJclXzUpdateArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 180 |
|-- TJclSwfcUpdateArchive handled by sevenzip http://sevenzip.sourceforge.net/ |
| 181 |
|
| 182 |
**************************************************************************************************} |
| 183 |
|
| 184 |
type |
| 185 |
|
| 186 |
{$IFNDEF FPC} |
| 187 |
|
| 188 |
TJclCompressionStream = class(TJclStream) |
| 189 |
private |
| 190 |
FOnProgress: TNotifyEvent; |
| 191 |
FBuffer: Pointer; |
| 192 |
FBufferSize: Cardinal; |
| 193 |
FStream: TStream; |
| 194 |
protected |
| 195 |
function SetBufferSize(Size: Cardinal): Cardinal; virtual; |
| 196 |
procedure Progress(Sender: TObject); dynamic; |
| 197 |
property OnProgress: TNotifyEvent read FOnProgress write FOnProgress; |
| 198 |
public |
| 199 |
class function StreamExtensions: string; virtual; |
| 200 |
class function StreamName: string; virtual; |
| 201 |
class function StreamSubExtensions: string; virtual; |
| 202 |
|
| 203 |
constructor Create(AStream: TStream); |
| 204 |
destructor Destroy; override; |
| 205 |
|
| 206 |
function Read(var Buffer; Count: Longint): Longint; override; |
| 207 |
function Write(const Buffer; Count: Longint): Longint; override; |
| 208 |
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; |
| 209 |
procedure Reset; virtual; |
| 210 |
end; |
| 211 |
|
| 212 |
TJclCompressionStreamClass = class of TJclCompressionStream; |
| 213 |
|
| 214 |
TJclCompressStream = class(TJclCompressionStream) |
| 215 |
public |
| 216 |
function Flush: Integer; dynamic; abstract; |
| 217 |
constructor Create(Destination: TStream); |
| 218 |
end; |
| 219 |
|
| 220 |
TJclCompressStreamClass = class of TJclCompressStream; |
| 221 |
|
| 222 |
TJclDecompressStream = class(TJclCompressionStream) |
| 223 |
private |
| 224 |
FOwnsStream: Boolean; |
| 225 |
public |
| 226 |
constructor Create(Source: TStream; AOwnsStream: Boolean = False); |
| 227 |
destructor Destroy; override; |
| 228 |
end; |
| 229 |
|
| 230 |
TJclDecompressStreamClass = class of TJclDecompressStream; |
| 231 |
|
| 232 |
TJclCompressionStreamFormats = class |
| 233 |
private |
| 234 |
FCompressFormats: TList; |
| 235 |
FDecompressFormats: TList; |
| 236 |
protected |
| 237 |
function GetCompressFormatCount: Integer; |
| 238 |
function GetCompressFormat(Index: Integer): TJclCompressStreamClass; |
| 239 |
function GetDecompressFormatCount: Integer; |
| 240 |
function GetDecompressFormat(Index: Integer): TJclDecompressStreamClass; |
| 241 |
public |
| 242 |
constructor Create; |
| 243 |
destructor Destroy; override; |
| 244 |
|
| 245 |
procedure RegisterFormat(AClass: TJclCompressionStreamClass); |
| 246 |
procedure UnregisterFormat(AClass: TJclCompressionStreamClass); |
| 247 |
|
| 248 |
function FindCompressFormat(const AFileName: TFileName): TJclCompressStreamClass; |
| 249 |
function FindDecompressFormat(const AFileName: TFileName): TJclDecompressStreamClass; |
| 250 |
|
| 251 |
property CompressFormatCount: Integer read GetCompressFormatCount; |
| 252 |
property CompressFormats[Index: Integer]: TJclCompressStreamClass read GetCompressFormat; |
| 253 |
property DecompressFormatCount: Integer read GetDecompressFormatCount; |
| 254 |
property DecompressFormats[Index: Integer]: TJclDecompressStreamClass read GetDecompressFormat; |
| 255 |
end; |
| 256 |
|
| 257 |
// retreive a singleton list containing registered stream classes |
| 258 |
function GetStreamFormats: TJclCompressionStreamFormats; |
| 259 |
|
| 260 |
// ZIP Support |
| 261 |
type |
| 262 |
TJclCompressionLevel = Integer; |
| 263 |
|
| 264 |
TJclZLibCompressStream = class(TJclCompressStream) |
| 265 |
private |
| 266 |
FWindowBits: Integer; |
| 267 |
FMemLevel: Integer; |
| 268 |
FMethod: Integer; |
| 269 |
FStrategy: Integer; |
| 270 |
FDeflateInitialized: Boolean; |
| 271 |
FCompressionLevel: Integer; |
| 272 |
protected |
| 273 |
ZLibRecord: TZStreamRec; |
| 274 |
procedure SetCompressionLevel(Value: Integer); |
| 275 |
procedure SetStrategy(Value: Integer); |
| 276 |
procedure SetMemLevel(Value: Integer); |
| 277 |
procedure SetMethod(Value: Integer); |
| 278 |
procedure SetWindowBits(Value: Integer); |
| 279 |
public |
| 280 |
// stream description |
| 281 |
class function StreamExtensions: string; override; |
| 282 |
class function StreamName: string; override; |
| 283 |
class function StreamSubExtensions: string; override; |
| 284 |
|
| 285 |
constructor Create(Destination: TStream; CompressionLevel: TJclCompressionLevel = -1); |
| 286 |
destructor Destroy; override; |
| 287 |
|
| 288 |
function Flush: Integer; override; |
| 289 |
procedure Reset; override; |
| 290 |
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; |
| 291 |
function Write(const Buffer; Count: Longint): Longint; override; |
| 292 |
|
| 293 |
property WindowBits: Integer read FWindowBits write SetWindowBits; |
| 294 |
property MemLevel: Integer read FMemLevel write SetMemLevel; |
| 295 |
property Method: Integer read FMethod write SetMethod; |
| 296 |
property Strategy: Integer read FStrategy write SetStrategy; |
| 297 |
property CompressionLevel: Integer read FCompressionLevel write SetCompressionLevel; |
| 298 |
end; |
| 299 |
|
| 300 |
{$IFDEF ZLIB_RTL} |
| 301 |
const |
| 302 |
DEF_WBITS = 15; |
| 303 |
{$EXTERNALSYM DEF_WBITS} |
| 304 |
DEF_MEM_LEVEL = 8; |
| 305 |
{$EXTERNALSYM DEF_MEM_LEVEL} |
| 306 |
|
| 307 |
type |
| 308 |
PBytef = PByte; |
| 309 |
{$EXTERNALSYM PBytef} |
| 310 |
{$ENDIF ZLIB_RTL} |
| 311 |
|
| 312 |
type |
| 313 |
TJclZLibDecompressStream = class(TJclDecompressStream) |
| 314 |
private |
| 315 |
FWindowBits: Integer; |
| 316 |
FInflateInitialized: Boolean; |
| 317 |
protected |
| 318 |
ZLibRecord: TZStreamRec; |
| 319 |
procedure SetWindowBits(Value: Integer); |
| 320 |
public |
| 321 |
// stream description |
| 322 |
class function StreamExtensions: string; override; |
| 323 |
class function StreamName: string; override; |
| 324 |
class function StreamSubExtensions: string; override; |
| 325 |
|
| 326 |
constructor Create(Source: TStream; WindowBits: Integer = DEF_WBITS; AOwnsStream: Boolean = False); |
| 327 |
destructor Destroy; override; |
| 328 |
|
| 329 |
function Read(var Buffer; Count: Longint): Longint; override; |
| 330 |
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; |
| 331 |
|
| 332 |
property WindowBits: Integer read FWindowBits write SetWindowBits; |
| 333 |
end; |
| 334 |
|
| 335 |
// GZIP Support |
| 336 |
|
| 337 |
//=== { GZIP helpers } ======================================================= |
| 338 |
|
| 339 |
type |
| 340 |
TJclGZIPHeader = packed record |
| 341 |
ID1: Byte; |
| 342 |
ID2: Byte; |
| 343 |
CompressionMethod: Byte; |
| 344 |
Flags: Byte; |
| 345 |
ModifiedTime: Cardinal; |
| 346 |
ExtraFlags: Byte; |
| 347 |
OS: Byte; |
| 348 |
end; |
| 349 |
|
| 350 |
TJclGZIPFooter = packed record |
| 351 |
DataCRC32: Cardinal; |
| 352 |
DataSize: Cardinal; |
| 353 |
end; |
| 354 |
|
| 355 |
const |
| 356 |
// ID1 and ID2 fields |
| 357 |
JCL_GZIP_ID1 = $1F; // value for the ID1 field |
| 358 |
JCL_GZIP_ID2 = $8B; // value for the ID2 field |
| 359 |
|
| 360 |
// Compression Model field |
| 361 |
JCL_GZIP_CM_DEFLATE = 8; // Zlib classic |
| 362 |
|
| 363 |
// Flags field : extra fields for the header |
| 364 |
JCL_GZIP_FLAG_TEXT = $01; // file is probably ASCII text |
| 365 |
JCL_GZIP_FLAG_CRC = $02; // a CRC16 for the header is present |
| 366 |
JCL_GZIP_FLAG_EXTRA = $04; // extra fields present |
| 367 |
JCL_GZIP_FLAG_NAME = $08; // original file name is present |
| 368 |
JCL_GZIP_FLAG_COMMENT = $10; // comment is present |
| 369 |
|
| 370 |
// ExtraFlags field : compression level |
| 371 |
JCL_GZIP_EFLAG_MAX = 2; // compressor used maximum compression |
| 372 |
JCL_GZIP_EFLAG_FAST = 4; // compressor used fastest compression |
| 373 |
|
| 374 |
// OS field : file system |
| 375 |
JCL_GZIP_OS_FAT = 0; // FAT filesystem (MS-DOS, OS/2, NT/Win32) |
| 376 |
JCL_GZIP_OS_AMIGA = 1; // Amiga |
| 377 |
JCL_GZIP_OS_VMS = 2; // VMS (or OpenVMS) |
| 378 |
JCL_GZIP_OS_UNIX = 3; // Unix |
| 379 |
JCL_GZIP_OS_VM = 4; // VM/CMS |
| 380 |
JCL_GZIP_OS_ATARI = 5; // Atari TOS |
| 381 |
JCL_GZIP_OS_HPFS = 6; // HPFS filesystem (OS/2, NT) |
| 382 |
JCL_GZIP_OS_MAC = 7; // Macintosh |
| 383 |
JCL_GZIP_OS_Z = 8; // Z-System |
| 384 |
JCL_GZIP_OS_CPM = 9; // CP/M |
| 385 |
JCL_GZIP_OS_TOPS = 10; // TOPS-20 |
| 386 |
JCL_GZIP_OS_NTFS = 11; // NTFS filesystem (NT) |
| 387 |
JCL_GZIP_OS_QDOS = 12; // QDOS |
| 388 |
JCL_GZIP_OS_ACORN = 13; // Acorn RISCOS |
| 389 |
JCL_GZIP_OS_UNKNOWN = 255; // unknown |
| 390 |
|
| 391 |
type |
| 392 |
TJclGZIPSubFieldHeader = packed record |
| 393 |
SI1: Byte; |
| 394 |
SI2: Byte; |
| 395 |
Len: Word; |
| 396 |
end; |
| 397 |
|
| 398 |
// constants to identify sub fields in the extra field |
| 399 |
// source: http://www.gzip.org/format.txt |
| 400 |
const |
| 401 |
JCL_GZIP_X_AC1 = $41; // AC Acorn RISC OS/BBC MOS file type information |
| 402 |
JCL_GZIP_X_AC2 = $43; |
| 403 |
JCL_GZIP_X_Ap1 = $41; // Ap Apollo file type information |
| 404 |
JCL_GZIP_X_Ap2 = $70; |
| 405 |
JCL_GZIP_X_cp1 = $63; // cp file compressed by cpio |
| 406 |
JCL_GZIP_X_cp2 = $70; |
| 407 |
JCL_GZIP_X_GS1 = $1D; // GS gzsig |
| 408 |
JCL_GZIP_X_GS2 = $53; |
| 409 |
JCL_GZIP_X_KN1 = $4B; // KN KeyNote assertion (RFC 2704) |
| 410 |
JCL_GZIP_X_KN2 = $4E; |
| 411 |
JCL_GZIP_X_Mc1 = $4D; // Mc Macintosh info (Type and Creator values) |
| 412 |
JCL_GZIP_X_Mc2 = $63; |
| 413 |
JCL_GZIP_X_RO1 = $52; // RO Acorn Risc OS file type information |
| 414 |
JCL_GZIP_X_RO2 = $4F; |
| 415 |
|
| 416 |
type |
| 417 |
TJclGZIPFlag = (gfDataIsText, gfHeaderCRC16, gfExtraField, gfOriginalFileName, gfComment); |
| 418 |
TJclGZIPFlags = set of TJclGZIPFlag; |
| 419 |
TJclGZIPFatSystem = (gfsFat, gfsAmiga, gfsVMS, gfsUnix, gfsVM, gfsAtari, gfsHPFS, |
| 420 |
gfsMac, gfsZ, gfsCPM, gfsTOPS, gfsNTFS, gfsQDOS, gfsAcorn, gfsOther, gfsUnknown); |
| 421 |
|
| 422 |
// Format is described in RFC 1952, http://www.faqs.org/rfcs/rfc1952.html |
| 423 |
TJclGZIPCompressionStream = class(TJclCompressStream) |
| 424 |
private |
| 425 |
FFlags: TJclGZIPFlags; |
| 426 |
FUnixTime: Cardinal; |
| 427 |
FAutoSetTime: Boolean; |
| 428 |
FCompressionLevel: TJclCompressionLevel; |
| 429 |
FFatSystem: TJclGZIPFatSystem; |
| 430 |
FExtraField: string; |
| 431 |
FOriginalFileName: TFileName; |
| 432 |
FComment: string; |
| 433 |
FZLibStream: TJclZLibCompressStream; |
| 434 |
FOriginalSize: Cardinal; |
| 435 |
FDataCRC32: Cardinal; |
| 436 |
FHeaderWritten: Boolean; |
| 437 |
FFooterWritten: Boolean; // flag so we only write the footer once! (NEW 2007) |
| 438 |
|
| 439 |
procedure WriteHeader; |
| 440 |
function GetDosTime: TDateTime; |
| 441 |
function GetUnixTime: Cardinal; |
| 442 |
procedure SetDosTime(const Value: TDateTime); |
| 443 |
procedure SetUnixTime(Value: Cardinal); |
| 444 |
procedure ZLibStreamProgress(Sender: TObject); |
| 445 |
public |
| 446 |
// stream description |
| 447 |
class function StreamExtensions: string; override; |
| 448 |
class function StreamName: string; override; |
| 449 |
class function StreamSubExtensions: string; override; |
| 450 |
|
| 451 |
constructor Create(Destination: TStream; CompressionLevel: TJclCompressionLevel = -1); |
| 452 |
destructor Destroy; override; |
| 453 |
|
| 454 |
function Write(const Buffer; Count: Longint): Longint; override; |
| 455 |
procedure Reset; override; |
| 456 |
// IMPORTANT: In order to get a valid GZip file, Flush MUST be called after |
| 457 |
// the last call to Write. |
| 458 |
function Flush: Integer; override; |
| 459 |
|
| 460 |
property Flags: TJclGZIPFlags read FFlags write FFlags; |
| 461 |
property DosTime: TDateTime read GetDosTime write SetDosTime; |
| 462 |
property UnixTime: Cardinal read GetUnixTime write SetUnixTime; |
| 463 |
property AutoSetTime: Boolean read FAutoSetTime write FAutoSetTime; |
| 464 |
property FatSystem: TJclGZIPFatSystem read FFatSystem write FFatSystem; |
| 465 |
property ExtraField: string read FExtraField write FExtraField; |
| 466 |
// Note: In order for most decompressors to work, the original file name |
| 467 |
// must be given or they would display an empty file name in their list. |
| 468 |
// This does not affect the decompression stream below as it simply reads |
| 469 |
// the value and does not work with it |
| 470 |
property OriginalFileName: TFileName read FOriginalFileName write FOriginalFileName; |
| 471 |
property Comment: string read FComment write FComment; |
| 472 |
end; |
| 473 |
|
| 474 |
TJclGZIPDecompressionStream = class(TJclDecompressStream) |
| 475 |
private |
| 476 |
FHeader: TJclGZIPHeader; |
| 477 |
FFooter: TJclGZIPFooter; |
| 478 |
FCompressedDataStream: TJclDelegatedStream; |
| 479 |
FZLibStream: TJclZLibDecompressStream; |
| 480 |
FOriginalFileName: TFileName; |
| 481 |
FComment: string; |
| 482 |
FExtraField: string; |
| 483 |
FComputedHeaderCRC16: Word; |
| 484 |
FStoredHeaderCRC16: Word; |
| 485 |
FComputedDataCRC32: Cardinal; |
| 486 |
FCompressedDataSize: Int64; |
| 487 |
FDataSize: Int64; |
| 488 |
FDataStarted: Boolean; |
| 489 |
FDataEnded: Boolean; |
| 490 |
FAutoCheckDataCRC32: Boolean; |
| 491 |
function GetCompressedDataSize: Int64; |
| 492 |
function GetComputedDataCRC32: Cardinal; |
| 493 |
function GetDosTime: TDateTime; |
| 494 |
function GetFatSystem: TJclGZIPFatSystem; |
| 495 |
function GetFlags: TJclGZIPFlags; |
| 496 |
function GetOriginalDataSize: Cardinal; |
| 497 |
function GetStoredDataCRC32: Cardinal; |
| 498 |
function ReadCompressedData(Sender: TObject; var Buffer; Count: Longint): Longint; |
| 499 |
procedure ZLibStreamProgress(Sender: TObject); |
| 500 |
public |
| 501 |
// stream description |
| 502 |
class function StreamExtensions: string; override; |
| 503 |
class function StreamName: string; override; |
| 504 |
class function StreamSubExtensions: string; override; |
| 505 |
|
| 506 |
constructor Create(Source: TStream; CheckHeaderCRC: Boolean = True; AOwnsStream: Boolean = False); |
| 507 |
destructor Destroy; override; |
| 508 |
|
| 509 |
function Read(var Buffer; Count: Longint): Longint; override; |
| 510 |
|
| 511 |
property ComputedHeaderCRC16: Word read FComputedHeaderCRC16; |
| 512 |
property StoredHeaderCRC16: Word read FStoredHeaderCRC16; |
| 513 |
property ExtraField: string read FExtraField; |
| 514 |
property OriginalFileName: TFileName read FOriginalFileName; |
| 515 |
property Comment: string read FComment; |
| 516 |
property Flags: TJclGZIPFlags read GetFlags; |
| 517 |
property CompressionLevel: Byte read FHeader.ExtraFlags; |
| 518 |
property FatSystem: TJclGZIPFatSystem read GetFatSystem; |
| 519 |
property UnixTime: Cardinal read FHeader.ModifiedTime; |
| 520 |
property DosTime: TDateTime read GetDosTime; |
| 521 |
property ComputedDataCRC32: Cardinal read GetComputedDataCRC32; |
| 522 |
property StoredDataCRC32: Cardinal read GetStoredDataCRC32; |
| 523 |
property AutoCheckDataCRC32: Boolean read FAutoCheckDataCRC32 write FAutoCheckDataCRC32; |
| 524 |
property CompressedDataSize: Int64 read GetCompressedDataSize; |
| 525 |
property OriginalDataSize: Cardinal read GetOriginalDataSize; |
| 526 |
end; |
| 527 |
|
| 528 |
// BZIP2 Support |
| 529 |
TJclBZIP2CompressionStream = class(TJclCompressStream) |
| 530 |
private |
| 531 |
FDeflateInitialized: Boolean; |
| 532 |
FCompressionLevel: Integer; |
| 533 |
protected |
| 534 |
BZLibRecord: bz_stream; |
| 535 |
procedure SetCompressionLevel(const Value: Integer); |
| 536 |
public |
| 537 |
// stream description |
| 538 |
class function StreamExtensions: string; override; |
| 539 |
class function StreamName: string; override; |
| 540 |
class function StreamSubExtensions: string; override; |
| 541 |
|
| 542 |
constructor Create(Destination: TStream; ACompressionLevel: TJclCompressionLevel = 9); |
| 543 |
destructor Destroy; override; |
| 544 |
|
| 545 |
function Flush: Integer; override; |
| 546 |
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; |
| 547 |
function Write(const Buffer; Count: Longint): Longint; override; |
| 548 |
|
| 549 |
property CompressionLevel: Integer read FCompressionLevel write SetCompressionLevel; |
| 550 |
end; |
| 551 |
|
| 552 |
TJclBZIP2DecompressionStream = class(TJclDecompressStream) |
| 553 |
private |
| 554 |
FInflateInitialized: Boolean; |
| 555 |
protected |
| 556 |
BZLibRecord: bz_stream; |
| 557 |
public |
| 558 |
// stream description |
| 559 |
class function StreamExtensions: string; override; |
| 560 |
class function StreamName: string; override; |
| 561 |
class function StreamSubExtensions: string; override; |
| 562 |
|
| 563 |
constructor Create(Source: TStream; AOwnsStream: Boolean = False); overload; |
| 564 |
destructor Destroy; override; |
| 565 |
|
| 566 |
function Read(var Buffer; Count: Longint): Longint; override; |
| 567 |
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; |
| 568 |
end; |
| 569 |
|
| 570 |
{$ENDIF FPC} |
| 571 |
|
| 572 |
EJclCompressionError = class(EJclError); |
| 573 |
|
| 574 |
{$IFNDEF FPC} |
| 575 |
|
| 576 |
// callback type used in helper functions below: |
| 577 |
TJclCompressStreamProgressCallback = procedure(FileSize, Position: Int64; UserData: Pointer) of object; |
| 578 |
|
| 579 |
{helper functions - one liners by wpostma} |
| 580 |
function GZipFile(SourceFile, DestinationFile: TFileName; CompressionLevel: Integer = Z_DEFAULT_COMPRESSION; |
| 581 |
ProgressCallback: TJclCompressStreamProgressCallback = nil; UserData: Pointer = nil): Boolean; |
| 582 |
function UnGZipFile(SourceFile, DestinationFile: TFileName; |
| 583 |
ProgressCallback: TJclCompressStreamProgressCallback = nil; UserData: Pointer = nil): Boolean; |
| 584 |
procedure GZipStream(SourceStream, DestinationStream: TStream; CompressionLevel: Integer = Z_DEFAULT_COMPRESSION; |
| 585 |
ProgressCallback: TJclCompressStreamProgressCallback = nil; UserData: Pointer = nil); |
| 586 |
procedure UnGZipStream(SourceStream, DestinationStream: TStream; |
| 587 |
ProgressCallback: TJclCompressStreamProgressCallback = nil; UserData: Pointer = nil); |
| 588 |
|
| 589 |
function BZip2File(SourceFile, DestinationFile: TFileName; CompressionLevel: Integer = 5; |
| 590 |
ProgressCallback: TJclCompressStreamProgressCallback = nil; UserData: Pointer = nil): Boolean; |
| 591 |
function UnBZip2File(SourceFile, DestinationFile: TFileName; |
| 592 |
ProgressCallback: TJclCompressStreamProgressCallback = nil; UserData: Pointer = nil): Boolean; |
| 593 |
procedure BZip2Stream(SourceStream, DestinationStream: TStream; CompressionLevel: Integer = 5; |
| 594 |
ProgressCallback: TJclCompressStreamProgressCallback = nil; UserData: Pointer = nil); |
| 595 |
procedure UnBZip2Stream(SourceStream, DestinationStream: TStream; |
| 596 |
ProgressCallback: TJclCompressStreamProgressCallback = nil; UserData: Pointer = nil); |
| 597 |
|
| 598 |
{$ENDIF FPC} |
| 599 |
|
| 600 |
// archive ancestor classes |
| 601 |
{$IFDEF MSWINDOWS} |
| 602 |
type |
| 603 |
TJclCompressionVolumeEvent = procedure(Sender: TObject; Index: Integer; |
| 604 |
var AFileName: TFileName; var AStream: TStream; var AOwnsStream: Boolean) of object; |
| 605 |
TJclCompressionVolumeMaxSizeEvent = procedure(Sender: TObject; Index: Integer; |
| 606 |
var AVolumeMaxSize: Int64) of object; |
| 607 |
TJclCompressionProgressEvent = procedure(Sender: TObject; const Value, MaxValue: Int64) of object; |
| 608 |
TJclCompressionRatioEvent = procedure(Sender: TObject; const InSize, OutSize: Int64) of object; |
| 609 |
TJclCompressionPasswordEvent = procedure(Sender: TObject; var Password: WideString) of object; |
| 610 |
|
| 611 |
TJclCompressionItemProperty = (ipPackedName, ipPackedSize, ipPackedExtension, |
| 612 |
ipFileSize, ipFileName, ipAttributes, ipCreationTime, ipLastAccessTime, |
| 613 |
ipLastWriteTime, ipComment, ipHostOS, ipHostFS, ipUser, ipGroup, ipCRC, |
| 614 |
ipStream, ipMethod, ipEncrypted); |
| 615 |
TJclCompressionItemProperties = set of TJclCompressionItemProperty; |
| 616 |
|
| 617 |
TJclCompressionItemKind = (ikFile, ikDirectory); |
| 618 |
|
| 619 |
TJclCompressionOperationSuccess = (osNoOperation, osOK, osUnsupportedMethod, |
| 620 |
osDataError, osCRCError, osUnknownError); |
| 621 |
|
| 622 |
TJclCompressionDuplicateCheck = (dcNone, dcExisting, dcAll); |
| 623 |
TJclCompressionDuplicateAction = (daOverwrite, daError, daSkip); |
| 624 |
|
| 625 |
TJclCompressionArchive = class; |
| 626 |
|
| 627 |
TJclCompressionItem = class |
| 628 |
private |
| 629 |
FArchive: TJclCompressionArchive; |
| 630 |
// source or destination |
| 631 |
FFileName: TFileName; |
| 632 |
FStream: TStream; |
| 633 |
FOwnsStream: Boolean; |
| 634 |
// miscellaneous |
| 635 |
FValidProperties: TJclCompressionItemProperties; |
| 636 |
FModifiedProperties: TJclCompressionItemProperties; |
| 637 |
FPackedIndex: Cardinal; |
| 638 |
FSelected: Boolean; |
| 639 |
FOperationSuccess: TJclCompressionOperationSuccess; |
| 640 |
// file properties |
| 641 |
FPackedName: WideString; |
| 642 |
FPackedSize: Int64; |
| 643 |
FFileSize: Int64; |
| 644 |
FAttributes: Cardinal; |
| 645 |
FPackedExtension: WideString; |
| 646 |
FCreationTime: TFileTime; |
| 647 |
FLastAccessTime: TFileTime; |
| 648 |
FLastWriteTime: TFileTime; |
| 649 |
FComment: WideString; |
| 650 |
FHostOS: WideString; |
| 651 |
FHostFS: WideString; |
| 652 |
FUser: WideString; |
| 653 |
FGroup: WideString; |
| 654 |
FCRC: Cardinal; |
| 655 |
FMethod: WideString; |
| 656 |
FEncrypted: Boolean; |
| 657 |
function WideChangeFileExt(const AFileName, AExtension: WideString): WideString; |
| 658 |
function WideExtractFileExt(const AFileName: WideString): WideString; |
| 659 |
function WideExtractFileName(const AFileName: WideString): WideString; |
| 660 |
protected |
| 661 |
// property checkers |
| 662 |
procedure CheckGetProperty(AProperty: TJclCompressionItemProperty); virtual; abstract; |
| 663 |
procedure CheckSetProperty(AProperty: TJclCompressionItemProperty); virtual; abstract; |
| 664 |
function ValidateExtraction(Index: Integer): Boolean; virtual; |
| 665 |
function DeleteOutputFile: Boolean; |
| 666 |
function UpdateFileTimes: Boolean; |
| 667 |
// property getters |
| 668 |
function GetAttributes: Cardinal; |
| 669 |
function GetComment: WideString; |
| 670 |
function GetCRC: Cardinal; |
| 671 |
function GetCreationTime: TFileTime; |
| 672 |
function GetDirectory: Boolean; |
| 673 |
function GetEncrypted: Boolean; |
| 674 |
function GetFileName: TFileName; |
| 675 |
function GetFileSize: Int64; |
| 676 |
function GetGroup: WideString; |
| 677 |
function GetHostFS: WideString; |
| 678 |
function GetHostOS: WideString; |
| 679 |
function GetItemKind: TJclCompressionItemKind; |
| 680 |
function GetLastAccessTime: TFileTime; |
| 681 |
function GetLastWriteTime: TFileTime; |
| 682 |
function GetMethod: WideString; |
| 683 |
function GetNestedArchiveName: WideString; virtual; |
| 684 |
function GetNestedArchiveStream: TStream; virtual; |
| 685 |
function GetPackedExtension: WideString; |
| 686 |
function GetPackedName: WideString; |
| 687 |
function GetPackedSize: Int64; |
| 688 |
function GetStream: TStream; |
| 689 |
function GetUser: WideString; |
| 690 |
// property setters |
| 691 |
procedure SetAttributes(Value: Cardinal); |
| 692 |
procedure SetComment(const Value: WideString); |
| 693 |
procedure SetCRC(Value: Cardinal); |
| 694 |
procedure SetCreationTime(const Value: TFileTime); |
| 695 |
procedure SetDirectory(Value: Boolean); |
| 696 |
procedure SetEncrypted(Value: Boolean); |
| 697 |
procedure SetFileName(const Value: TFileName); |
| 698 |
procedure SetFileSize(const Value: Int64); |
| 699 |
procedure SetGroup(const Value: WideString); |
| 700 |
procedure SetHostFS(const Value: WideString); |
| 701 |
procedure SetHostOS(const Value: WideString); |
| 702 |
procedure SetLastAccessTime(const Value: TFileTime); |
| 703 |
procedure SetLastWriteTime(const Value: TFileTime); |
| 704 |
procedure SetMethod(const Value: WideString); |
| 705 |
procedure SetPackedExtension(const Value: WideString); |
| 706 |
procedure SetPackedName(const Value: WideString); |
| 707 |
procedure SetPackedSize(const Value: Int64); |
| 708 |
procedure SetStream(const Value: TStream); |
| 709 |
procedure SetUser(const Value: WideString); |
| 710 |
public |
| 711 |
constructor Create(AArchive: TJclCompressionArchive); |
| 712 |
destructor Destroy; override; |
| 713 |
// release stream if owned and created from file name |
| 714 |
procedure ReleaseStream; |
| 715 |
// properties in archive |
| 716 |
property Attributes: Cardinal read GetAttributes write SetAttributes; |
| 717 |
property Comment: WideString read GetComment write SetComment; |
| 718 |
property CRC: Cardinal read GetCRC write SetCRC; |
| 719 |
property CreationTime: TFileTime read GetCreationTime write SetCreationTime; |
| 720 |
property Directory: Boolean read GetDirectory write SetDirectory; |
| 721 |
property Encrypted: Boolean read GetEncrypted write SetEncrypted; |
| 722 |
property FileSize: Int64 read GetFileSize write SetFileSize; |
| 723 |
property Group: WideString read GetGroup write SetGroup; |
| 724 |
property HostOS: WideString read GetHostOS write SetHostOS; |
| 725 |
property HostFS: WideString read GetHostFS write SetHostFS; |
| 726 |
property Kind: TJclCompressionItemKind read GetItemKind; |
| 727 |
property LastAccessTime: TFileTime read GetLastAccessTime write SetLastAccessTime; |
| 728 |
property LastWriteTime: TFileTime read GetLastWriteTime write SetLastWriteTime; |
| 729 |
property Method: WideString read GetMethod write SetMethod; |
| 730 |
property PackedExtension: WideString read GetPackedExtension write SetPackedExtension; |
| 731 |
property PackedName: WideString read GetPackedName write SetPackedName; |
| 732 |
property PackedSize: Int64 read GetPackedSize write SetPackedSize; |
| 733 |
property User: WideString read GetUser write SetUser; |
| 734 |
// source or destination |
| 735 |
property FileName: TFileName read GetFileName write SetFileName; |
| 736 |
property OwnsStream: Boolean read FOwnsStream write FOwnsStream; |
| 737 |
property Stream: TStream read GetStream write SetStream; |
| 738 |
property NestedArchiveStream: TStream read GetNestedArchiveStream; |
| 739 |
property NestedArchiveName: WideString read GetNestedArchiveName; |
| 740 |
// miscellaneous |
| 741 |
property Archive: TJclCompressionArchive read FArchive; |
| 742 |
property OperationSuccess: TJclCompressionOperationSuccess read FOperationSuccess |
| 743 |
write FOperationSuccess; |
| 744 |
property ValidProperties: TJclCompressionItemProperties read FValidProperties; |
| 745 |
property ModifiedProperties: TJclCompressionItemProperties read FModifiedProperties |
| 746 |
write FModifiedProperties; |
| 747 |
property PackedIndex: Cardinal read FPackedIndex; |
| 748 |
property Selected: Boolean read FSelected write FSelected; |
| 749 |
end; |
| 750 |
|
| 751 |
TJclCompressionItemClass = class of TJclCompressionItem; |
| 752 |
|
| 753 |
TJclCompressionVolume = class |
| 754 |
protected |
| 755 |
FFileName: TFileName; |
| 756 |
FTmpFileName: TFileName; |
| 757 |
FStream: TStream; |
| 758 |
FTmpStream: TStream; |
| 759 |
FOwnsStream: Boolean; |
| 760 |
FOwnsTmpStream: Boolean; |
| 761 |
FVolumeMaxSize: Int64; |
| 762 |
public |
| 763 |
constructor Create(AStream, ATmpStream: TStream; AOwnsStream, AOwnsTmpStream: Boolean; |
| 764 |
AFileName, ATmpFileName: TFileName; AVolumeMaxSize: Int64); |
| 765 |
destructor Destroy; override; |
| 766 |
procedure ReleaseStreams; |
| 767 |
property FileName: TFileName read FFileName; |
| 768 |
property TmpFileName: TFileName read FTmpFileName; |
| 769 |
property Stream: TStream read FStream; |
| 770 |
property TmpStream: TStream read FTmpStream; |
| 771 |
property OwnsStream: Boolean read FOwnsStream; |
| 772 |
property OwnsTmpStream: Boolean read FOwnsTmpStream; |
| 773 |
property VolumeMaxSize: Int64 read FVolumeMaxSize; |
| 774 |
end; |
| 775 |
|
| 776 |
TJclStreamAccess = (saCreate, saReadOnly, saReadOnlyDenyNone, saWriteOnly, saReadWrite); |
| 777 |
|
| 778 |
{ TJclCompressionArchive is not ref-counted } |
| 779 |
TJclCompressionArchive = class(TInterfacedObject, IInterface) |
| 780 |
private |
| 781 |
FOnProgress: TJclCompressionProgressEvent; |
| 782 |
FOnRatio: TJclCompressionRatioEvent; |
| 783 |
FOnVolume: TJclCompressionVolumeEvent; |
| 784 |
FOnVolumeMaxSize: TJclCompressionVolumeMaxSizeEvent; |
| 785 |
FOnPassword: TJclCompressionPasswordEvent; |
| 786 |
FPassword: WideString; |
| 787 |
FVolumeIndex: Integer; |
| 788 |
FVolumeIndexOffset: Integer; |
| 789 |
FVolumeMaxSize: Int64; |
| 790 |
FVolumeFileNameMask: TFileName; |
| 791 |
FProgressMax: Int64; |
| 792 |
FCancelCurrentOperation: Boolean; |
| 793 |
FCurrentItemIndex: Integer; |
| 794 |
function GetItemCount: Integer; |
| 795 |
function GetItem(Index: Integer): TJclCompressionItem; |
| 796 |
function GetVolumeCount: Integer; |
| 797 |
function GetVolume(Index: Integer): TJclCompressionVolume; |
| 798 |
protected |
| 799 |
FVolumes: TObjectList; |
| 800 |
FItems: TObjectList; |
| 801 |
|
| 802 |
procedure InitializeArchiveProperties; virtual; |
| 803 |
|
| 804 |
function InternalOpenStream(const FileName: TFileName): TStream; |
| 805 |
function TranslateItemPath(const ItemPath, OldBase, NewBase: WideString): WideString; |
| 806 |
|
| 807 |
function DoProgress(const Value, MaxValue: Int64): Boolean; |
| 808 |
function DoRatio(const InSize, OutSize: Int64): Boolean; |
| 809 |
function NeedStream(Index: Integer): TStream; |
| 810 |
function NeedStreamMaxSize(Index: Integer): Int64; |
| 811 |
procedure ReleaseVolumes; |
| 812 |
function GetItemClass: TJclCompressionItemClass; virtual; abstract; |
| 813 |
function GetSupportsNestedArchive: Boolean; virtual; |
| 814 |
public |
| 815 |
{ IInterface } |
| 816 |
// function QueryInterface(const IID: TGUID; out Obj): HRESULT; stdcall; |
| 817 |
function _AddRef: Integer; stdcall; |
| 818 |
function _Release: Integer; stdcall; |
| 819 |
public |
| 820 |
PropNames: array of WideString; |
| 821 |
PropValues: array of TPropVariant; |
| 822 |
public |
| 823 |
class function MultipleItemContainer: Boolean; virtual; |
| 824 |
class function VolumeAccess: TJclStreamAccess; virtual; |
| 825 |
function ItemAccess: TJclStreamAccess; virtual; |
| 826 |
class function ArchiveExtensions: string; virtual; |
| 827 |
class function ArchiveName: string; virtual; |
| 828 |
class function ArchiveSubExtensions: string; virtual; |
| 829 |
class function ArchiveSignature: TDynByteArray; virtual; |
| 830 |
|
| 831 |
constructor Create(Volume0: TStream; AVolumeMaxSize: Int64 = 0; |
| 832 |
AOwnVolume: Boolean = False); overload; virtual; |
| 833 |
constructor Create(const VolumeFileName: TFileName; AVolumeMaxSize: Int64 = 0; |
| 834 |
VolumeMask: Boolean = False); overload; virtual; |
| 835 |
// if VolumeMask is true then VolumeFileName represents a mask to get volume file names |
| 836 |
// "myfile%d.zip" "myfile.zip.%.3d" ... |
| 837 |
destructor Destroy; override; |
| 838 |
|
| 839 |
function AddVolume(const VolumeFileName: TFileName; |
| 840 |
AVolumeMaxSize: Int64 = 0): Integer; overload; virtual; |
| 841 |
function AddVolume(const VolumeFileName, TmpVolumeFileName: TFileName; |
| 842 |
AVolumeMaxSize: Int64 = 0): Integer; overload; virtual; |
| 843 |
function AddVolume(VolumeStream: TStream; AVolumeMaxSize: Int64 = 0; |
| 844 |
AOwnsStream: Boolean = False): Integer; overload; virtual; |
| 845 |
function AddVolume(VolumeStream, TmpVolumeStream: TStream; AVolumeMaxSize: Int64 = 0; |
| 846 |
AOwnsStream: Boolean = False; AOwnsTmpStream: Boolean = False): Integer; overload; virtual; |
| 847 |
|
| 848 |
// miscellaneous |
| 849 |
procedure ClearVolumes; |
| 850 |
procedure ClearItems; |
| 851 |
|
| 852 |
procedure CheckOperationSuccess; |
| 853 |
procedure ClearOperationSuccess; |
| 854 |
procedure SelectAll; |
| 855 |
procedure UnselectAll; |
| 856 |
|
| 857 |
property ItemCount: Integer read GetItemCount; |
| 858 |
property Items[Index: Integer]: TJclCompressionItem read GetItem; |
| 859 |
|
| 860 |
property VolumeCount: Integer read GetVolumeCount; |
| 861 |
property Volumes[Index: Integer]: TJclCompressionVolume read GetVolume; |
| 862 |
property VolumeMaxSize: Int64 read FVolumeMaxSize; |
| 863 |
property VolumeFileNameMask: TFileName read FVolumeFileNameMask; |
| 864 |
property VolumeIndexOffset: Integer read FVolumeIndexOffset write FVolumeIndexOffset; |
| 865 |
|
| 866 |
property CurrentItemIndex: Integer read FCurrentItemIndex; // valid during OnProgress |
| 867 |
property OnProgress: TJclCompressionProgressEvent read FOnProgress write FOnProgress; |
| 868 |
property OnRatio: TJclCompressionRatioEvent read FOnRatio write FOnRatio; |
| 869 |
|
| 870 |
// volume events |
| 871 |
property OnVolume: TJclCompressionVolumeEvent read FOnVolume write FOnVolume; |
| 872 |
property OnVolumeMaxSize: TJclCompressionVolumeMaxSizeEvent read FOnVolumeMaxSize |
| 873 |
write FOnVolumeMaxSize; |
| 874 |
property OnPassword: TJclCompressionPasswordEvent read FOnPassword write FOnPassword; |
| 875 |
property Password: WideString read FPassword write FPassword; |
| 876 |
|
| 877 |
property SupportsNestedArchive: Boolean read GetSupportsNestedArchive; |
| 878 |
property CancelCurrentOperation: Boolean read FCancelCurrentOperation write FCancelCurrentOperation; |
| 879 |
end; |
| 880 |
|
| 881 |
TJclCompressionArchiveClass = class of TJclCompressionArchive; |
| 882 |
|
| 883 |
IJclArchiveNumberOfThreads = interface |
| 884 |
['{9CFAB801-E68E-4A51-AC49-277B297F1141}'] |
| 885 |
function GetNumberOfThreads: Cardinal; |
| 886 |
procedure SetNumberOfThreads(Value: Cardinal); |
| 887 |
property NumberOfThreads: Cardinal read GetNumberOfThreads write SetNumberOfThreads; |
| 888 |
end; |
| 889 |
|
| 890 |
IJclArchiveCompressionLevel = interface |
| 891 |
['{A6A2F55F-2860-4E44-BC20-8C5D3E322AB6}'] |
| 892 |
function GetCompressionLevel: Cardinal; |
| 893 |
function GetCompressionLevelMax: Cardinal; |
| 894 |
function GetCompressionLevelMin: Cardinal; |
| 895 |
procedure SetCompressionLevel(Value: Cardinal); |
| 896 |
property CompressionLevel: Cardinal read GetCompressionLevel write SetCompressionLevel; |
| 897 |
property CompressionLevelMax: Cardinal read GetCompressionLevelMax; |
| 898 |
property CompressionLevelMin: Cardinal read GetCompressionLevelMin; |
| 899 |
end; |
| 900 |
|
| 901 |
TJclCompressionMethod = (cmCopy, cmDeflate, cmDeflate64, cmBZip2, cmLZMA, cmLZMA2, cmPPMd); |
| 902 |
TJclCompressionMethods = set of TJclCompressionMethod; |
| 903 |
|
| 904 |
IJclArchiveCompressionMethod = interface |
| 905 |
['{2818F8E8-7D5F-4C8C-865E-9BA4512BB766}'] |
| 906 |
function GetCompressionMethod: TJclCompressionMethod; |
| 907 |
function GetSupportedCompressionMethods: TJclCompressionMethods; |
| 908 |
procedure SetCompressionMethod(Value: TJclCompressionMethod); |
| 909 |
property CompressionMethod: TJclCompressionMethod read GetCompressionMethod write SetCompressionMethod; |
| 910 |
property SupportedCompressionMethods: TJclCompressionMethods read GetSupportedCompressionMethods; |
| 911 |
end; |
| 912 |
|
| 913 |
TJclEncryptionMethod = (emNone, emAES128, emAES192, emAES256, emZipCrypto); |
| 914 |
TJclEncryptionMethods = set of TJclEncryptionMethod; |
| 915 |
|
| 916 |
IJclArchiveEncryptionMethod = interface |
| 917 |
['{643485B6-66A1-41C9-A13B-0A8453E9D0C9}'] |
| 918 |
function GetEncryptionMethod: TJclEncryptionMethod; |
| 919 |
function GetSupportedEncryptionMethods: TJclEncryptionMethods; |
| 920 |
procedure SetEncryptionMethod(Value: TJclEncryptionMethod); |
| 921 |
property EncryptionMethod: TJclEncryptionMethod read GetEncryptionMethod write SetEncryptionMethod; |
| 922 |
property SupportedEncryptionMethods: TJclEncryptionMethods read GetSupportedEncryptionMethods; |
| 923 |
end; |
| 924 |
|
| 925 |
IJclArchiveDictionarySize = interface |
| 926 |
['{D3949834-9F3B-49BC-8403-FE3CE5FDCF35}'] |
| 927 |
function GetDictionarySize: Cardinal; |
| 928 |
procedure SetDictionarySize(Value: Cardinal); |
| 929 |
property DictionarySize: Cardinal read GetDictionarySize write SetDictionarySize; |
| 930 |
end; |
| 931 |
|
| 932 |
IJclArchiveNumberOfPasses = interface |
| 933 |
['{C61B2814-50CE-4C3C-84A5-BACF8A57E3BC}'] |
| 934 |
function GetNumberOfPasses: Cardinal; |
| 935 |
procedure SetNumberOfPasses(Value: Cardinal); |
| 936 |
property NumberOfPasses: Cardinal read GetNumberOfPasses write SetNumberOfPasses; |
| 937 |
end; |
| 938 |
|
| 939 |
IJclArchiveRemoveSfxBlock = interface |
| 940 |
['{852D050D-734E-4610-902A-8FB845DB32A9}'] |
| 941 |
function GetRemoveSfxBlock: Boolean; |
| 942 |
procedure SetRemoveSfxBlock(Value: Boolean); |
| 943 |
property RemoveSfxBlock: Boolean read GetRemoveSfxBlock write SetRemoveSfxBlock; |
| 944 |
end; |
| 945 |
|
| 946 |
IJclArchiveCompressHeader = interface |
| 947 |
['{22C62A3B-A58E-4F88-9D3F-08586B542639}'] |
| 948 |
function GetCompressHeader: Boolean; |
| 949 |
function GetCompressHeaderFull: Boolean; |
| 950 |
procedure SetCompressHeader(Value: Boolean); |
| 951 |
procedure SetCompressHeaderFull(Value: Boolean); |
| 952 |
property CompressHeader: Boolean read GetCompressHeader write SetCompressHeader; |
| 953 |
property CompressHeaderFull: Boolean read GetCompressHeaderFull write SetCompressHeaderFull; |
| 954 |
end; |
| 955 |
|
| 956 |
IJclArchiveEncryptHeader = interface |
| 957 |
['{7DBA20A8-48A1-4CA2-B9AC-41C219A09A4A}'] |
| 958 |
function GetEncryptHeader: Boolean; |
| 959 |
procedure SetEncryptHeader(Value: Boolean); |
| 960 |
property EncryptHeader: Boolean read GetEncryptHeader write SetEncryptHeader; |
| 961 |
end; |
| 962 |
|
| 963 |
IJclArchiveSaveCreationDateTime = interface |
| 964 |
['{8B212BF9-C13F-4582-A4FA-A40E538EFF65}'] |
| 965 |
function GetSaveCreationDateTime: Boolean; |
| 966 |
procedure SetSaveCreationDateTime(Value: Boolean); |
| 967 |
property SaveCreationDateTime: Boolean read GetSaveCreationDateTime write SetSaveCreationDateTime; |
| 968 |
end; |
| 969 |
|
| 970 |
IJclArchiveSaveLastAccessDateTime = interface |
| 971 |
['{1A4B2906-9DD2-4584-B7A3-3639DA92AFC5}'] |
| 972 |
function GetSaveLastAccessDateTime: Boolean; |
| 973 |
procedure SetSaveLastAccessDateTime(Value: Boolean); |
| 974 |
property SaveLastAccessDateTime: Boolean read GetSaveLastAccessDateTime write SetSaveLastAccessDateTime; |
| 975 |
end; |
| 976 |
|
| 977 |
IJclArchiveSaveLastWriteDateTime = interface |
| 978 |
['{0C1729DC-35E8-43D4-8ECA-54F20CDFF87A}'] |
| 979 |
function GetSaveLastWriteDateTime: Boolean; |
| 980 |
procedure SetSaveLastWriteDateTime(Value: Boolean); |
| 981 |
property SaveLastWriteDateTime: Boolean read GetSaveLastWriteDateTime write SetSaveLastWriteDateTime; |
| 982 |
end; |
| 983 |
|
| 984 |
IJclArchiveAlgorithm = interface |
| 985 |
['{53965F1F-24CC-4548-B9E8-5AE2EB7F142D}'] |
| 986 |
function GetAlgorithm: Cardinal; |
| 987 |
function GetSupportedAlgorithms: TDynCardinalArray; |
| 988 |
procedure SetAlgorithm(Value: Cardinal); |
| 989 |
property Algorithm: Cardinal read GetAlgorithm write SetAlgorithm; |
| 990 |
property SupportedAlgorithms: TDynCardinalArray read GetSupportedAlgorithms; |
| 991 |
end; |
| 992 |
|
| 993 |
IJclArchiveSolid = interface |
| 994 |
['{6902C54C-1577-422C-B18B-E27953A28661}'] |
| 995 |
function GetSolidBlockSize: Int64; |
| 996 |
function GetSolidExtension: Boolean; |
| 997 |
procedure SetSolidBlockSize(const Value: Int64); |
| 998 |
procedure SetSolidExtension(Value: Boolean); |
| 999 |
property SolidBlockSize: Int64 read GetSolidBlockSize write SetSolidBlockSize; |
| 1000 |
property SolidExtension: Boolean read GetSolidExtension write SetSolidExtension; |
| 1001 |
end; |
| 1002 |
|
| 1003 |
TJclCompressItem = class(TJclCompressionItem) |
| 1004 |
protected |
| 1005 |
procedure CheckGetProperty(AProperty: TJclCompressionItemProperty); override; |
| 1006 |
procedure CheckSetProperty(AProperty: TJclCompressionItemProperty); override; |
| 1007 |
end; |
| 1008 |
|
| 1009 |
TJclCompressArchive = class(TJclCompressionArchive, IInterface) |
| 1010 |
private |
| 1011 |
FBaseRelName: WideString; |
| 1012 |
FBaseDirName: string; |
| 1013 |
FAddFilesInDir: Boolean; |
| 1014 |
FDuplicateAction: TJclCompressionDuplicateAction; |
| 1015 |
FDuplicateCheck: TJclCompressionDuplicateCheck; |
| 1016 |
procedure InternalAddFile(const Directory: string; const FileInfo: TSearchRec); |
| 1017 |
procedure InternalAddDirectory(const Directory: string); |
| 1018 |
protected |
| 1019 |
FCompressing: Boolean; |
| 1020 |
FPackedNames: TJclWideStringList; |
| 1021 |
procedure CheckNotCompressing; |
| 1022 |
function AddFileCheckDuplicate(NewItem: TJclCompressionItem): Integer; |
| 1023 |
public |
| 1024 |
class function VolumeAccess: TJclStreamAccess; override; |
| 1025 |
function ItemAccess: TJclStreamAccess; override; |
| 1026 |
|
| 1027 |
destructor Destroy; override; |
| 1028 |
|
| 1029 |
function AddDirectory(const PackedName: WideString; |
| 1030 |
const DirName: string = ''; RecurseIntoDir: Boolean = False; |
| 1031 |
AddFilesInDir: Boolean = False): Integer; overload; virtual; |
| 1032 |
function AddFile(const PackedName: WideString; |
| 1033 |
const FileName: TFileName): Integer; overload; virtual; |
| 1034 |
function AddFile(const PackedName: WideString; AStream: TStream; |
| 1035 |
AOwnsStream: Boolean = False): Integer; overload; virtual; |
| 1036 |
procedure Compress; virtual; |
| 1037 |
|
| 1038 |
property DuplicateCheck: TJclCompressionDuplicateCheck read FDuplicateCheck write FDuplicateCheck; |
| 1039 |
property DuplicateAction: TJclCompressionDuplicateAction read FDuplicateAction write FDuplicateAction; |
| 1040 |
end; |
| 1041 |
|
| 1042 |
TJclCompressArchiveClass = class of TJclCompressArchive; |
| 1043 |
|
| 1044 |
TJclCompressArchiveClassArray = array of TJclCompressArchiveClass; |
| 1045 |
|
| 1046 |
TJclDecompressItem = class(TJclCompressionItem) |
| 1047 |
protected |
| 1048 |
procedure CheckGetProperty(AProperty: TJclCompressionItemProperty); override; |
| 1049 |
procedure CheckSetProperty(AProperty: TJclCompressionItemProperty); override; |
| 1050 |
function ValidateExtraction(Index: Integer): Boolean; override; |
| 1051 |
end; |
| 1052 |
|
| 1053 |
// return False not to extract this file |
| 1054 |
// assign your own FileName, Stream or AOwnsStream to override default one |
| 1055 |
TJclCompressionExtractEvent = function (Sender: TObject; Index: Integer; |
| 1056 |
var FileName: TFileName; var Stream: TStream; var AOwnsStream: Boolean): Boolean of object; |
| 1057 |
|
| 1058 |
TJclDecompressArchive = class(TJclCompressionArchive, IInterface) |
| 1059 |
private |
| 1060 |
FOnExtract: TJclCompressionExtractEvent; |
| 1061 |
FAutoCreateSubDir: Boolean; |
| 1062 |
protected |
| 1063 |
FDecompressing: Boolean; |
| 1064 |
FListing: Boolean; |
| 1065 |
FDestinationDir: string; |
| 1066 |
FExtractingAllIndex: Integer; |
| 1067 |
procedure CheckNotDecompressing; |
| 1068 |
procedure CheckListing; |
| 1069 |
|
| 1070 |
function ValidateExtraction(Index: Integer; var FileName: TFileName; var AStream: TStream; |
| 1071 |
var AOwnsStream: Boolean): Boolean; virtual; |
| 1072 |
public |
| 1073 |
class function VolumeAccess: TJclStreamAccess; override; |
| 1074 |
function ItemAccess: TJclStreamAccess; override; |
| 1075 |
|
| 1076 |
procedure ListFiles; virtual; abstract; |
| 1077 |
procedure ExtractSelected(const ADestinationDir: string = ''; |
| 1078 |
AAutoCreateSubDir: Boolean = True); virtual; |
| 1079 |
procedure ExtractAll(const ADestinationDir: string = ''; |
| 1080 |
AAutoCreateSubDir: Boolean = True); virtual; |
| 1081 |
|
| 1082 |
property OnExtract: TJclCompressionExtractEvent read FOnExtract write FOnExtract; |
| 1083 |
property DestinationDir: string read FDestinationDir; |
| 1084 |
property AutoCreateSubDir: Boolean read FAutoCreateSubDir; |
| 1085 |
end; |
| 1086 |
|
| 1087 |
TJclDecompressArchiveClass = class of TJclDecompressArchive; |
| 1088 |
|
| 1089 |
TJclDecompressArchiveClassArray = array of TJclDecompressArchiveClass; |
| 1090 |
|
| 1091 |
TJclUpdateItem = class(TJclCompressionItem) |
| 1092 |
protected |
| 1093 |
procedure CheckGetProperty(AProperty: TJclCompressionItemProperty); override; |
| 1094 |
procedure CheckSetProperty(AProperty: TJclCompressionItemProperty); override; |
| 1095 |
function ValidateExtraction(Index: Integer): Boolean; override; |
| 1096 |
end; |
| 1097 |
|
| 1098 |
TJclUpdateArchive = class(TJclCompressArchive, IInterface) |
| 1099 |
private |
| 1100 |
FOnExtract: TJclCompressionExtractEvent; |
| 1101 |
FAutoCreateSubDir: Boolean; |
| 1102 |
protected |
| 1103 |
FDecompressing: Boolean; |
| 1104 |
FListing: Boolean; |
| 1105 |
FDestinationDir: string; |
| 1106 |
FExtractingAllIndex: Integer; |
| 1107 |
procedure CheckNotDecompressing; |
| 1108 |
procedure CheckListing; |
| 1109 |
|
| 1110 |
procedure InitializeArchiveProperties; override; |
| 1111 |
|
| 1112 |
function ValidateExtraction(Index: Integer; var FileName: TFileName; var AStream: TStream; |
| 1113 |
var AOwnsStream: Boolean): Boolean; virtual; |
| 1114 |
public |
| 1115 |
class function VolumeAccess: TJclStreamAccess; override; |
| 1116 |
function ItemAccess: TJclStreamAccess; override; |
| 1117 |
|
| 1118 |
procedure ListFiles; virtual; abstract; |
| 1119 |
procedure ExtractSelected(const ADestinationDir: string = ''; |
| 1120 |
AAutoCreateSubDir: Boolean = True); virtual; |
| 1121 |
procedure ExtractAll(const ADestinationDir: string = ''; |
| 1122 |
AAutoCreateSubDir: Boolean = True); virtual; |
| 1123 |
procedure DeleteItem(Index: Integer); virtual; abstract; |
| 1124 |
procedure RemoveItem(const PackedName: WideString); virtual; abstract; |
| 1125 |
|
| 1126 |
property OnExtract: TJclCompressionExtractEvent read FOnExtract write FOnExtract; |
| 1127 |
property DestinationDir: string read FDestinationDir; |
| 1128 |
property AutoCreateSubDir: Boolean read FAutoCreateSubDir; |
| 1129 |
end; |
| 1130 |
|
| 1131 |
// ancestor class for all archives that update files in-place (not creating a copy of the volumes) |
| 1132 |
TJclInPlaceUpdateArchive = class(TJclUpdateArchive, IInterface) |
| 1133 |
end; |
| 1134 |
|
| 1135 |
// called when tmp volumes will replace volumes after out-of-place update |
| 1136 |
TJclCompressionReplaceEvent = function (Sender: TObject; const SrcFileName, DestFileName: TFileName; |
| 1137 |
var SrcStream, DestStream: TStream; var OwnsSrcStream, OwnsDestStream: Boolean): Boolean of object; |
| 1138 |
|
| 1139 |
// ancestor class for all archives that update files out-of-place (by creating a copy of the volumes) |
| 1140 |
TJclOutOfPlaceUpdateArchive = class(TJclUpdateArchive, IInterface) |
| 1141 |
private |
| 1142 |
FReplaceVolumes: Boolean; |
| 1143 |
FTmpVolumeIndex: Integer; |
| 1144 |
FOnReplace: TJclCompressionReplaceEvent; |
| 1145 |
FOnTmpVolume: TJclCompressionVolumeEvent; |
| 1146 |
protected |
| 1147 |
function NeedTmpStream(Index: Integer): TStream; |
| 1148 |
procedure InitializeArchiveProperties; override; |
| 1149 |
function InternalOpenTmpStream(const FileName: TFileName): TStream; |
| 1150 |
public |
| 1151 |
class function TmpVolumeAccess: TJclStreamAccess; virtual; |
| 1152 |
|
| 1153 |
procedure Compress; override; |
| 1154 |
|
| 1155 |
property ReplaceVolumes: Boolean read FReplaceVolumes write FReplaceVolumes; |
| 1156 |
property OnReplace: TJclCompressionReplaceEvent read FOnReplace write FOnReplace; |
| 1157 |
property OnTmpVolume: TJclCompressionVolumeEvent read FOnTmpVolume write FOnTmpVolume; |
| 1158 |
end; |
| 1159 |
|
| 1160 |
TJclUpdateArchiveClass = class of TJclUpdateArchive; |
| 1161 |
|
| 1162 |
TJclUpdateArchiveClassArray = array of TJclUpdateArchiveClass; |
| 1163 |
|
| 1164 |
// registered archive formats |
| 1165 |
type |
| 1166 |
TJclCompressionArchiveFormats = class |
| 1167 |
private |
| 1168 |
FCompressFormats: TList; |
| 1169 |
FDecompressFormats: TList; |
| 1170 |
FUpdateFormats: TList; |
| 1171 |
protected |
| 1172 |
function GetCompressFormatCount: Integer; |
| 1173 |
function GetCompressFormat(Index: Integer): TJclCompressArchiveClass; |
| 1174 |
function GetDecompressFormatCount: Integer; |
| 1175 |
function GetDecompressFormat(Index: Integer): TJclDecompressArchiveClass; |
| 1176 |
function GetUpdateFormatCount: Integer; |
| 1177 |
function GetUpdateFormat(Index: Integer): TJclUpdateArchiveClass; |
| 1178 |
public |
| 1179 |
constructor Create; |
| 1180 |
destructor Destroy; override; |
| 1181 |
|
| 1182 |
procedure RegisterFormat(AClass: TJclCompressionArchiveClass); |
| 1183 |
procedure UnregisterFormat(AClass: TJclCompressionArchiveClass); |
| 1184 |
|
| 1185 |
// archive signatures do not give significant results for ISO/UDF (signature is not located at stream start) |
| 1186 |
// need to find a generic way to match all signature before publishing the code |
| 1187 |
//function SignatureMatches(Format: TJclCompressionArchiveClass; ArchiveStream: TStream; var Buffer: TDynByteArray): Boolean; |
| 1188 |
function FindCompressFormat(const AFileName: TFileName): TJclCompressArchiveClass; |
| 1189 |
//function FindDecompressFormat(const AFileName: TFileName; TestArchiveSignature: Boolean): TJclDecompressArchiveClass; overload; |
| 1190 |
function FindDecompressFormat(const AFileName: TFileName): TJclDecompressArchiveClass; //overload; |
| 1191 |
//function FindUpdateFormat(const AFileName: TFileName; TestArchiveSignature: Boolean): TJclUpdateArchiveClass; overload; |
| 1192 |
function FindUpdateFormat(const AFileName: TFileName): TJclUpdateArchiveClass; //overload; |
| 1193 |
|
| 1194 |
function FindCompressFormats(const AFileName: TFileName): TJclCompressArchiveClassArray; |
| 1195 |
function FindDecompressFormats(const AFileName: TFileName): TJclDecompressArchiveClassArray; |
| 1196 |
function FindUpdateFormats(const AFileName: TFileName): TJclUpdateArchiveClassArray; |
| 1197 |
|
| 1198 |
property CompressFormatCount: Integer read GetCompressFormatCount; |
| 1199 |
property CompressFormats[Index: Integer]: TJclCompressArchiveClass read GetCompressFormat; |
| 1200 |
property DecompressFormatCount: Integer read GetDecompressFormatCount; |
| 1201 |
property DecompressFormats[Index: Integer]: TJclDecompressArchiveClass read GetDecompressFormat; |
| 1202 |
property UpdateFormatCount: Integer read GetUpdateFormatCount; |
| 1203 |
property UpdateFormats[Index: Integer]: TJclUpdateArchiveClass read GetUpdateFormat; |
| 1204 |
end; |
| 1205 |
|
| 1206 |
// retreive a singleton list containing archive formats |
| 1207 |
function GetArchiveFormats: TJclCompressionArchiveFormats; |
| 1208 |
|
| 1209 |
// sevenzip classes for compression |
| 1210 |
type |
| 1211 |
TJclSevenzipCompressArchive = class(TJclCompressArchive, IInterface) |
| 1212 |
private |
| 1213 |
FSfxModule: String; |
| 1214 |
FOutArchive: IOutArchive; |
| 1215 |
protected |
| 1216 |
function GetItemClass: TJclCompressionItemClass; override; |
| 1217 |
function GetOutArchive: IOutArchive; |
| 1218 |
public |
| 1219 |
class function ArchiveCLSID: TGUID; virtual; |
| 1220 |
class function ArchiveSignature: TDynByteArray; override; |
| 1221 |
destructor Destroy; override; |
| 1222 |
procedure Compress; override; |
| 1223 |
property OutArchive: IOutArchive read GetOutArchive; |
| 1224 |
property SfxModule: String read FSfxModule write FSfxModule; |
| 1225 |
end; |
| 1226 |
|
| 1227 |
// file formats |
| 1228 |
|
| 1229 |
TJclZipCompressArchive = class(TJclSevenzipCompressArchive, IJclArchiveCompressionLevel, IJclArchiveCompressionMethod, |
| 1230 |
IJclArchiveEncryptionMethod, IJclArchiveDictionarySize, IJclArchiveNumberOfPasses, IJclArchiveNumberOfThreads, |
| 1231 |
IJclArchiveAlgorithm, IInterface) |
| 1232 |
private |
| 1233 |
FNumberOfThreads: Cardinal; |
| 1234 |
FEncryptionMethod: TJclEncryptionMethod; |
| 1235 |
FDictionarySize: Cardinal; |
| 1236 |
FCompressionLevel: Cardinal; |
| 1237 |
FCompressionMethod: TJclCompressionMethod; |
| 1238 |
FNumberOfPasses: Cardinal; |
| 1239 |
FAlgorithm: Cardinal; |
| 1240 |
protected |
| 1241 |
procedure InitializeArchiveProperties; override; |
| 1242 |
public |
| 1243 |
class function MultipleItemContainer: Boolean; override; |
| 1244 |
class function ArchiveExtensions: string; override; |
| 1245 |
class function ArchiveName: string; override; |
| 1246 |
class function ArchiveCLSID: TGUID; override; |
| 1247 |
{ IJclArchiveNumberOfThreads } |
| 1248 |
function GetNumberOfThreads: Cardinal; |
| 1249 |
procedure SetNumberOfThreads(Value: Cardinal); |
| 1250 |
{ IJclArchiveEncryptionMethod } |
| 1251 |
function GetEncryptionMethod: TJclEncryptionMethod; |
| 1252 |
function GetSupportedEncryptionMethods: TJclEncryptionMethods; |
| 1253 |
procedure SetEncryptionMethod(Value: TJclEncryptionMethod); |
| 1254 |
{ IJclArchiveDictionarySize } |
| 1255 |
function GetDictionarySize: Cardinal; |
| 1256 |
procedure SetDictionarySize(Value: Cardinal); |
| 1257 |
{ IJclArchiveCompressionLevel } |
| 1258 |
function GetCompressionLevel: Cardinal; |
| 1259 |
function GetCompressionLevelMax: Cardinal; |
| 1260 |
function GetCompressionLevelMin: Cardinal; |
| 1261 |
procedure SetCompressionLevel(Value: Cardinal); |
| 1262 |
{ IJclArchiveCompressionMethod } |
| 1263 |
function GetCompressionMethod: TJclCompressionMethod; |
| 1264 |
function GetSupportedCompressionMethods: TJclCompressionMethods; |
| 1265 |
procedure SetCompressionMethod(Value: TJclCompressionMethod); |
| 1266 |
{ IJclArchiveNumberOfPasses } |
| 1267 |
function GetNumberOfPasses: Cardinal; |
| 1268 |
procedure SetNumberOfPasses(Value: Cardinal); |
| 1269 |
{ IJclArchiveAlgoritm } |
| 1270 |
function GetAlgorithm: Cardinal; |
| 1271 |
function GetSupportedAlgorithms: TDynCardinalArray; |
| 1272 |
procedure SetAlgorithm(Value: Cardinal); |
| 1273 |
end; |
| 1274 |
|
| 1275 |
TJclBZ2CompressArchive = class(TJclSevenzipCompressArchive, IJclArchiveCompressionLevel, IJclArchiveDictionarySize, |
| 1276 |
IJclArchiveNumberOfPasses, IJclArchiveNumberOfThreads, IInterface) |
| 1277 |
private |
| 1278 |
FNumberOfThreads: Cardinal; |
| 1279 |
FDictionarySize: Cardinal; |
| 1280 |
FCompressionLevel: Cardinal; |
| 1281 |
FNumberOfPasses: Cardinal; |
| 1282 |
protected |
| 1283 |
procedure InitializeArchiveProperties; override; |
| 1284 |
public |
| 1285 |
class function ArchiveExtensions: string; override; |
| 1286 |
class function ArchiveName: string; override; |
| 1287 |
class function ArchiveSubExtensions: string; override; |
| 1288 |
class function ArchiveCLSID: TGUID; override; |
| 1289 |
{ IJclArchiveNumberOfThreads } |
| 1290 |
function GetNumberOfThreads: Cardinal; |
| 1291 |
procedure SetNumberOfThreads(Value: Cardinal); |
| 1292 |
{ IJclArchiveDictionarySize } |
| 1293 |
function GetDictionarySize: Cardinal; |
| 1294 |
procedure SetDictionarySize(Value: Cardinal); |
| 1295 |
{ IJclArchiveCompressionLevel } |
| 1296 |
function GetCompressionLevel: Cardinal; |
| 1297 |
function GetCompressionLevelMax: Cardinal; |
| 1298 |
function GetCompressionLevelMin: Cardinal; |
| 1299 |
procedure SetCompressionLevel(Value: Cardinal); |
| 1300 |
{ IJclArchiveNumberOfPasses } |
| 1301 |
function GetNumberOfPasses: Cardinal; |
| 1302 |
procedure SetNumberOfPasses(Value: Cardinal); |
| 1303 |
end; |
| 1304 |
|
| 1305 |
TJcl7zCompressArchive = class(TJclSevenzipCompressArchive, IJclArchiveCompressionLevel, IJclArchiveDictionarySize, |
| 1306 |
IJclArchiveNumberOfThreads, IJclArchiveRemoveSfxBlock, IJclArchiveCompressHeader, IJclArchiveEncryptHeader, |
| 1307 |
IJclArchiveSaveCreationDateTime, IJclArchiveSaveLastAccessDateTime, IJclArchiveSaveLastWriteDateTime, |
| 1308 |
IJclArchiveSolid, IInterface) |
| 1309 |
private |
| 1310 |
FNumberOfThreads: Cardinal; |
| 1311 |
FEncryptHeader: Boolean; |
| 1312 |
FRemoveSfxBlock: Boolean; |
| 1313 |
FDictionarySize: Cardinal; |
| 1314 |
FCompressionLevel: Cardinal; |
| 1315 |
FCompressHeader: Boolean; |
| 1316 |
FCompressHeaderFull: Boolean; |
| 1317 |
FSaveLastAccessDateTime: Boolean; |
| 1318 |
FSaveCreationDateTime: Boolean; |
| 1319 |
FSaveLastWriteDateTime: Boolean; |
| 1320 |
FSolidBlockSize: Int64; |
| 1321 |
FSolidExtension: Boolean; |
| 1322 |
protected |
| 1323 |
procedure InitializeArchiveProperties; override; |
| 1324 |
public |
| 1325 |
class function MultipleItemContainer: Boolean; override; |
| 1326 |
class function ArchiveExtensions: string; override; |
| 1327 |
class function ArchiveName: string; override; |
| 1328 |
class function ArchiveCLSID: TGUID; override; |
| 1329 |
{ IJclArchiveNumberOfThreads } |
| 1330 |
function GetNumberOfThreads: Cardinal; |
| 1331 |
procedure SetNumberOfThreads(Value: Cardinal); |
| 1332 |
{ IJclArchiveEncryptHeader } |
| 1333 |
function GetEncryptHeader: Boolean; |
| 1334 |
procedure SetEncryptHeader(Value: Boolean); |
| 1335 |
{ IJclArchiveRemoveSfxBlock } |
| 1336 |
function GetRemoveSfxBlock: Boolean; |
| 1337 |
procedure SetRemoveSfxBlock(Value: Boolean); |
| 1338 |
{ IJclArchiveDictionarySize } |
| 1339 |
function GetDictionarySize: Cardinal; |
| 1340 |
procedure SetDictionarySize(Value: Cardinal); |
| 1341 |
{ IJclArchiveCompressionLevel } |
| 1342 |
function GetCompressionLevel: Cardinal; |
| 1343 |
function GetCompressionLevelMax: Cardinal; |
| 1344 |
function GetCompressionLevelMin: Cardinal; |
| 1345 |
procedure SetCompressionLevel(Value: Cardinal); |
| 1346 |
{ IJclArchiveCompressHeader } |
| 1347 |
function GetCompressHeader: Boolean; |
| 1348 |
function GetCompressHeaderFull: Boolean; |
| 1349 |
procedure SetCompressHeader(Value: Boolean); |
| 1350 |
procedure SetCompressHeaderFull(Value: Boolean); |
| 1351 |
{ IJclArchiveSaveLastAccessDateTime } |
| 1352 |
function GetSaveLastAccessDateTime: Boolean; |
| 1353 |
procedure SetSaveLastAccessDateTime(Value: Boolean); |
| 1354 |
{ IJclArchiveSaveCreationDateTime } |
| 1355 |
function GetSaveCreationDateTime: Boolean; |
| 1356 |
procedure SetSaveCreationDateTime(Value: Boolean); |
| 1357 |
{ IJclArchiveSaveLastWriteDateTime } |
| 1358 |
function GetSaveLastWriteDateTime: Boolean; |
| 1359 |
procedure SetSaveLastWriteDateTime(Value: Boolean); |
| 1360 |
{ IJclArchiveSolid } |
| 1361 |
function GetSolidBlockSize: Int64; |
| 1362 |
function GetSolidExtension: Boolean; |
| 1363 |
procedure SetSolidBlockSize(const Value: Int64); |
| 1364 |
procedure SetSolidExtension(Value: Boolean); |
| 1365 |
end; |
| 1366 |
|
| 1367 |
TJclTarCompressArchive = class(TJclSevenzipCompressArchive, IInterface) |
| 1368 |
public |
| 1369 |
class function MultipleItemContainer: Boolean; override; |
| 1370 |
class function ArchiveExtensions: string; override; |
| 1371 |
class function ArchiveName: string; override; |
| 1372 |
class function ArchiveCLSID: TGUID; override; |
| 1373 |
end; |
| 1374 |
|
| 1375 |
TJclGZipCompressArchive = class(TJclSevenzipCompressArchive, IJclArchiveCompressionLevel, IJclArchiveNumberOfPasses, |
| 1376 |
IJclArchiveAlgorithm, IInterface) |
| 1377 |
private |
| 1378 |
FCompressionLevel: Cardinal; |
| 1379 |
FNumberOfPasses: Cardinal; |
| 1380 |
FAlgorithm: Cardinal; |
| 1381 |
protected |
| 1382 |
procedure InitializeArchiveProperties; override; |
| 1383 |
public |
| 1384 |
class function ArchiveExtensions: string; override; |
| 1385 |
class function ArchiveName: string; override; |
| 1386 |
class function ArchiveSubExtensions: string; override; |
| 1387 |
class function ArchiveCLSID: TGUID; override; |
| 1388 |
{ IJclArchiveCompressionLevel } |
| 1389 |
function GetCompressionLevel: Cardinal; |
| 1390 |
function GetCompressionLevelMax: Cardinal; |
| 1391 |
function GetCompressionLevelMin: Cardinal; |
| 1392 |
procedure SetCompressionLevel(Value: Cardinal); |
| 1393 |
{ IJclArchiveNumberOfPasses } |
| 1394 |
function GetNumberOfPasses: Cardinal; |
| 1395 |
procedure SetNumberOfPasses(Value: Cardinal); |
| 1396 |
{ IJclArchiveAlgorithm } |
| 1397 |
function GetAlgorithm: Cardinal; |
| 1398 |
function GetSupportedAlgorithms: TDynCardinalArray; |
| 1399 |
procedure SetAlgorithm(Value: Cardinal); |
| 1400 |
end; |
| 1401 |
|
| 1402 |
TJclXzCompressArchive = class(TJclSevenzipCompressArchive, IJclArchiveCompressionMethod, IInterface) |
| 1403 |
private |
| 1404 |
FCompressionMethod: TJclCompressionMethod; |
| 1405 |
protected |
| 1406 |
procedure InitializeArchiveProperties; override; |
| 1407 |
public |
| 1408 |
class function ArchiveExtensions: string; override; |
| 1409 |
class function ArchiveName: string; override; |
| 1410 |
class function ArchiveSubExtensions: string; override; |
| 1411 |
class function ArchiveCLSID: TGUID; override; |
| 1412 |
{ IJclArchiveCompressionMethod } |
| 1413 |
function GetCompressionMethod: TJclCompressionMethod; |
| 1414 |
function GetSupportedCompressionMethods: TJclCompressionMethods; |
| 1415 |
procedure SetCompressionMethod(Value: TJclCompressionMethod); |
| 1416 |
end; |
| 1417 |
|
| 1418 |
TJclSwfcCompressArchive = class(TJclSevenzipCompressArchive, IInterface) |
| 1419 |
public |
| 1420 |
class function ArchiveExtensions: string; override; |
| 1421 |
class function ArchiveName: string; override; |
| 1422 |
class function ArchiveCLSID: TGUID; override; |
| 1423 |
end; |
| 1424 |
|
| 1425 |
TJclWimCompressArchive = class(TJclSevenzipCompressArchive, IInterface) |
| 1426 |
public |
| 1427 |
class function ArchiveExtensions: string; override; |
| 1428 |
class function ArchiveName: string; override; |
| 1429 |
class function ArchiveCLSID: TGUID; override; |
| 1430 |
end; |
| 1431 |
|
| 1432 |
// sevenzip classes for decompression |
| 1433 |
type |
| 1434 |
TJclSevenzipDecompressItem = class(TJclDecompressItem) |
| 1435 |
protected |
| 1436 |
function GetNestedArchiveStream: TStream; override; |
| 1437 |
end; |
| 1438 |
|
| 1439 |
TJclSevenzipDecompressArchive = class(TJclDecompressArchive, IInterface) |
| 1440 |
private |
| 1441 |
FInArchive: IInArchive; |
| 1442 |
FInArchiveGetStream: IInArchiveGetStream; |
| 1443 |
FOpened: Boolean; |
| 1444 |
protected |
| 1445 |
procedure OpenArchive; |
| 1446 |
function GetInArchive: IInArchive; |
| 1447 |
function GetInArchiveGetStream: IInArchiveGetStream; |
| 1448 |
function GetItemClass: TJclCompressionItemClass; override; |
| 1449 |
function GetSupportsNestedArchive: Boolean; override; |
| 1450 |
public |
| 1451 |
class function ArchiveCLSID: TGUID; virtual; |
| 1452 |
class function ArchiveSignature: TDynByteArray; override; |
| 1453 |
destructor Destroy; override; |
| 1454 |
procedure ListFiles; override; |
| 1455 |
procedure ExtractSelected(const ADestinationDir: string = ''; |
| 1456 |
AAutoCreateSubDir: Boolean = True); override; |
| 1457 |
procedure ExtractAll(const ADestinationDir: string = ''; |
| 1458 |
AAutoCreateSubDir: Boolean = True); override; |
| 1459 |
property InArchive: IInArchive read GetInArchive; |
| 1460 |
property InArchiveGetStream: IInArchiveGetStream read GetInArchiveGetStream; |
| 1461 |
end; |
| 1462 |
|
| 1463 |
// file formats |
| 1464 |
|
| 1465 |
TJclZipDecompressArchive = class(TJclSevenzipDecompressArchive, IJclArchiveNumberOfThreads, IInterface) |
| 1466 |
private |
| 1467 |
FNumberOfThreads: Cardinal; |
| 1468 |
protected |
| 1469 |
procedure InitializeArchiveProperties; override; |
| 1470 |
public |
| 1471 |
class function MultipleItemContainer: Boolean; override; |
| 1472 |
class function ArchiveExtensions: string; override; |
| 1473 |
class function ArchiveName: string; override; |
| 1474 |
class function ArchiveCLSID: TGUID; override; |
| 1475 |
{ IJclArchiveNumberOfThreads } |
| 1476 |
function GetNumberOfThreads: Cardinal; |
| 1477 |
procedure SetNumberOfThreads(Value: Cardinal); |
| 1478 |
end; |
| 1479 |
|
| 1480 |
TJclBZ2DecompressArchive = class(TJclSevenzipDecompressArchive, IJclArchiveNumberOfThreads, IInterface) |
| 1481 |
private |
| 1482 |
FNumberOfThreads: Cardinal; |
| 1483 |
protected |
| 1484 |
procedure InitializeArchiveProperties; override; |
| 1485 |
public |
| 1486 |
class function ArchiveExtensions: string; override; |
| 1487 |
class function ArchiveName: string; override; |
| 1488 |
class function ArchiveSubExtensions: string; override; |
| 1489 |
class function ArchiveCLSID: TGUID; override; |
| 1490 |
{ IJclArchiveNumberOfThreads } |
| 1491 |
function GetNumberOfThreads: Cardinal; |
| 1492 |
procedure SetNumberOfThreads(Value: Cardinal); |
| 1493 |
end; |
| 1494 |
|
| 1495 |
TJclRarDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1496 |
public |
| 1497 |
class function MultipleItemContainer: Boolean; override; |
| 1498 |
class function ArchiveExtensions: string; override; |
| 1499 |
class function ArchiveName: string; override; |
| 1500 |
class function ArchiveCLSID: TGUID; override; |
| 1501 |
end; |
| 1502 |
|
| 1503 |
TJclArjDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1504 |
public |
| 1505 |
class function MultipleItemContainer: Boolean; override; |
| 1506 |
class function ArchiveExtensions: string; override; |
| 1507 |
class function ArchiveName: string; override; |
| 1508 |
class function ArchiveCLSID: TGUID; override; |
| 1509 |
end; |
| 1510 |
|
| 1511 |
TJclZDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1512 |
public |
| 1513 |
class function MultipleItemContainer: Boolean; override; |
| 1514 |
class function ArchiveExtensions: string; override; |
| 1515 |
class function ArchiveName: string; override; |
| 1516 |
class function ArchiveSubExtensions: string; override; |
| 1517 |
class function ArchiveCLSID: TGUID; override; |
| 1518 |
end; |
| 1519 |
|
| 1520 |
TJclLzhDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1521 |
public |
| 1522 |
class function MultipleItemContainer: Boolean; override; |
| 1523 |
class function ArchiveExtensions: string; override; |
| 1524 |
class function ArchiveName: string; override; |
| 1525 |
class function ArchiveCLSID: TGUID; override; |
| 1526 |
end; |
| 1527 |
|
| 1528 |
TJcl7zDecompressArchive = class(TJclSevenzipDecompressArchive, IJclArchiveNumberOfThreads, IInterface) |
| 1529 |
private |
| 1530 |
FNumberOfThreads: Cardinal; |
| 1531 |
protected |
| 1532 |
procedure InitializeArchiveProperties; override; |
| 1533 |
public |
| 1534 |
class function MultipleItemContainer: Boolean; override; |
| 1535 |
class function ArchiveExtensions: string; override; |
| 1536 |
class function ArchiveName: string; override; |
| 1537 |
class function ArchiveCLSID: TGUID; override; |
| 1538 |
{ IJclArchiveNumberOfThreads } |
| 1539 |
function GetNumberOfThreads: Cardinal; |
| 1540 |
procedure SetNumberOfThreads(Value: Cardinal); |
| 1541 |
end; |
| 1542 |
|
| 1543 |
TJclCabDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1544 |
public |
| 1545 |
class function MultipleItemContainer: Boolean; override; |
| 1546 |
class function ArchiveExtensions: string; override; |
| 1547 |
class function ArchiveName: string; override; |
| 1548 |
class function ArchiveCLSID: TGUID; override; |
| 1549 |
end; |
| 1550 |
|
| 1551 |
TJclNsisDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1552 |
public |
| 1553 |
class function MultipleItemContainer: Boolean; override; |
| 1554 |
class function ArchiveExtensions: string; override; |
| 1555 |
class function ArchiveName: string; override; |
| 1556 |
class function ArchiveCLSID: TGUID; override; |
| 1557 |
end; |
| 1558 |
|
| 1559 |
TJclLzmaDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1560 |
public |
| 1561 |
class function MultipleItemContainer: Boolean; override; |
| 1562 |
class function ArchiveExtensions: string; override; |
| 1563 |
class function ArchiveName: string; override; |
| 1564 |
class function ArchiveCLSID: TGUID; override; |
| 1565 |
end; |
| 1566 |
|
| 1567 |
TJclLzma86DecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1568 |
public |
| 1569 |
class function MultipleItemContainer: Boolean; override; |
| 1570 |
class function ArchiveExtensions: string; override; |
| 1571 |
class function ArchiveName: string; override; |
| 1572 |
class function ArchiveCLSID: TGUID; override; |
| 1573 |
end; |
| 1574 |
|
| 1575 |
TJclPeDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1576 |
public |
| 1577 |
class function MultipleItemContainer: Boolean; override; |
| 1578 |
class function ArchiveExtensions: string; override; |
| 1579 |
class function ArchiveName: string; override; |
| 1580 |
class function ArchiveCLSID: TGUID; override; |
| 1581 |
end; |
| 1582 |
|
| 1583 |
TJclElfDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1584 |
public |
| 1585 |
class function MultipleItemContainer: Boolean; override; |
| 1586 |
class function ArchiveExtensions: string; override; |
| 1587 |
class function ArchiveName: string; override; |
| 1588 |
class function ArchiveCLSID: TGUID; override; |
| 1589 |
end; |
| 1590 |
|
| 1591 |
TJclMachoDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1592 |
public |
| 1593 |
class function MultipleItemContainer: Boolean; override; |
| 1594 |
class function ArchiveExtensions: string; override; |
| 1595 |
class function ArchiveName: string; override; |
| 1596 |
class function ArchiveCLSID: TGUID; override; |
| 1597 |
end; |
| 1598 |
|
| 1599 |
TJclUdfDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1600 |
public |
| 1601 |
class function MultipleItemContainer: Boolean; override; |
| 1602 |
class function ArchiveExtensions: string; override; |
| 1603 |
class function ArchiveName: string; override; |
| 1604 |
class function ArchiveCLSID: TGUID; override; |
| 1605 |
end; |
| 1606 |
|
| 1607 |
TJclXarDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1608 |
public |
| 1609 |
class function MultipleItemContainer: Boolean; override; |
| 1610 |
class function ArchiveExtensions: string; override; |
| 1611 |
class function ArchiveName: string; override; |
| 1612 |
class function ArchiveCLSID: TGUID; override; |
| 1613 |
end; |
| 1614 |
|
| 1615 |
TJclMubDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1616 |
public |
| 1617 |
class function MultipleItemContainer: Boolean; override; |
| 1618 |
class function ArchiveExtensions: string; override; |
| 1619 |
class function ArchiveName: string; override; |
| 1620 |
class function ArchiveCLSID: TGUID; override; |
| 1621 |
end; |
| 1622 |
|
| 1623 |
TJclHfsDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1624 |
public |
| 1625 |
class function MultipleItemContainer: Boolean; override; |
| 1626 |
class function ArchiveExtensions: string; override; |
| 1627 |
class function ArchiveName: string; override; |
| 1628 |
class function ArchiveCLSID: TGUID; override; |
| 1629 |
end; |
| 1630 |
|
| 1631 |
TJclDmgDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1632 |
public |
| 1633 |
class function MultipleItemContainer: Boolean; override; |
| 1634 |
class function ArchiveExtensions: string; override; |
| 1635 |
class function ArchiveName: string; override; |
| 1636 |
class function ArchiveCLSID: TGUID; override; |
| 1637 |
end; |
| 1638 |
|
| 1639 |
TJclCompoundDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1640 |
public |
| 1641 |
class function MultipleItemContainer: Boolean; override; |
| 1642 |
class function ArchiveExtensions: string; override; |
| 1643 |
class function ArchiveName: string; override; |
| 1644 |
class function ArchiveCLSID: TGUID; override; |
| 1645 |
end; |
| 1646 |
|
| 1647 |
TJclWimDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1648 |
public |
| 1649 |
class function MultipleItemContainer: Boolean; override; |
| 1650 |
class function ArchiveExtensions: string; override; |
| 1651 |
class function ArchiveName: string; override; |
| 1652 |
class function ArchiveCLSID: TGUID; override; |
| 1653 |
end; |
| 1654 |
|
| 1655 |
TJclIsoDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1656 |
public |
| 1657 |
class function MultipleItemContainer: Boolean; override; |
| 1658 |
class function ArchiveExtensions: string; override; |
| 1659 |
class function ArchiveName: string; override; |
| 1660 |
class function ArchiveCLSID: TGUID; override; |
| 1661 |
end; |
| 1662 |
|
| 1663 |
// not implemented in 9.04 |
| 1664 |
{TJclBkfDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1665 |
protected |
| 1666 |
function GetCLSID: TGUID; override; |
| 1667 |
public |
| 1668 |
class function MultipleItemContainer: Boolean; override; |
| 1669 |
class function ArchiveExtensions: string; override; |
| 1670 |
class function ArchiveName: string; override; |
| 1671 |
end;} |
| 1672 |
|
| 1673 |
TJclChmDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1674 |
public |
| 1675 |
class function MultipleItemContainer: Boolean; override; |
| 1676 |
class function ArchiveExtensions: string; override; |
| 1677 |
class function ArchiveName: string; override; |
| 1678 |
class function ArchiveCLSID: TGUID; override; |
| 1679 |
end; |
| 1680 |
|
| 1681 |
TJclSplitDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1682 |
public |
| 1683 |
class function ArchiveExtensions: string; override; |
| 1684 |
class function ArchiveName: string; override; |
| 1685 |
class function ArchiveCLSID: TGUID; override; |
| 1686 |
end; |
| 1687 |
|
| 1688 |
TJclRpmDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1689 |
public |
| 1690 |
class function MultipleItemContainer: Boolean; override; |
| 1691 |
class function ArchiveExtensions: string; override; |
| 1692 |
class function ArchiveName: string; override; |
| 1693 |
class function ArchiveCLSID: TGUID; override; |
| 1694 |
end; |
| 1695 |
|
| 1696 |
TJclDebDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1697 |
public |
| 1698 |
class function MultipleItemContainer: Boolean; override; |
| 1699 |
class function ArchiveExtensions: string; override; |
| 1700 |
class function ArchiveName: string; override; |
| 1701 |
class function ArchiveCLSID: TGUID; override; |
| 1702 |
end; |
| 1703 |
|
| 1704 |
TJclCpioDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1705 |
public |
| 1706 |
class function MultipleItemContainer: Boolean; override; |
| 1707 |
class function ArchiveExtensions: string; override; |
| 1708 |
class function ArchiveName: string; override; |
| 1709 |
class function ArchiveCLSID: TGUID; override; |
| 1710 |
end; |
| 1711 |
|
| 1712 |
TJclTarDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1713 |
public |
| 1714 |
class function MultipleItemContainer: Boolean; override; |
| 1715 |
class function ArchiveExtensions: string; override; |
| 1716 |
class function ArchiveName: string; override; |
| 1717 |
class function ArchiveCLSID: TGUID; override; |
| 1718 |
end; |
| 1719 |
|
| 1720 |
TJclGZipDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1721 |
public |
| 1722 |
class function ArchiveExtensions: string; override; |
| 1723 |
class function ArchiveName: string; override; |
| 1724 |
class function ArchiveSubExtensions: string; override; |
| 1725 |
class function ArchiveCLSID: TGUID; override; |
| 1726 |
end; |
| 1727 |
|
| 1728 |
TJclXzDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1729 |
public |
| 1730 |
class function ArchiveExtensions: string; override; |
| 1731 |
class function ArchiveName: string; override; |
| 1732 |
class function ArchiveSubExtensions: string; override; |
| 1733 |
class function ArchiveCLSID: TGUID; override; |
| 1734 |
end; |
| 1735 |
|
| 1736 |
TJclNtfsDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1737 |
public |
| 1738 |
class function MultipleItemContainer: Boolean; override; |
| 1739 |
class function ArchiveExtensions: string; override; |
| 1740 |
class function ArchiveName: string; override; |
| 1741 |
class function ArchiveCLSID: TGUID; override; |
| 1742 |
end; |
| 1743 |
|
| 1744 |
TJclFatDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1745 |
public |
| 1746 |
class function MultipleItemContainer: Boolean; override; |
| 1747 |
class function ArchiveExtensions: string; override; |
| 1748 |
class function ArchiveName: string; override; |
| 1749 |
class function ArchiveCLSID: TGUID; override; |
| 1750 |
end; |
| 1751 |
|
| 1752 |
TJclMbrDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1753 |
public |
| 1754 |
class function MultipleItemContainer: Boolean; override; |
| 1755 |
class function ArchiveExtensions: string; override; |
| 1756 |
class function ArchiveName: string; override; |
| 1757 |
class function ArchiveCLSID: TGUID; override; |
| 1758 |
end; |
| 1759 |
|
| 1760 |
TJclVhdDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1761 |
public |
| 1762 |
class function ArchiveExtensions: string; override; |
| 1763 |
class function ArchiveName: string; override; |
| 1764 |
class function ArchiveSubExtensions: string; override; |
| 1765 |
class function ArchiveCLSID: TGUID; override; |
| 1766 |
end; |
| 1767 |
|
| 1768 |
TJclMslzDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1769 |
public |
| 1770 |
class function ArchiveExtensions: string; override; |
| 1771 |
class function ArchiveName: string; override; |
| 1772 |
class function ArchiveCLSID: TGUID; override; |
| 1773 |
end; |
| 1774 |
|
| 1775 |
TJclFlvDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1776 |
public |
| 1777 |
class function ArchiveExtensions: string; override; |
| 1778 |
class function ArchiveName: string; override; |
| 1779 |
class function ArchiveCLSID: TGUID; override; |
| 1780 |
end; |
| 1781 |
|
| 1782 |
TJclSwfDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1783 |
public |
| 1784 |
class function ArchiveExtensions: string; override; |
| 1785 |
class function ArchiveName: string; override; |
| 1786 |
class function ArchiveCLSID: TGUID; override; |
| 1787 |
end; |
| 1788 |
|
| 1789 |
TJclSwfcDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1790 |
public |
| 1791 |
class function ArchiveExtensions: string; override; |
| 1792 |
class function ArchiveName: string; override; |
| 1793 |
class function ArchiveCLSID: TGUID; override; |
| 1794 |
end; |
| 1795 |
|
| 1796 |
TJclAPMDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1797 |
public |
| 1798 |
class function ArchiveExtensions: string; override; |
| 1799 |
class function ArchiveName: string; override; |
| 1800 |
class function ArchiveCLSID: TGUID; override; |
| 1801 |
end; |
| 1802 |
|
| 1803 |
TJclPpmdDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1804 |
public |
| 1805 |
class function ArchiveExtensions: string; override; |
| 1806 |
class function ArchiveName: string; override; |
| 1807 |
class function ArchiveCLSID: TGUID; override; |
| 1808 |
end; |
| 1809 |
|
| 1810 |
TJclTEDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1811 |
public |
| 1812 |
class function ArchiveExtensions: string; override; |
| 1813 |
class function ArchiveName: string; override; |
| 1814 |
class function ArchiveCLSID: TGUID; override; |
| 1815 |
end; |
| 1816 |
|
| 1817 |
TJclUEFIcDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1818 |
public |
| 1819 |
class function ArchiveExtensions: string; override; |
| 1820 |
class function ArchiveName: string; override; |
| 1821 |
class function ArchiveCLSID: TGUID; override; |
| 1822 |
end; |
| 1823 |
|
| 1824 |
TJclUEFIsDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1825 |
public |
| 1826 |
class function ArchiveExtensions: string; override; |
| 1827 |
class function ArchiveName: string; override; |
| 1828 |
class function ArchiveCLSID: TGUID; override; |
| 1829 |
end; |
| 1830 |
|
| 1831 |
TJclSquashFSDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1832 |
public |
| 1833 |
class function ArchiveExtensions: string; override; |
| 1834 |
class function ArchiveName: string; override; |
| 1835 |
class function ArchiveCLSID: TGUID; override; |
| 1836 |
end; |
| 1837 |
|
| 1838 |
TJclCramFSDecompressArchive = class(TJclSevenzipDecompressArchive, IInterface) |
| 1839 |
public |
| 1840 |
class function ArchiveExtensions: string; override; |
| 1841 |
class function ArchiveName: string; override; |
| 1842 |
class function ArchiveCLSID: TGUID; override; |
| 1843 |
end; |
| 1844 |
|
| 1845 |
//sevenzip classes for updates (read and write) |
| 1846 |
type |
| 1847 |
TJclSevenzipUpdateArchive = class(TJclOutOfPlaceUpdateArchive, IInterface) |
| 1848 |
private |
| 1849 |
FInArchive: IInArchive; |
| 1850 |
FOutArchive: IOutArchive; |
| 1851 |
FOpened: Boolean; |
| 1852 |
protected |
| 1853 |
procedure OpenArchive; |
| 1854 |
function GetInArchive: IInArchive; |
| 1855 |
function GetItemClass: TJclCompressionItemClass; override; |
| 1856 |
function GetOutArchive: IOutArchive; |
| 1857 |
public |
| 1858 |
class function ArchiveCLSID: TGUID; virtual; |
| 1859 |
class function ArchiveSignature: TDynByteArray; override; |
| 1860 |
destructor Destroy; override; |
| 1861 |
procedure ListFiles; override; |
| 1862 |
procedure ExtractSelected(const ADestinationDir: string = ''; |
| 1863 |
AAutoCreateSubDir: Boolean = True); override; |
| 1864 |
procedure ExtractAll(const ADestinationDir: string = ''; |
| 1865 |
AAutoCreateSubDir: Boolean = True); override; |
| 1866 |
procedure Compress; override; |
| 1867 |
procedure DeleteItem(Index: Integer); override; |
| 1868 |
procedure RemoveItem(const PackedName: WideString); override; |
| 1869 |
property InArchive: IInArchive read GetInArchive; |
| 1870 |
property OutArchive: IOutArchive read GetOutArchive; |
| 1871 |
end; |
| 1872 |
|
| 1873 |
TJclZipUpdateArchive = class(TJclSevenzipUpdateArchive, IJclArchiveCompressionLevel, IJclArchiveCompressionMethod, |
| 1874 |
IJclArchiveEncryptionMethod, IJclArchiveDictionarySize, IJclArchiveNumberOfPasses, IJclArchiveNumberOfThreads, |
| 1875 |
IJclArchiveAlgorithm, IInterface) |
| 1876 |
private |
| 1877 |
FNumberOfThreads: Cardinal; |
| 1878 |
FEncryptionMethod: TJclEncryptionMethod; |
| 1879 |
FDictionarySize: Cardinal; |
| 1880 |
FCompressionLevel: Cardinal; |
| 1881 |
FCompressionMethod: TJclCompressionMethod; |
| 1882 |
FNumberOfPasses: Cardinal; |
| 1883 |
FAlgorithm: Cardinal; |
| 1884 |
protected |
| 1885 |
procedure InitializeArchiveProperties; override; |
| 1886 |
public |
| 1887 |
class function MultipleItemContainer: Boolean; override; |
| 1888 |
class function ArchiveExtensions: string; override; |
| 1889 |
class function ArchiveName: string; override; |
| 1890 |
class function ArchiveCLSID: TGUID; override; |
| 1891 |
{ IJclArchiveNumberOfThreads } |
| 1892 |
function GetNumberOfThreads: Cardinal; |
| 1893 |
procedure SetNumberOfThreads(Value: Cardinal); |
| 1894 |
{ IJclArchiveEncryptionMethod } |
| 1895 |
function GetEncryptionMethod: TJclEncryptionMethod; |
| 1896 |
function GetSupportedEncryptionMethods: TJclEncryptionMethods; |
| 1897 |
procedure SetEncryptionMethod(Value: TJclEncryptionMethod); |
| 1898 |
{ IJclArchiveDictionarySize } |
| 1899 |
function GetDictionarySize: Cardinal; |
| 1900 |
procedure SetDictionarySize(Value: Cardinal); |
| 1901 |
{ IJclArchiveCompressionLevel } |
| 1902 |
function GetCompressionLevel: Cardinal; |
| 1903 |
function GetCompressionLevelMax: Cardinal; |
| 1904 |
function GetCompressionLevelMin: Cardinal; |
| 1905 |
procedure SetCompressionLevel(Value: Cardinal); |
| 1906 |
{ IJclArchiveCompressionMethod } |
| 1907 |
function GetCompressionMethod: TJclCompressionMethod; |
| 1908 |
function GetSupportedCompressionMethods: TJclCompressionMethods; |
| 1909 |
procedure SetCompressionMethod(Value: TJclCompressionMethod); |
| 1910 |
{ IJclArchiveNumberOfPasses } |
| 1911 |
function GetNumberOfPasses: Cardinal; |
| 1912 |
procedure SetNumberOfPasses(Value: Cardinal); |
| 1913 |
{ IJclArchiveAlgoritm } |
| 1914 |
function GetAlgorithm: Cardinal; |
| 1915 |
function GetSupportedAlgorithms: TDynCardinalArray; |
| 1916 |
procedure SetAlgorithm(Value: Cardinal); |
| 1917 |
end; |
| 1918 |
|
| 1919 |
TJclBZ2UpdateArchive = class(TJclSevenzipUpdateArchive, IJclArchiveCompressionLevel, IJclArchiveDictionarySize, |
| 1920 |
IJclArchiveNumberOfPasses, IJclArchiveNumberOfThreads, IInterface) |
| 1921 |
private |
| 1922 |
FNumberOfThreads: Cardinal; |
| 1923 |
FDictionarySize: Cardinal; |
| 1924 |
FCompressionLevel: Cardinal; |
| 1925 |
FNumberOfPasses: Cardinal; |
| 1926 |
protected |
| 1927 |
procedure InitializeArchiveProperties; override; |
| 1928 |
public |
| 1929 |
class function ArchiveExtensions: string; override; |
| 1930 |
class function ArchiveName: string; override; |
| 1931 |
class function ArchiveSubExtensions: string; override; |
| 1932 |
class function ArchiveCLSID: TGUID; override; |
| 1933 |
{ IJclArchiveNumberOfThreads } |
| 1934 |
function GetNumberOfThreads: Cardinal; |
| 1935 |
procedure SetNumberOfThreads(Value: Cardinal); |
| 1936 |
{ IJclArchiveDictionarySize } |
| 1937 |
function GetDictionarySize: Cardinal; |
| 1938 |
procedure SetDictionarySize(Value: Cardinal); |
| 1939 |
{ IJclArchiveCompressionLevel } |
| 1940 |
function GetCompressionLevel: Cardinal; |
| 1941 |
function GetCompressionLevelMax: Cardinal; |
| 1942 |
function GetCompressionLevelMin: Cardinal; |
| 1943 |
procedure SetCompressionLevel(Value: Cardinal); |
| 1944 |
{ IJclArchiveNumberOfPasses } |
| 1945 |
function GetNumberOfPasses: Cardinal; |
| 1946 |
procedure SetNumberOfPasses(Value: Cardinal); |
| 1947 |
end; |
| 1948 |
|
| 1949 |
TJcl7zUpdateArchive = class(TJclSevenzipUpdateArchive, IJclArchiveCompressionLevel, IJclArchiveDictionarySize, |
| 1950 |
IJclArchiveNumberOfThreads, IJclArchiveRemoveSfxBlock, IJclArchiveCompressHeader, IJclArchiveEncryptHeader, |
| 1951 |
IJclArchiveSaveCreationDateTime, IJclArchiveSaveLastAccessDateTime, IJclArchiveSaveLastWriteDateTime, IInterface) |
| 1952 |
private |
| 1953 |
FNumberOfThreads: Cardinal; |
| 1954 |
FEncryptHeader: Boolean; |
| 1955 |
FRemoveSfxBlock: Boolean; |
| 1956 |
FDictionarySize: Cardinal; |
| 1957 |
FCompressionLevel: Cardinal; |
| 1958 |
FCompressHeader: Boolean; |
| 1959 |
FCompressHeaderFull: Boolean; |
| 1960 |
FSaveLastAccessDateTime: Boolean; |
| 1961 |
FSaveCreationDateTime: Boolean; |
| 1962 |
FSaveLastWriteDateTime: Boolean; |
| 1963 |
protected |
| 1964 |
procedure InitializeArchiveProperties; override; |
| 1965 |
public |
| 1966 |
class function MultipleItemContainer: Boolean; override; |
| 1967 |
class function ArchiveExtensions: string; override; |
| 1968 |
class function ArchiveName: string; override; |
| 1969 |
class function ArchiveCLSID: TGUID; override; |
| 1970 |
{ IJclArchiveNumberOfThreads } |
| 1971 |
function GetNumberOfThreads: Cardinal; |
| 1972 |
procedure SetNumberOfThreads(Value: Cardinal); |
| 1973 |
{ IJclArchiveEncryptHeader } |
| 1974 |
function GetEncryptHeader: Boolean; |
| 1975 |
procedure SetEncryptHeader(Value: Boolean); |
| 1976 |
{ IJclArchiveRemoveSfxBlock } |
| 1977 |
function GetRemoveSfxBlock: Boolean; |
| 1978 |
procedure SetRemoveSfxBlock(Value: Boolean); |
| 1979 |
{ IJclArchiveDictionarySize } |
| 1980 |
function GetDictionarySize: Cardinal; |
| 1981 |
procedure SetDictionarySize(Value: Cardinal); |
| 1982 |
{ IJclArchiveCompressionLevel } |
| 1983 |
function GetCompressionLevel: Cardinal; |
| 1984 |
function GetCompressionLevelMax: Cardinal; |
| 1985 |
function GetCompressionLevelMin: Cardinal; |
| 1986 |
procedure SetCompressionLevel(Value: Cardinal); |
| 1987 |
{ IJclArchiveCompressHeader } |
| 1988 |
function GetCompressHeader: Boolean; |
| 1989 |
function GetCompressHeaderFull: Boolean; |
| 1990 |
procedure SetCompressHeader(Value: Boolean); |
| 1991 |
procedure SetCompressHeaderFull(Value: Boolean); |
| 1992 |
{ IJclArchiveSaveLastAccessDateTime } |
| 1993 |
function GetSaveLastAccessDateTime: Boolean; |
| 1994 |
procedure SetSaveLastAccessDateTime(Value: Boolean); |
| 1995 |
{ IJclArchiveSaveCreationDateTime } |
| 1996 |
function GetSaveCreationDateTime: Boolean; |
| 1997 |
procedure SetSaveCreationDateTime(Value: Boolean); |
| 1998 |
{ IJclArchiveSaveLastWriteDateTime } |
| 1999 |
function GetSaveLastWriteDateTime: Boolean; |
| 2000 |
procedure SetSaveLastWriteDateTime(Value: Boolean); |
| 2001 |
end; |
| 2002 |
|
| 2003 |
TJclTarUpdateArchive = class(TJclSevenzipUpdateArchive, IInterface) |
| 2004 |
public |
| 2005 |
class function MultipleItemContainer: Boolean; override; |
| 2006 |
class function ArchiveExtensions: string; override; |
| 2007 |
class function ArchiveName: string; override; |
| 2008 |
class function ArchiveCLSID: TGUID; override; |
| 2009 |
end; |
| 2010 |
|
| 2011 |
TJclGZipUpdateArchive = class(TJclSevenzipUpdateArchive, IJclArchiveCompressionLevel, IJclArchiveNumberOfPasses, |
| 2012 |
IJclArchiveAlgorithm, IInterface) |
| 2013 |
private |
| 2014 |
FCompressionLevel: Cardinal; |
| 2015 |
FNumberOfPasses: Cardinal; |
| 2016 |
FAlgorithm: Cardinal; |
| 2017 |
protected |
| 2018 |
procedure InitializeArchiveProperties; override; |
| 2019 |
public |
| 2020 |
class function ArchiveExtensions: string; override; |
| 2021 |
class function ArchiveName: string; override; |
| 2022 |
class function ArchiveSubExtensions: string; override; |
| 2023 |
class function ArchiveCLSID: TGUID; override; |
| 2024 |
{ IJclArchiveCompressionLevel } |
| 2025 |
function GetCompressionLevel: Cardinal; |
| 2026 |
function GetCompressionLevelMax: Cardinal; |
| 2027 |
function GetCompressionLevelMin: Cardinal; |
| 2028 |
procedure SetCompressionLevel(Value: Cardinal); |
| 2029 |
{ IJclArchiveNumberOfPasses } |
| 2030 |
function GetNumberOfPasses: Cardinal; |
| 2031 |
procedure SetNumberOfPasses(Value: Cardinal); |
| 2032 |
{ IJclArchiveAlgorithm } |
| 2033 |
function GetAlgorithm: Cardinal; |
| 2034 |
function GetSupportedAlgorithms: TDynCardinalArray; |
| 2035 |
procedure SetAlgorithm(Value: Cardinal); |
| 2036 |
end; |
| 2037 |
|
| 2038 |
TJclXzUpdateArchive = class(TJclSevenzipUpdateArchive, IJclArchiveCompressionMethod, IInterface) |
| 2039 |
private |
| 2040 |
FCompressionMethod: TJclCompressionMethod; |
| 2041 |
protected |
| 2042 |
procedure InitializeArchiveProperties; override; |
| 2043 |
public |
| 2044 |
class function ArchiveExtensions: string; override; |
| 2045 |
class function ArchiveName: string; override; |
| 2046 |
class function ArchiveSubExtensions: string; override; |
| 2047 |
class function ArchiveCLSID: TGUID; override; |
| 2048 |
{ IJclArchiveCompressionMethod } |
| 2049 |
function GetCompressionMethod: TJclCompressionMethod; |
| 2050 |
function GetSupportedCompressionMethods: TJclCompressionMethods; |
| 2051 |
procedure SetCompressionMethod(Value: TJclCompressionMethod); |
| 2052 |
end; |
| 2053 |
|
| 2054 |
TJclSwfcUpdateArchive = class(TJclSevenzipUpdateArchive, IInterface) |
| 2055 |
public |
| 2056 |
class function ArchiveExtensions: string; override; |
| 2057 |
class function ArchiveName: string; override; |
| 2058 |
class function ArchiveCLSID: TGUID; override; |
| 2059 |
end; |
| 2060 |
|
| 2061 |
// internal sevenzip stuff, do not use it directly |
| 2062 |
type |
| 2063 |
TJclSevenzipOutStream = class(TInterfacedObject, ISequentialOutStream, |
| 2064 |
IOutStream, IUnknown) |
| 2065 |
private |
| 2066 |
FArchive: TJclCompressionArchive; |
| 2067 |
FItemIndex: Integer; |
| 2068 |
FStream: TStream; |
| 2069 |
FOwnsStream: Boolean; |
| 2070 |
FTruncateOnRelease: Boolean; |
| 2071 |
FMaximumPosition: Int64; |
| 2072 |
procedure NeedStream; |
| 2073 |
procedure ReleaseStream; |
| 2074 |
public |
| 2075 |
constructor Create(AArchive: TJclCompressionArchive; AItemIndex: Integer); overload; |
| 2076 |
constructor Create(AStream: TStream; AOwnsStream: Boolean; ATruncateOnRelease: Boolean); overload; |
| 2077 |
destructor Destroy; override; |
| 2078 |
// ISequentialOutStream |
| 2079 |
function Write(Data: Pointer; Size: Cardinal; ProcessedSize: PCardinal): HRESULT; stdcall; |
| 2080 |
// IOutStream |
| 2081 |
function Seek(Offset: Int64; SeekOrigin: Cardinal; NewPosition: PInt64): HRESULT; stdcall; |
| 2082 |
function SetSize(NewSize: Int64): HRESULT; stdcall; |
| 2083 |
end; |
| 2084 |
|
| 2085 |
TJclSevenzipNestedInStream = class(TJclStream) |
| 2086 |
private |
| 2087 |
FInStream: IInStream; |
| 2088 |
protected |
| 2089 |
procedure SetSize(const NewSize: Int64); override; |
| 2090 |
public |
| 2091 |
constructor Create(AInStream: IInStream); |
| 2092 |
function Read(var Buffer; Count: Longint): Longint; override; |
| 2093 |
function Write(const Buffer; Count: Longint): Longint; override; |
| 2094 |
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; |
| 2095 |
end; |
| 2096 |
|
| 2097 |
TJclSevenzipInStream = class(TInterfacedObject, ISequentialInStream, |
| 2098 |
IInStream, IStreamGetSize, IUnknown) |
| 2099 |
private |
| 2100 |
FArchive: TJclCompressionArchive; |
| 2101 |
FItemIndex: Integer; |
| 2102 |
FStream: TStream; |
| 2103 |
FOwnsStream: Boolean; |
| 2104 |
procedure NeedStream; |
| 2105 |
procedure ReleaseStream; |
| 2106 |
public |
| 2107 |
constructor Create(AArchive: TJclCompressionArchive; AItemIndex: Integer); overload; |
| 2108 |
constructor Create(AStream: TStream; AOwnsStream: Boolean); overload; |
| 2109 |
destructor Destroy; override; |
| 2110 |
// ISequentialInStream |
| 2111 |
function Read(Data: Pointer; Size: Cardinal; ProcessedSize: PCardinal): HRESULT; stdcall; |
| 2112 |
// IInStream |
| 2113 |
function Seek(Offset: Int64; SeekOrigin: Cardinal; NewPosition: PInt64): HRESULT; stdcall; |
| 2114 |
// IStreamGetSize |
| 2115 |
function GetSize(Size: PInt64): HRESULT; stdcall; |
| 2116 |
end; |
| 2117 |
|
| 2118 |
TJclSevenzipOpenCallback = class(TInterfacedObject, IArchiveOpenCallback, |
| 2119 |
ICryptoGetTextPassword, IUnknown) |
| 2120 |
private |
| 2121 |
FArchive: TJclCompressionArchive; |
| 2122 |
public |
| 2123 |
constructor Create(AArchive: TJclCompressionArchive); |
| 2124 |
// IArchiveOpenCallback |
| 2125 |
function SetCompleted(Files: PInt64; Bytes: PInt64): HRESULT; stdcall; |
| 2126 |
function SetTotal(Files: PInt64; Bytes: PInt64): HRESULT; stdcall; |
| 2127 |
// ICryptoGetTextPassword |
| 2128 |
function CryptoGetTextPassword(password: PBStr): HRESULT; stdcall; |
| 2129 |
end; |
| 2130 |
|
| 2131 |
TJclSevenzipExtractCallback = class(TInterfacedObject, IUnknown, IProgress, |
| 2132 |
IArchiveExtractCallback, ICryptoGetTextPassword, ICompressProgressInfo) |
| 2133 |
private |
| 2134 |
FArchive: TJclCompressionArchive; |
| 2135 |
FLastStream: Cardinal; |
| 2136 |
public |
| 2137 |
constructor Create(AArchive: TJclCompressionArchive); |
| 2138 |
// IArchiveExtractCallback |
| 2139 |
function GetStream(Index: Cardinal; out OutStream: ISequentialOutStream; |
| 2140 |
askExtractMode: Cardinal): HRESULT; stdcall; |
| 2141 |
function PrepareOperation(askExtractMode: Cardinal): HRESULT; stdcall; |
| 2142 |
function SetOperationResult(resultEOperationResult: Integer): HRESULT; stdcall; |
| 2143 |
// IProgress |
| 2144 |
function SetCompleted(CompleteValue: PInt64): HRESULT; stdcall; |
| 2145 |
function SetTotal(Total: Int64): HRESULT; stdcall; |
| 2146 |
// ICryptoGetTextPassword |
| 2147 |
function CryptoGetTextPassword(password: PBStr): HRESULT; stdcall; |
| 2148 |
// ICompressProgressInfo |
| 2149 |
function SetRatioInfo(InSize: PInt64; OutSize: PInt64): HRESULT; stdcall; |
| 2150 |
end; |
| 2151 |
|
| 2152 |
TJclSevenzipUpdateCallback = class(TInterfacedObject, IUnknown, IProgress, |
| 2153 |
IArchiveUpdateCallback, IArchiveUpdateCallback2, ICryptoGetTextPassword2, |
| 2154 |
ICompressProgressInfo) |
| 2155 |
private |
| 2156 |
FArchive: TJclCompressionArchive; |
| 2157 |
FLastStream: Cardinal; |
| 2158 |
public |
| 2159 |
constructor Create(AArchive: TJclCompressionArchive); |
| 2160 |
// IProgress |
| 2161 |
function SetCompleted(CompleteValue: PInt64): HRESULT; stdcall; |
| 2162 |
function SetTotal(Total: Int64): HRESULT; stdcall; |
| 2163 |
// IArchiveUpdateCallback |
| 2164 |
function GetProperty(Index: Cardinal; PropID: Cardinal; out Value: tagPROPVARIANT): HRESULT; stdcall; |
| 2165 |
function GetStream(Index: Cardinal; out InStream: ISequentialInStream): HRESULT; stdcall; |
| 2166 |
function GetUpdateItemInfo(Index: Cardinal; NewData: PInteger; |
| 2167 |
NewProperties: PInteger; IndexInArchive: PCardinal): HRESULT; stdcall; |
| 2168 |
function SetOperationResult(OperationResult: Integer): HRESULT; stdcall; |
| 2169 |
// IArchiveUpdateCallback2 |
| 2170 |
function GetVolumeSize(Index: Cardinal; Size: PInt64): HRESULT; stdcall; |
| 2171 |
function GetVolumeStream(Index: Cardinal; |
| 2172 |
out VolumeStream: ISequentialOutStream): HRESULT; stdcall; |
| 2173 |
// ICryptoGetTextPassword2 |
| 2174 |
function CryptoGetTextPassword2(PasswordIsDefined: PInteger; |
| 2175 |
Password: PBStr): HRESULT; stdcall; |
| 2176 |
// ICompressProgressInfo |
| 2177 |
function SetRatioInfo(InSize: PInt64; OutSize: PInt64): HRESULT; stdcall; |
| 2178 |
end; |
| 2179 |
|
| 2180 |
type |
| 2181 |
TWideStringSetter = procedure (const Value: WideString) of object; |
| 2182 |
TCardinalSetter = procedure (Value: Cardinal) of object; |
| 2183 |
TInt64Setter = procedure (const Value: Int64) of object; |
| 2184 |
TFileTimeSetter = procedure (const Value: TFileTime) of object; |
| 2185 |
TBoolSetter = procedure (Value: Boolean) of object; |
| 2186 |
|
| 2187 |
procedure SevenzipCheck(Value: HRESULT); |
| 2188 |
function Get7zWideStringProp(const AArchive: IInArchive; ItemIndex: Integer; |
| 2189 |
PropID: Cardinal; const Setter: TWideStringSetter): Boolean; |
| 2190 |
function Get7zCardinalProp(const AArchive: IInArchive; ItemIndex: Integer; |
| 2191 |
PropID: Cardinal; const Setter: TCardinalSetter): Boolean; |
| 2192 |
function Get7zInt64Prop(const AArchive: IInArchive; ItemIndex: Integer; |
| 2193 |
PropID: Cardinal; const Setter: TInt64Setter): Boolean; |
| 2194 |
function Get7zFileTimeProp(const AArchive: IInArchive; ItemIndex: Integer; |
| 2195 |
PropID: Cardinal; const Setter: TFileTimeSetter): Boolean; |
| 2196 |
function Get7zBoolProp(const AArchive: IInArchive; ItemIndex: Integer; |
| 2197 |
PropID: Cardinal; const Setter: TBoolSetter): Boolean; |
| 2198 |
procedure Load7zFileAttribute(AInArchive: IInArchive; ItemIndex: Integer; |
| 2199 |
AItem: TJclCompressionItem); |
| 2200 |
procedure GetSevenzipArchiveCompressionProperties(AJclArchive: IInterface; ASevenzipArchive: IInterface); |
| 2201 |
procedure SetSevenzipArchiveCompressionProperties(AJclArchive: IInterface; ASevenzipArchive: IInterface); |
| 2202 |
|
| 2203 |
|
| 2204 |
function Create7zFile(SourceFiles: TStrings; const DestinationFile: TFileName; VolumeSize: Int64 = 0; |
| 2205 |
Password: String = ''; OnArchiveProgress: TJclCompressionProgressEvent = nil; |
| 2206 |
OnArchiveRatio: TJclCompressionRatioEvent = nil): Boolean; overload; |
| 2207 |
function Create7zFile(const SourceFile, DestinationFile: TFileName; VolumeSize: Int64 = 0; Password: String = ''; |
| 2208 |
OnArchiveProgress: TJclCompressionProgressEvent = nil; |
| 2209 |
OnArchiveRatio: TJclCompressionRatioEvent = nil): Boolean; overload; |
| 2210 |
|
| 2211 |
var |
| 2212 |
JclCompressSharedFiles: Boolean = False; |
| 2213 |
|
| 2214 |
{$ENDIF MSWINDOWS} |
| 2215 |
|
| 2216 |
{$IFDEF UNITVERSIONING} |
| 2217 |
const |
| 2218 |
UnitVersioning: TUnitVersionInfo = ( |
| 2219 |
RCSfile: '$URL$'; |
| 2220 |
Revision: '$Revision$'; |
| 2221 |
Date: '$Date$'; |
| 2222 |
LogPath: 'JCL\source\common'; |
| 2223 |
Extra: ''; |
| 2224 |
Data: nil |
| 2225 |
); |
| 2226 |
{$ENDIF UNITVERSIONING} |
| 2227 |
|
| 2228 |
implementation |
| 2229 |
|
| 2230 |
uses |
| 2231 |
DCJclResources, DCJclCompression; |
| 2232 |
|
| 2233 |
const |
| 2234 |
JclDefaultBufferSize = 131072; // 128k |
| 2235 |
|
| 2236 |
var |
| 2237 |
// using TObject prevents default linking of TJclCompressionStreamFormats |
| 2238 |
// and TJclCompressionArchiveFormats and all classes |
| 2239 |
GlobalStreamFormats: TObject; |
| 2240 |
GlobalArchiveFormats: TObject; |
| 2241 |
|
| 2242 |
{$IFNDEF FPC} |
| 2243 |
|
| 2244 |
//=== { TJclCompressionStream } ============================================== |
| 2245 |
|
| 2246 |
constructor TJclCompressionStream.Create(AStream: TStream); |
| 2247 |
begin |
| 2248 |
inherited Create; |
| 2249 |
FBuffer := nil; |
| 2250 |
SetBufferSize(JclDefaultBufferSize); |
| 2251 |
FStream := AStream; |
| 2252 |
end; |
| 2253 |
|
| 2254 |
destructor TJclCompressionStream.Destroy; |
| 2255 |
begin |
| 2256 |
SetBufferSize(0); |
| 2257 |
inherited Destroy; |
| 2258 |
end; |
| 2259 |
|
| 2260 |
function TJclCompressionStream.Read(var Buffer; Count: Longint): Longint; |
| 2261 |
begin |
| 2262 |
raise EJclCompressionError.CreateRes(@RsCompressionReadNotSupported); |
| 2263 |
end; |
| 2264 |
|
| 2265 |
function TJclCompressionStream.Write(const Buffer; Count: Longint): Longint; |
| 2266 |
begin |
| 2267 |
raise EJclCompressionError.CreateRes(@RsCompressionWriteNotSupported); |
| 2268 |
end; |
| 2269 |
|
| 2270 |
function TJclCompressionStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; |
| 2271 |
begin |
| 2272 |
raise EJclCompressionError.CreateRes(@RsCompressionSeekNotSupported); |
| 2273 |
end; |
| 2274 |
|
| 2275 |
procedure TJclCompressionStream.Reset; |
| 2276 |
begin |
| 2277 |
raise EJclCompressionError.CreateRes(@RsCompressionResetNotSupported); |
| 2278 |
end; |
| 2279 |
|
| 2280 |
function TJclCompressionStream.SetBufferSize(Size: Cardinal): Cardinal; |
| 2281 |
begin |
| 2282 |
if FBuffer <> nil then |
| 2283 |
FreeMem(FBuffer, FBufferSize); |
| 2284 |
|
| 2285 |
FBufferSize := Size; |
| 2286 |
|
| 2287 |
if FBufferSize > 0 then |
| 2288 |
GetMem(FBuffer, FBufferSize) |
| 2289 |
else |
| 2290 |
FBuffer := nil; |
| 2291 |
|
| 2292 |
Result := FBufferSize; |
| 2293 |
end; |
| 2294 |
|
| 2295 |
class function TJclCompressionStream.StreamExtensions: string; |
| 2296 |
begin |
| 2297 |
Result := ''; |
| 2298 |
end; |
| 2299 |
|
| 2300 |
class function TJclCompressionStream.StreamName: string; |
| 2301 |
begin |
| 2302 |
Result := ''; |
| 2303 |
end; |
| 2304 |
|
| 2305 |
class function TJclCompressionStream.StreamSubExtensions: string; |
| 2306 |
begin |
| 2307 |
Result := ''; |
| 2308 |
end; |
| 2309 |
|
| 2310 |
procedure TJclCompressionStream.Progress(Sender: TObject); |
| 2311 |
begin |
| 2312 |
if Assigned(FOnProgress) then |
| 2313 |
FOnProgress(Sender); |
| 2314 |
end; |
| 2315 |
|
| 2316 |
//=== { TJclCompressStream } ================================================= |
| 2317 |
|
| 2318 |
constructor TJclCompressStream.Create(Destination: TStream); |
| 2319 |
begin |
| 2320 |
inherited Create(Destination); |
| 2321 |
end; |
| 2322 |
|
| 2323 |
//=== { TJclDecompressStream } =============================================== |
| 2324 |
|
| 2325 |
constructor TJclDecompressStream.Create(Source: TStream; AOwnsStream: Boolean); |
| 2326 |
begin |
| 2327 |
inherited Create(Source); |
| 2328 |
FOwnsStream := AOwnsStream; |
| 2329 |
end; |
| 2330 |
|
| 2331 |
destructor TJclDecompressStream.Destroy; |
| 2332 |
begin |
| 2333 |
if FOwnsStream then |
| 2334 |
FStream.Free; |
| 2335 |
inherited Destroy; |
| 2336 |
end; |
| 2337 |
|
| 2338 |
//=== { TJclCompressionStreamFormats } ======================================= |
| 2339 |
|
| 2340 |
constructor TJclCompressionStreamFormats.Create; |
| 2341 |
begin |
| 2342 |
inherited Create; |
| 2343 |
FCompressFormats := TList.Create; |
| 2344 |
FDecompressFormats := TList.Create; |
| 2345 |
RegisterFormat(TJclZLibCompressStream); |
| 2346 |
RegisterFormat(TJclZLibDecompressStream); |
| 2347 |
RegisterFormat(TJclGZIPCompressionStream); |
| 2348 |
RegisterFormat(TJclGZIPDecompressionStream); |
| 2349 |
RegisterFormat(TJclBZIP2CompressionStream); |
| 2350 |
RegisterFormat(TJclBZIP2DecompressionStream); |
| 2351 |
end; |
| 2352 |
|
| 2353 |
destructor TJclCompressionStreamFormats.Destroy; |
| 2354 |
begin |
| 2355 |
FCompressFormats.Free; |
| 2356 |
FDecompressFormats.Free; |
| 2357 |
inherited Destroy; |
| 2358 |
end; |
| 2359 |
|
| 2360 |
function TJclCompressionStreamFormats.FindCompressFormat(const AFileName: TFileName): TJclCompressStreamClass; |
| 2361 |
var |
| 2362 |
IndexFormat, IndexFilter: Integer; |
| 2363 |
Filters: TStrings; |
| 2364 |
AFormat: TJclCompressStreamClass; |
| 2365 |
begin |
| 2366 |
Result := nil; |
| 2367 |
Filters := TStringList.Create; |
| 2368 |
try |
| 2369 |
for IndexFormat := 0 to CompressFormatCount - 1 do |
| 2370 |
begin |
| 2371 |
AFormat := CompressFormats[IndexFormat]; |
| 2372 |
StrTokenToStrings(AFormat.StreamExtensions, DirSeparator, Filters); |
| 2373 |
for IndexFilter := 0 to Filters.Count - 1 do |
| 2374 |
if IsFileNameMatch(AFileName, Filters.Strings[IndexFilter]) then |
| 2375 |
begin |
| 2376 |
Result := AFormat; |
| 2377 |
Break; |
| 2378 |
end; |
| 2379 |
if Result <> nil then |
| 2380 |
Break; |
| 2381 |
end; |
| 2382 |
finally |
| 2383 |
Filters.Free; |
| 2384 |
end; |
| 2385 |
end; |
| 2386 |
|
| 2387 |
function TJclCompressionStreamFormats.FindDecompressFormat(const AFileName: TFileName): TJclDecompressStreamClass; |
| 2388 |
var |
| 2389 |
IndexFormat, IndexFilter: Integer; |
| 2390 |
Filters: TStrings; |
| 2391 |
AFormat: TJclDecompressStreamClass; |
| 2392 |
begin |
| 2393 |
Result := nil; |
| 2394 |
Filters := TStringList.Create; |
| 2395 |
try |
| 2396 |
for IndexFormat := 0 to DecompressFormatCount - 1 do |
| 2397 |
begin |
| 2398 |
AFormat := DecompressFormats[IndexFormat]; |
| 2399 |
StrTokenToStrings(AFormat.StreamExtensions, DirSeparator, Filters); |
| 2400 |
for IndexFilter := 0 to Filters.Count - 1 do |
| 2401 |
if IsFileNameMatch(AFileName, Filters.Strings[IndexFilter]) then |
| 2402 |
begin |
| 2403 |
Result := AFormat; |
| 2404 |
Break; |
| 2405 |
end; |
| 2406 |
if Result <> nil then |
| 2407 |
Break; |
| 2408 |
end; |
| 2409 |
finally |
| 2410 |
Filters.Free; |
| 2411 |
end; |
| 2412 |
end; |
| 2413 |
|
| 2414 |
function TJclCompressionStreamFormats.GetCompressFormat(Index: Integer): TJclCompressStreamClass; |
| 2415 |
begin |
| 2416 |
Result := TJclCompressStreamClass(FCompressFormats.Items[Index]); |
| 2417 |
end; |
| 2418 |
|
| 2419 |
function TJclCompressionStreamFormats.GetCompressFormatCount: Integer; |
| 2420 |
begin |
| 2421 |
Result := FCompressFormats.Count; |
| 2422 |
end; |
| 2423 |
|
| 2424 |
function TJclCompressionStreamFormats.GetDecompressFormat(Index: Integer): TJclDecompressStreamClass; |
| 2425 |
begin |
| 2426 |
Result := TJclDecompressStreamClass(FDecompressFormats.Items[Index]); |
| 2427 |
end; |
| 2428 |
|
| 2429 |
function TJclCompressionStreamFormats.GetDecompressFormatCount: Integer; |
| 2430 |
begin |
| 2431 |
Result := FDecompressFormats.Count; |
| 2432 |
end; |
| 2433 |
|
| 2434 |
procedure TJclCompressionStreamFormats.RegisterFormat(AClass: TJclCompressionStreamClass); |
| 2435 |
begin |
| 2436 |
if AClass.InheritsFrom(TJclCompressStream) then |
| 2437 |
FCompressFormats.Add(AClass) |
| 2438 |
else |
| 2439 |
if AClass.InheritsFrom(TJclDecompressStream) then |
| 2440 |
FDecompressFormats.Add(AClass); |
| 2441 |
end; |
| 2442 |
|
| 2443 |
procedure TJclCompressionStreamFormats.UnregisterFormat(AClass: TJclCompressionStreamClass); |
| 2444 |
begin |
| 2445 |
if AClass.InheritsFrom(TJclCompressStream) then |
| 2446 |
FCompressFormats.Remove(AClass) |
| 2447 |
else |
| 2448 |
if AClass.InheritsFrom(TJclDecompressStream) then |
| 2449 |
FDecompressFormats.Remove(AClass); |
| 2450 |
end; |
| 2451 |
|
| 2452 |
function GetStreamFormats: TJclCompressionStreamFormats; |
| 2453 |
begin |
| 2454 |
if not Assigned(GlobalStreamFormats) then |
| 2455 |
GlobalStreamFormats := TJclCompressionStreamFormats.Create; |
| 2456 |
Result := TJclCompressionStreamFormats(GlobalStreamFormats); |
| 2457 |
end; |
| 2458 |
|
| 2459 |
//=== { TJclZLibCompressionStream } ========================================== |
| 2460 |
|
| 2461 |
{ Error checking helper } |
| 2462 |
|
| 2463 |
function ZLibCheck(const ErrCode: Integer): Integer; |
| 2464 |
begin |
| 2465 |
case ErrCode of |
| 2466 |
0..High(ErrCode): |
| 2467 |
Result := ErrCode; // no error |
| 2468 |
Z_ERRNO: |
| 2469 |
raise EJclCompressionError.CreateRes(@RsCompressionZLibZErrNo); |
| 2470 |
Z_STREAM_ERROR: |
| 2471 |
raise EJclCompressionError.CreateRes(@RsCompressionZLibZStreamError); |
| 2472 |
Z_DATA_ERROR: |
| 2473 |
raise EJclCompressionError.CreateRes(@RsCompressionZLibZDataError); |
| 2474 |
Z_MEM_ERROR: |
| 2475 |
raise EJclCompressionError.CreateRes(@RsCompressionZLibZMemError); |
| 2476 |
Z_BUF_ERROR: |
| 2477 |
raise EJclCompressionError.CreateRes(@RsCompressionZLibZBufError); |
| 2478 |
Z_VERSION_ERROR: |
| 2479 |
raise EJclCompressionError.CreateRes(@RsCompressionZLibZVersionError); |
| 2480 |
else |
| 2481 |
raise EJclCompressionError.CreateResFmt(@RsCompressionZLibError, [ErrCode]); |
| 2482 |
end; |
| 2483 |
end; |
| 2484 |
|
| 2485 |
constructor TJclZLibCompressStream.Create(Destination: TStream; CompressionLevel: TJclCompressionLevel); |
| 2486 |
begin |
| 2487 |
inherited Create(Destination); |
| 2488 |
|
| 2489 |
LoadZLib; |
| 2490 |
|
| 2491 |
Assert(FBuffer <> nil); |
| 2492 |
Assert(FBufferSize > 0); |
| 2493 |
|
| 2494 |
// Initialize ZLib StreamRecord |
| 2495 |
ZLibRecord.zalloc := nil; // Use build-in memory allocation functionality |
| 2496 |
ZLibRecord.zfree := nil; |
| 2497 |
ZLibRecord.next_in := nil; |
| 2498 |
ZLibRecord.avail_in := 0; |
| 2499 |
ZLibRecord.next_out := FBuffer; |
| 2500 |
ZLibRecord.avail_out := FBufferSize; |
| 2501 |
|
| 2502 |
FWindowBits := DEF_WBITS; |
| 2503 |
FMemLevel := DEF_MEM_LEVEL; |
| 2504 |
FMethod := Z_DEFLATED; |
| 2505 |
FStrategy := Z_DEFAULT_STRATEGY; |
| 2506 |
FCompressionLevel := CompressionLevel; |
| 2507 |
FDeflateInitialized := False; |
| 2508 |
end; |
| 2509 |
|
| 2510 |
destructor TJclZLibCompressStream.Destroy; |
| 2511 |
begin |
| 2512 |
Flush; |
| 2513 |
if FDeflateInitialized then |
| 2514 |
begin |
| 2515 |
ZLibRecord.next_in := nil; |
| 2516 |
ZLibRecord.avail_in := 0; |
| 2517 |
ZLibRecord.avail_out := 0; |
| 2518 |
ZLibRecord.next_out := nil; |
| 2519 |
|
| 2520 |
ZLibCheck(deflateEnd(ZLibRecord)); |
| 2521 |
end; |
| 2522 |
|
| 2523 |
inherited Destroy; |
| 2524 |
end; |
| 2525 |
|
| 2526 |
function TJclZLibCompressStream.Write(const Buffer; Count: Longint): Longint; |
| 2527 |
begin |
| 2528 |
if not FDeflateInitialized then |
| 2529 |
begin |
| 2530 |
ZLibCheck(deflateInit2(ZLibRecord, FCompressionLevel, FMethod, FWindowBits, FMemLevel, FStrategy)); |
| 2531 |
FDeflateInitialized := True; |
| 2532 |
end; |
| 2533 |
|
| 2534 |
ZLibRecord.next_in := @Buffer; |
| 2535 |
ZLibRecord.avail_in := Count; |
| 2536 |
|
| 2537 |
while ZLibRecord.avail_in > 0 do |
| 2538 |
begin |
| 2539 |
ZLibCheck(deflate(ZLibRecord, Z_NO_FLUSH)); |
| 2540 |
|
| 2541 |
if ZLibRecord.avail_out = 0 then // Output buffer empty. Write to stream and go on... |
| 2542 |
begin |
| 2543 |
FStream.WriteBuffer(FBuffer^, FBufferSize); |
| 2544 |
Progress(Self); |
| 2545 |
ZLibRecord.next_out := FBuffer; |
| 2546 |
ZLibRecord.avail_out := FBufferSize; |
| 2547 |
end; |
| 2548 |
end; |
| 2549 |
|
| 2550 |
Result := Count; |
| 2551 |
end; |
| 2552 |
|
| 2553 |
function TJclZLibCompressStream.Flush: Integer; |
| 2554 |
begin |
| 2555 |
Result := 0; |
| 2556 |
|
| 2557 |
if FDeflateInitialized then |
| 2558 |
begin |
| 2559 |
ZLibRecord.next_in := nil; |
| 2560 |
ZLibRecord.avail_in := 0; |
| 2561 |
|
| 2562 |
while (ZLibCheck(deflate(ZLibRecord, Z_FINISH)) <> Z_STREAM_END) and |
| 2563 |
(ZLibRecord.avail_out = 0) do |
| 2564 |
begin |
| 2565 |
FStream.WriteBuffer(FBuffer^, FBufferSize); |
| 2566 |
Progress(Self); |
| 2567 |
|
| 2568 |
ZLibRecord.next_out := FBuffer; |
| 2569 |
ZLibRecord.avail_out := FBufferSize; |
| 2570 |
Inc(Result, FBufferSize); |
| 2571 |
end; |
| 2572 |
|
| 2573 |
if ZLibRecord.avail_out < FBufferSize then |
| 2574 |
begin |
| 2575 |
FStream.WriteBuffer(FBuffer^, FBufferSize - ZLibRecord.avail_out); |
| 2576 |
Progress(Self); |
| 2577 |
Inc(Result, FBufferSize - ZLibRecord.avail_out); |
| 2578 |
ZLibRecord.next_out := FBuffer; |
| 2579 |
ZLibRecord.avail_out := FBufferSize; |
| 2580 |
end; |
| 2581 |
end; |
| 2582 |
end; |
| 2583 |
|
| 2584 |
function TJclZLibCompressStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; |
| 2585 |
begin |
| 2586 |
if (Offset = 0) and (Origin = soCurrent) then |
| 2587 |
Result := ZLibRecord.total_in |
| 2588 |
else |
| 2589 |
if (Offset = 0) and (Origin = soBeginning) and (ZLibRecord.total_in = 0) then |
| 2590 |
Result := 0 |
| 2591 |
else |
| 2592 |
Result := inherited Seek(Offset, Origin); |
| 2593 |
end; |
| 2594 |
|
| 2595 |
procedure TJclZLibCompressStream.SetWindowBits(Value: Integer); |
| 2596 |
begin |
| 2597 |
FWindowBits := Value; |
| 2598 |
end; |
| 2599 |
|
| 2600 |
class function TJclZLibCompressStream.StreamExtensions: string; |
| 2601 |
begin |
| 2602 |
Result := LoadResString(@RsCompressionZExtensions); |
| 2603 |
end; |
| 2604 |
|
| 2605 |
class function TJclZLibCompressStream.StreamName: string; |
| 2606 |
begin |
| 2607 |
Result := LoadResString(@RsCompressionZName); |
| 2608 |
end; |
| 2609 |
|
| 2610 |
class function TJclZLibCompressStream.StreamSubExtensions: string; |
| 2611 |
begin |
| 2612 |
Result := LoadResString(@RsCompressionZSubExtensions); |
| 2613 |
end; |
| 2614 |
|
| 2615 |
procedure TJclZLibCompressStream.SetMethod(Value: Integer); |
| 2616 |
begin |
| 2617 |
FMethod := Value; |
| 2618 |
end; |
| 2619 |
|
| 2620 |
procedure TJclZLibCompressStream.SetStrategy(Value: Integer); |
| 2621 |
begin |
| 2622 |
FStrategy := Value; |
| 2623 |
if FDeflateInitialized then |
| 2624 |
ZLibCheck(deflateParams(ZLibRecord, FCompressionLevel, FStrategy)); |
| 2625 |
end; |
| 2626 |
|
| 2627 |
procedure TJclZLibCompressStream.SetMemLevel(Value: Integer); |
| 2628 |
begin |
| 2629 |
FMemLevel := Value; |
| 2630 |
end; |
| 2631 |
|
| 2632 |
procedure TJclZLibCompressStream.SetCompressionLevel(Value: Integer); |
| 2633 |
begin |
| 2634 |
FCompressionLevel := Value; |
| 2635 |
if FDeflateInitialized then |
| 2636 |
ZLibCheck(deflateParams(ZLibRecord, FCompressionLevel, FStrategy)); |
| 2637 |
end; |
| 2638 |
|
| 2639 |
procedure TJclZLibCompressStream.Reset; |
| 2640 |
begin |
| 2641 |
if FDeflateInitialized then |
| 2642 |
begin |
| 2643 |
Flush; |
| 2644 |
ZLibCheck(deflateReset(ZLibRecord)); |
| 2645 |
end; |
| 2646 |
end; |
| 2647 |
|
| 2648 |
//=== { TJclZLibDecompressionStream } ======================================= |
| 2649 |
|
| 2650 |
constructor TJclZLibDecompressStream.Create(Source: TStream; WindowBits: Integer; AOwnsStream: Boolean); |
| 2651 |
begin |
| 2652 |
inherited Create(Source, AOwnsStream); |
| 2653 |
|
| 2654 |
LoadZLib; |
| 2655 |
|
| 2656 |
// Initialize ZLib StreamRecord |
| 2657 |
ZLibRecord.zalloc := nil; // Use build-in memory allocation functionality |
| 2658 |
ZLibRecord.zfree := nil; |
| 2659 |
ZLibRecord.next_in := nil; |
| 2660 |
ZLibRecord.avail_in := 0; |
| 2661 |
ZLibRecord.next_out := FBuffer; |
| 2662 |
ZLibRecord.avail_out := FBufferSize; |
| 2663 |
|
| 2664 |
FInflateInitialized := False; |
| 2665 |
FWindowBits := WindowBits; |
| 2666 |
end; |
| 2667 |
|
| 2668 |
destructor TJclZLibDecompressStream.Destroy; |
| 2669 |
begin |
| 2670 |
if FInflateInitialized then |
| 2671 |
begin |
| 2672 |
FStream.Seek(-ZLibRecord.avail_in, soCurrent); |
| 2673 |
ZLibCheck(inflateEnd(ZLibRecord)); |
| 2674 |
end; |
| 2675 |
|
| 2676 |
inherited Destroy; |
| 2677 |
end; |
| 2678 |
|
| 2679 |
function TJclZLibDecompressStream.Read(var Buffer; Count: Longint): Longint; |
| 2680 |
var |
| 2681 |
Res: Integer; |
| 2682 |
begin |
| 2683 |
if not FInflateInitialized then |
| 2684 |
begin |
| 2685 |
ZLibCheck(InflateInit2(ZLibRecord, FWindowBits)); |
| 2686 |
FInflateInitialized := True; |
| 2687 |
end; |
| 2688 |
|
| 2689 |
ZLibRecord.next_out := @Buffer; |
| 2690 |
ZLibRecord.avail_out := Count; |
| 2691 |
|
| 2692 |
while ZLibRecord.avail_out > 0 do // as long as we have data |
| 2693 |
begin |
| 2694 |
if ZLibRecord.avail_in = 0 then |
| 2695 |
begin |
| 2696 |
ZLibRecord.avail_in := FStream.Read(FBuffer^, FBufferSize); |
| 2697 |
|
| 2698 |
if ZLibRecord.avail_in = 0 then |
| 2699 |
begin |
| 2700 |
Result := Count - Longint(ZLibRecord.avail_out); |
| 2701 |
Exit; |
| 2702 |
end; |
| 2703 |
|
| 2704 |
ZLibRecord.next_in := FBuffer; |
| 2705 |
end; |
| 2706 |
|
| 2707 |
if ZLibRecord.avail_in > 0 then |
| 2708 |
begin |
| 2709 |
Res := inflate(ZLibRecord, Z_NO_FLUSH); |
| 2710 |
ZLibCheck(Res); |
| 2711 |
Progress(Self); |
| 2712 |
|
| 2713 |
// Suggestion by ZENsan (mantis 4546) |
| 2714 |
if Res = Z_STREAM_END then |
| 2715 |
begin |
| 2716 |
Result := Count - Longint(ZLibRecord.avail_out); |
| 2717 |
Exit; |
| 2718 |
end; |
| 2719 |
end; |
| 2720 |
end; |
| 2721 |
|
| 2722 |
Result := Count; |
| 2723 |
end; |
| 2724 |
|
| 2725 |
function TJclZLibDecompressStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; |
| 2726 |
begin |
| 2727 |
if (Offset = 0) and (Origin = soCurrent) then |
| 2728 |
Result := ZLibRecord.total_out |
| 2729 |
else |
| 2730 |
Result := inherited Seek(Offset, Origin); |
| 2731 |
end; |
| 2732 |
|
| 2733 |
procedure TJclZLibDecompressStream.SetWindowBits(Value: Integer); |
| 2734 |
begin |
| 2735 |
FWindowBits := Value; |
| 2736 |
end; |
| 2737 |
|
| 2738 |
class function TJclZLibDecompressStream.StreamExtensions: string; |
| 2739 |
begin |
| 2740 |
Result := LoadResString(@RsCompressionZExtensions); |
| 2741 |
end; |
| 2742 |
|
| 2743 |
class function TJclZLibDecompressStream.StreamName: string; |
| 2744 |
begin |
| 2745 |
Result := LoadResString(@RsCompressionZName); |
| 2746 |
end; |
| 2747 |
|
| 2748 |
class function TJclZLibDecompressStream.StreamSubExtensions: string; |
| 2749 |
begin |
| 2750 |
Result := LoadResString(@RsCompressionZSubExtensions); |
| 2751 |
end; |
| 2752 |
|
| 2753 |
//=== { TJclGZIPCompressionStream } ========================================== |
| 2754 |
|
| 2755 |
constructor TJclGZIPCompressionStream.Create(Destination: TStream; CompressionLevel: TJclCompressionLevel); |
| 2756 |
begin |
| 2757 |
inherited Create(Destination); |
| 2758 |
|
| 2759 |
LoadZLib; |
| 2760 |
|
| 2761 |
FFlags := [gfHeaderCRC16, gfExtraField, gfOriginalFileName, gfComment]; |
| 2762 |
FAutoSetTime := True; |
| 2763 |
FFatSystem := gfsUnknown; |
| 2764 |
FCompressionLevel := CompressionLevel; |
| 2765 |
FDataCRC32 := crc32(0, nil, 0); |
| 2766 |
end; |
| 2767 |
|
| 2768 |
destructor TJclGZIPCompressionStream.Destroy; |
| 2769 |
begin |
| 2770 |
// BUGFIX: CRC32 and Uncompressed Size missing from GZIP output |
| 2771 |
// unless you called Flush manually. This is not correct Stream behaviour. |
| 2772 |
// Flush should be optional! |
| 2773 |
Flush; |
| 2774 |
FZLibStream.Free; |
| 2775 |
inherited Destroy; |
| 2776 |
end; |
| 2777 |
|
| 2778 |
function TJclGZIPCompressionStream.Flush: Integer; |
| 2779 |
var |
| 2780 |
AFooter: TJclGZIPFooter; |
| 2781 |
begin |
| 2782 |
if Assigned(FZLibStream) then |
| 2783 |
Result := FZLibStream.Flush |
| 2784 |
else |
| 2785 |
Result := 0; |
| 2786 |
|
| 2787 |
if FFooterWritten then |
| 2788 |
Exit; |
| 2789 |
FFooterWritten := True; |
| 2790 |
|
| 2791 |
// Write footer, CRC32 followed by ISIZE |
| 2792 |
AFooter.DataCRC32 := FDataCRC32; |
| 2793 |
AFooter.DataSize := FOriginalSize; |
| 2794 |
|
| 2795 |
Inc(Result, FStream.Write(AFooter, SizeOf(AFooter))); |
| 2796 |
end; |
| 2797 |
|
| 2798 |
function TJclGZIPCompressionStream.GetDosTime: TDateTime; |
| 2799 |
begin |
| 2800 |
if AutoSetTime then |
| 2801 |
Result := Now |
| 2802 |
else |
| 2803 |
Result := UnixTimeToDateTime(FUnixTime); |
| 2804 |
end; |
| 2805 |
|
| 2806 |
function TJclGZIPCompressionStream.GetUnixTime: Cardinal; |
| 2807 |
begin |
| 2808 |
if AutoSetTime then |
| 2809 |
Result := DateTimeToUnixTime(Now) |
| 2810 |
else |
| 2811 |
Result := FUnixTime; |
| 2812 |
end; |
| 2813 |
|
| 2814 |
procedure TJclGZIPCompressionStream.Reset; |
| 2815 |
begin |
| 2816 |
if Assigned(FZLibStream) then |
| 2817 |
FZLibStream.Reset; |
| 2818 |
|
| 2819 |
FDataCRC32 := crc32(0, nil, 0); |
| 2820 |
FOriginalSize := 0; |
| 2821 |
end; |
| 2822 |
|
| 2823 |
procedure TJclGZIPCompressionStream.SetDosTime(const Value: TDateTime); |
| 2824 |
begin |
| 2825 |
AutoSetTime := False; |
| 2826 |
FUnixTime := DateTimeToUnixTime(Value); |
| 2827 |
end; |
| 2828 |
|
| 2829 |
procedure TJclGZIPCompressionStream.SetUnixTime(Value: Cardinal); |
| 2830 |
begin |
| 2831 |
AutoSetTime := False; |
| 2832 |
FUnixTime := Value; |
| 2833 |
end; |
| 2834 |
|
| 2835 |
class function TJclGZIPCompressionStream.StreamExtensions: string; |
| 2836 |
begin |
| 2837 |
Result := LoadResString(@RsCompressionGZipExtensions); |
| 2838 |
end; |
| 2839 |
|
| 2840 |
class function TJclGZIPCompressionStream.StreamName: string; |
| 2841 |
begin |
| 2842 |
Result := LoadResString(@RsCompressionGZipName); |
| 2843 |
end; |
| 2844 |
|
| 2845 |
class function TJclGZIPCompressionStream.StreamSubExtensions: string; |
| 2846 |
begin |
| 2847 |
Result := LoadResString(@RsCompressionGZipSubExtensions); |
| 2848 |
end; |
| 2849 |
|
| 2850 |
function TJclGZIPCompressionStream.Write(const Buffer; Count: Integer): Longint; |
| 2851 |
begin |
| 2852 |
if not FHeaderWritten then |
| 2853 |
begin |
| 2854 |
WriteHeader; |
| 2855 |
FHeaderWritten := True; |
| 2856 |
end; |
| 2857 |
|
| 2858 |
if not Assigned(FZLibStream) then |
| 2859 |
begin |
| 2860 |
FZLibStream := TJclZLibCompressStream.Create(FStream, FCompressionLevel); |
| 2861 |
FZLibStream.WindowBits := -DEF_WBITS; // negative value for raw mode |
| 2862 |
FZLibStream.OnProgress := ZLibStreamProgress; |
| 2863 |
end; |
| 2864 |
|
| 2865 |
Result := FZLibStream.Write(Buffer, Count); |
| 2866 |
FDataCRC32 := crc32(FDataCRC32, PBytef(@Buffer), Result); |
| 2867 |
Inc(FOriginalSize, Result); |
| 2868 |
end; |
| 2869 |
|
| 2870 |
procedure TJclGZIPCompressionStream.WriteHeader; |
| 2871 |
const |
| 2872 |
FatSystemToByte: array [TJclGZIPFatSystem] of Byte = |
| 2873 |
(JCL_GZIP_OS_FAT, JCL_GZIP_OS_AMIGA, JCL_GZIP_OS_VMS, JCL_GZIP_OS_UNIX, |
| 2874 |
JCL_GZIP_OS_VM, JCL_GZIP_OS_ATARI, JCL_GZIP_OS_HPFS, JCL_GZIP_OS_MAC, |
| 2875 |
JCL_GZIP_OS_Z, JCL_GZIP_OS_CPM, JCL_GZIP_OS_TOPS, JCL_GZIP_OS_NTFS, |
| 2876 |
JCL_GZIP_OS_QDOS, JCL_GZIP_OS_ACORN, JCL_GZIP_OS_UNKNOWN, JCL_GZIP_OS_UNKNOWN); |
| 2877 |
var |
| 2878 |
AHeader: TJclGZIPHeader; |
| 2879 |
ExtraFieldLength, HeaderCRC16: Word; |
| 2880 |
HeaderCRC: Cardinal; |
| 2881 |
TmpAnsiString: AnsiString; |
| 2882 |
|
| 2883 |
procedure StreamWriteBuffer(const Buffer; Count: Longint); |
| 2884 |
begin |
| 2885 |
FStream.WriteBuffer(Buffer, Count); |
| 2886 |
if gfHeaderCRC16 in Flags then |
| 2887 |
HeaderCRC := crc32(HeaderCRC, @Byte(Buffer), Count); |
| 2888 |
end; |
| 2889 |
|
| 2890 |
function CheckCString(const Buffer: string): Boolean; |
| 2891 |
var |
| 2892 |
Index: Integer; |
| 2893 |
begin |
| 2894 |
Result := False; |
| 2895 |
for Index := 1 to Length(Buffer) do |
| 2896 |
if Buffer[Index] = #0 then |
| 2897 |
Exit; |
| 2898 |
Result := True; |
| 2899 |
end; |
| 2900 |
|
| 2901 |
begin |
| 2902 |
if gfHeaderCRC16 in Flags then |
| 2903 |
HeaderCRC := crc32(0, nil, 0); |
| 2904 |
|
| 2905 |
AHeader.ID1 := JCL_GZIP_ID1; |
| 2906 |
AHeader.ID2 := JCL_GZIP_ID2; |
| 2907 |
AHeader.CompressionMethod := JCL_GZIP_CM_DEFLATE; |
| 2908 |
AHeader.Flags := 0; |
| 2909 |
if gfDataIsText in Flags then |
| 2910 |
AHeader.Flags := AHeader.Flags or JCL_GZIP_FLAG_TEXT; |
| 2911 |
if gfHeaderCRC16 in Flags then |
| 2912 |
AHeader.Flags := AHeader.Flags or JCL_GZIP_FLAG_CRC; |
| 2913 |
if (gfExtraField in Flags) and (ExtraField <> '') then |
| 2914 |
AHeader.Flags := AHeader.Flags or JCL_GZIP_FLAG_EXTRA; |
| 2915 |
if (gfOriginalFileName in Flags) and (OriginalFileName <> '') then |
| 2916 |
AHeader.Flags := AHeader.Flags or JCL_GZIP_FLAG_NAME; |
| 2917 |
if (gfComment in Flags) and (Comment <> '') then |
| 2918 |
AHeader.Flags := AHeader.Flags or JCL_GZIP_FLAG_COMMENT; |
| 2919 |
|
| 2920 |
if AutoSetTime then |
| 2921 |
AHeader.ModifiedTime := DateTimeToUnixTime(Now) |
| 2922 |
else |
| 2923 |
AHeader.ModifiedTime := FUnixTime; |
| 2924 |
|
| 2925 |
case FCompressionLevel of |
| 2926 |
Z_BEST_COMPRESSION: |
| 2927 |
AHeader.ExtraFlags := JCL_GZIP_EFLAG_MAX; |
| 2928 |
Z_BEST_SPEED: |
| 2929 |
AHeader.ExtraFlags := JCL_GZIP_EFLAG_FAST; |
| 2930 |
else |
| 2931 |
AHeader.ExtraFlags := 0; |
| 2932 |
end; |
| 2933 |
|
| 2934 |
AHeader.OS := FatSystemToByte[FatSystem]; |
| 2935 |
|
| 2936 |
StreamWriteBuffer(AHeader, SizeOf(AHeader)); |
| 2937 |
|
| 2938 |
if (gfExtraField in Flags) and (ExtraField <> '') then |
| 2939 |
begin |
| 2940 |
if Length(ExtraField) > High(Word) then |
| 2941 |
raise EJclCompressionError.CreateRes(@RsCompressionGZIPExtraFieldTooLong); |
| 2942 |
ExtraFieldLength := Length(ExtraField); |
| 2943 |
StreamWriteBuffer(ExtraFieldLength, SizeOf(ExtraFieldLength)); |
| 2944 |
StreamWriteBuffer(ExtraField[1], Length(ExtraField)); |
| 2945 |
end; |
| 2946 |
|
| 2947 |
if (gfOriginalFileName in Flags) and (OriginalFileName <> '') then |
| 2948 |
begin |
| 2949 |
if not CheckCString(OriginalFileName) then |
| 2950 |
raise EJclCompressionError.CreateRes(@RsCompressionGZIPBadString); |
| 2951 |
|
| 2952 |
TmpAnsiString := AnsiString(OriginalFileName); |
| 2953 |
StreamWriteBuffer(TmpAnsiString[1], Length(TmpAnsiString) + 1); |
| 2954 |
end; |
| 2955 |
|
| 2956 |
if (gfComment in Flags) and (Comment <> '') then |
| 2957 |
begin |
| 2958 |
if not CheckCString(Comment) then |
| 2959 |
raise EJclCompressionError.CreateRes(@RsCompressionGZIPBadString); |
| 2960 |
|
| 2961 |
TmpAnsiString := AnsiString(Comment); |
| 2962 |
StreamWriteBuffer(TmpAnsiString[1], Length(TmpAnsiString) + 1); |
| 2963 |
end; |
| 2964 |
|
| 2965 |
if (gfHeaderCRC16 in Flags) then |
| 2966 |
begin |
| 2967 |
HeaderCRC16 := HeaderCRC and $FFFF; |
| 2968 |
FStream.WriteBuffer(HeaderCRC16, SizeOf(HeaderCRC16)); |
| 2969 |
end; |
| 2970 |
end; |
| 2971 |
|
| 2972 |
procedure TJclGZIPCompressionStream.ZLibStreamProgress(Sender: TObject); |
| 2973 |
begin |
| 2974 |
Progress(Self); |
| 2975 |
end; |
| 2976 |
|
| 2977 |
//=== { TJclGZIPDecompressionStream } ======================================== |
| 2978 |
|
| 2979 |
constructor TJclGZIPDecompressionStream.Create(Source: TStream; CheckHeaderCRC: Boolean; AOwnsStream: Boolean); |
| 2980 |
var |
| 2981 |
HeaderCRC: Cardinal; |
| 2982 |
ComputeHeaderCRC: Boolean; |
| 2983 |
ExtraFieldLength: Word; |
| 2984 |
|
| 2985 |
procedure ReadBuffer(var Buffer; SizeOfBuffer: Longint); |
| 2986 |
begin |
| 2987 |
Source.ReadBuffer(Buffer, SizeOfBuffer); |
| 2988 |
if ComputeHeaderCRC then |
| 2989 |
HeaderCRC := crc32(HeaderCRC, @Byte(Buffer), SizeOfBuffer); |
| 2990 |
end; |
| 2991 |
|
| 2992 |
function ReadCString: AnsiString; |
| 2993 |
var |
| 2994 |
Buf: AnsiChar; |
| 2995 |
begin |
| 2996 |
Result := ''; |
| 2997 |
Buf := #0; |
| 2998 |
repeat |
| 2999 |
Source.ReadBuffer(Buf, SizeOf(Buf)); |
| 3000 |
if Buf = #0 then Break; |
| 3001 |
Result := Result + Buf; |
| 3002 |
until False; |
| 3003 |
end; |
| 3004 |
|
| 3005 |
begin |
| 3006 |
inherited Create(Source, AOwnsStream); |
| 3007 |
|
| 3008 |
LoadZLib; |
| 3009 |
|
| 3010 |
FAutoCheckDataCRC32 := True; |
| 3011 |
FComputedDataCRC32 := crc32(0, nil, 0); |
| 3012 |
HeaderCRC := crc32(0, nil, 0); |
| 3013 |
|
| 3014 |
ComputeHeaderCRC := CheckHeaderCRC; |
| 3015 |
ReadBuffer(FHeader, SizeOf(FHeader)); |
| 3016 |
if (FHeader.ID1 <> JCL_GZIP_ID1) or (FHeader.ID2 <> JCL_GZIP_ID2) then |
| 3017 |
raise EJclCompressionError.CreateResFmt(@RsCompressionGZipInvalidID, [FHeader.ID1, FHeader.ID2]); |
| 3018 |
if (FHeader.CompressionMethod <> JCL_GZIP_CM_DEFLATE) then |
| 3019 |
raise EJclCompressionError.CreateResFmt(@RsCompressionGZipUnsupportedCM, [FHeader.CompressionMethod]); |
| 3020 |
|
| 3021 |
if (FHeader.Flags and JCL_GZIP_FLAG_EXTRA) <> 0 then |
| 3022 |
begin |
| 3023 |
ExtraFieldLength := 0; |
| 3024 |
ReadBuffer(ExtraFieldLength, SizeOf(ExtraFieldLength)); |
| 3025 |
SetLength(FExtraField, ExtraFieldLength); |
| 3026 |
ReadBuffer(FExtraField[1], ExtraFieldLength); |
| 3027 |
end; |
| 3028 |
|
| 3029 |
if (FHeader.Flags and JCL_GZIP_FLAG_NAME) <> 0 then |
| 3030 |
FOriginalFileName := TFileName(ReadCString); |
| 3031 |
if (FHeader.Flags and JCL_GZIP_FLAG_COMMENT) <> 0 then |
| 3032 |
FComment := string(ReadCString); |
| 3033 |
|
| 3034 |
if CheckHeaderCRC then |
| 3035 |
begin |
| 3036 |
ComputeHeaderCRC := False; |
| 3037 |
FComputedHeaderCRC16 := HeaderCRC and $FFFF; |
| 3038 |
end; |
| 3039 |
|
| 3040 |
if (FHeader.Flags and JCL_GZIP_FLAG_CRC) <> 0 then |
| 3041 |
begin |
| 3042 |
Source.ReadBuffer(FStoredHeaderCRC16, SizeOf(FStoredHeaderCRC16)); |
| 3043 |
if CheckHeaderCRC and (FComputedHeaderCRC16 <> FStoredHeaderCRC16) then |
| 3044 |
raise EJclCompressionError.CreateRes(@RsCompressionGZipHeaderCRC); |
| 3045 |
end; |
| 3046 |
end; |
| 3047 |
|
| 3048 |
destructor TJclGZIPDecompressionStream.Destroy; |
| 3049 |
begin |
| 3050 |
FZLibStream.Free; |
| 3051 |
FCompressedDataStream.Free; |
| 3052 |
inherited Destroy; |
| 3053 |
end; |
| 3054 |
|
| 3055 |
function TJclGZIPDecompressionStream.GetCompressedDataSize: Int64; |
| 3056 |
begin |
| 3057 |
if not FDataStarted then |
| 3058 |
Result := FStream.Size - FStream.Position - SizeOf(FFooter) |
| 3059 |
else |
| 3060 |
if FDataEnded then |
| 3061 |
Result := FCompressedDataSize |
| 3062 |
else |
| 3063 |
raise EJclCompressionError.CreateRes(@RsCompressionGZipDecompressing); |
| 3064 |
end; |
| 3065 |
|
| 3066 |
function TJclGZIPDecompressionStream.GetComputedDataCRC32: Cardinal; |
| 3067 |
begin |
| 3068 |
if FDataEnded then |
| 3069 |
Result := FComputedDataCRC32 |
| 3070 |
else |
| 3071 |
raise EJclCompressionError.CreateRes(@RsCompressionGZipNotDecompressed); |
| 3072 |
end; |
| 3073 |
|
| 3074 |
function TJclGZIPDecompressionStream.GetDosTime: TDateTime; |
| 3075 |
begin |
| 3076 |
Result := UnixTimeToDateTime(FHeader.ModifiedTime); |
| 3077 |
end; |
| 3078 |
|
| 3079 |
function TJclGZIPDecompressionStream.GetFatSystem: TJclGZIPFatSystem; |
| 3080 |
const |
| 3081 |
ByteToFatSystem: array [JCL_GZIP_OS_FAT..JCL_GZIP_OS_ACORN] of TJclGZIPFatSystem = |
| 3082 |
(gfsFat, gfsAmiga, gfsVMS, gfsUnix, gfsVM, gfsAtari, gfsHPFS, gfsMac, gfsZ, |
| 3083 |
gfsCPM, gfsTOPS, gfsNTFS, gfsQDOS, gfsAcorn); |
| 3084 |
begin |
| 3085 |
case FHeader.OS of |
| 3086 |
JCL_GZIP_OS_FAT..JCL_GZIP_OS_ACORN: |
| 3087 |
Result := ByteToFatSystem[FHeader.OS]; |
| 3088 |
JCL_GZIP_OS_UNKNOWN: |
| 3089 |
Result := gfsUnknown; |
| 3090 |
else |
| 3091 |
Result := gfsOther; |
| 3092 |
end; |
| 3093 |
end; |
| 3094 |
|
| 3095 |
function TJclGZIPDecompressionStream.GetFlags: TJclGZIPFlags; |
| 3096 |
begin |
| 3097 |
Result := []; |
| 3098 |
if (FHeader.Flags and JCL_GZIP_FLAG_TEXT) <> 0 then |
| 3099 |
Result := Result + [gfDataIsText]; |
| 3100 |
if (FHeader.Flags and JCL_GZIP_FLAG_CRC) <> 0 then |
| 3101 |
Result := Result + [gfHeaderCRC16]; |
| 3102 |
if (FHeader.Flags and JCL_GZIP_FLAG_EXTRA) <> 0 then |
| 3103 |
Result := Result + [gfExtraField]; |
| 3104 |
if (FHeader.Flags and JCL_GZIP_FLAG_NAME) <> 0 then |
| 3105 |
Result := Result + [gfOriginalFileName]; |
| 3106 |
if (FHeader.Flags and JCL_GZIP_FLAG_COMMENT) <> 0 then |
| 3107 |
Result := Result + [gfComment]; |
| 3108 |
end; |
| 3109 |
|
| 3110 |
function TJclGZIPDecompressionStream.GetOriginalDataSize: Cardinal; |
| 3111 |
var |
| 3112 |
StartPos: Int64; |
| 3113 |
AFooter: TJclGZIPFooter; |
| 3114 |
begin |
| 3115 |
if not FDataStarted then |
| 3116 |
begin |
| 3117 |
StartPos := FStream.Position; |
| 3118 |
try |
| 3119 |
FStream.Seek(-SizeOf(AFooter), soEnd); |
| 3120 |
AFooter.DataCRC32 := 0; |
| 3121 |
AFooter.DataSize := 0; |
| 3122 |
FStream.ReadBuffer(AFooter, SizeOf(AFooter)); |
| 3123 |
Result := AFooter.DataSize; |
| 3124 |
finally |
| 3125 |
FStream.Seek(StartPos, soBeginning); |
| 3126 |
end; |
| 3127 |
end |
| 3128 |
else |
| 3129 |
if FDataEnded then |
| 3130 |
Result := FFooter.DataSize |
| 3131 |
else |
| 3132 |
raise EJclCompressionError.CreateRes(@RsCompressionGZipDecompressing); |
| 3133 |
end; |
| 3134 |
|
| 3135 |
function TJclGZIPDecompressionStream.GetStoredDataCRC32: Cardinal; |
| 3136 |
var |
| 3137 |
StartPos: Int64; |
| 3138 |
AFooter: TJclGZIPFooter; |
| 3139 |
begin |
| 3140 |
if not FDataStarted then |
| 3141 |
begin |
| 3142 |
StartPos := FStream.Position; |
| 3143 |
try |
| 3144 |
FStream.Seek(-SizeOf(AFooter), soEnd); |
| 3145 |
AFooter.DataSize := 0; |
| 3146 |
AFooter.DataCRC32 := 0; |
| 3147 |
FStream.ReadBuffer(AFooter, SizeOf(AFooter)); |
| 3148 |
Result := AFooter.DataCRC32; |
| 3149 |
finally |
| 3150 |
FStream.Seek(StartPos, soBeginning); |
| 3151 |
end; |
| 3152 |
end |
| 3153 |
else |
| 3154 |
if FDataEnded then |
| 3155 |
Result := FFooter.DataCRC32 |
| 3156 |
else |
| 3157 |
raise EJclCompressionError.CreateRes(@RsCompressionGZipDecompressing); |
| 3158 |
end; |
| 3159 |
|
| 3160 |
function TJclGZIPDecompressionStream.Read(var Buffer; Count: Longint): Longint; |
| 3161 |
begin |
| 3162 |
if not Assigned(FZLibStream) then |
| 3163 |
begin |
| 3164 |
FCompressedDataStream := TJclDelegatedStream.Create; |
| 3165 |
FCompressedDataStream.OnRead := ReadCompressedData; |
| 3166 |
FZLibStream := TJclZLibDecompressStream.Create(FCompressedDataStream, -DEF_WBITS); |
| 3167 |
FZLibStream.OnProgress := ZLibStreamProgress; |
| 3168 |
end; |
| 3169 |
Result := FZLibStream.Read(Buffer, Count); |
| 3170 |
Inc(FDataSize, Result); |
| 3171 |
FComputedDataCRC32 := crc32(FComputedDataCRC32, @Byte(Buffer), Result); |
| 3172 |
if Result < Count then |
| 3173 |
begin |
| 3174 |
if not FDataEnded then |
| 3175 |
// the decompressed stream is stopping before the compressed stream |
| 3176 |
raise EJclCompressionError.CreateRes(@RsCompressionGZipInternalError); |
| 3177 |
if AutoCheckDataCRC32 and (FComputedDataCRC32 <> FFooter.DataCRC32) then |
| 3178 |
raise EJclCompressionError.CreateRes(@RsCompressionGZipDataCRCFailed); |
| 3179 |
end; |
| 3180 |
end; |
| 3181 |
|
| 3182 |
function TJclGZIPDecompressionStream.ReadCompressedData(Sender: TObject; var Buffer; |
| 3183 |
Count: Longint): Longint; |
| 3184 |
var |
| 3185 |
BufferAddr: PAnsiChar; |
| 3186 |
FooterAddr: PAnsiChar; |
| 3187 |
begin |
| 3188 |
if (Count = 0) or FDataEnded then |
| 3189 |
begin |
| 3190 |
Result := 0; |
| 3191 |
Exit; |
| 3192 |
end |
| 3193 |
else |
| 3194 |
if not FDataStarted then |
| 3195 |
begin |
| 3196 |
FDataStarted := True; |
| 3197 |
// prolog |
| 3198 |
if FStream.Read(FFooter, SizeOf(FFooter)) < SizeOf(FFooter) then |
| 3199 |
raise EJclCompressionError.CreateRes(@RsCompressionGZipDataTruncated); |
| 3200 |
end; |
| 3201 |
|
| 3202 |
BufferAddr := @Byte(Buffer); |
| 3203 |
Move(FFooter, Buffer, SizeOf(FFooter)); |
| 3204 |
Result := FStream.Read(BufferAddr[SizeOf(FFooter)], Count - SizeOf(FFooter)) |
| 3205 |
+ FStream.Read(FFooter, SizeOf(FFooter)); |
| 3206 |
|
| 3207 |
if Result < Count then |
| 3208 |
begin |
| 3209 |
FDataEnded := True; |
| 3210 |
// epilog |
| 3211 |
FooterAddr := @FFooter; |
| 3212 |
if (Count - Result) < SizeOf(FFooter) then |
| 3213 |
begin |
| 3214 |
// the "real" footer is splitted in the data and the footer |
| 3215 |
// shift the valid bytes of the footer to their place |
| 3216 |
Move(FFooter, FooterAddr[Count - Result], SizeOf(FFooter) - Count + Result); |
| 3217 |
// the missing bytes of the footer are located after the data |
| 3218 |
Move(BufferAddr[Result], FFooter, Count - Result); |
| 3219 |
end |
| 3220 |
else |
| 3221 |
// the "real" footer is located in the data |
| 3222 |
Move(BufferAddr[Result], FFooter, SizeOf(FFooter)); |
| 3223 |
end; |
| 3224 |
Inc(FCompressedDataSize, Result); |
| 3225 |
end; |
| 3226 |
|
| 3227 |
class function TJclGZIPDecompressionStream.StreamExtensions: string; |
| 3228 |
begin |
| 3229 |
Result := LoadResString(@RsCompressionGZipExtensions); |
| 3230 |
end; |
| 3231 |
|
| 3232 |
class function TJclGZIPDecompressionStream.StreamName: string; |
| 3233 |
begin |
| 3234 |
Result := LoadResString(@RsCompressionGZipName); |
| 3235 |
end; |
| 3236 |
|
| 3237 |
class function TJclGZIPDecompressionStream.StreamSubExtensions: string; |
| 3238 |
begin |
| 3239 |
Result := LoadResString(@RsCompressionGZipSubExtensions); |
| 3240 |
end; |
| 3241 |
|
| 3242 |
procedure TJclGZIPDecompressionStream.ZLibStreamProgress(Sender: TObject); |
| 3243 |
begin |
| 3244 |
Progress(Self); |
| 3245 |
end; |
| 3246 |
|
| 3247 |
//=== { TJclBZLibCompressionStream } ========================================= |
| 3248 |
|
| 3249 |
{ Error checking helper } |
| 3250 |
|
| 3251 |
function BZIP2LibCheck(const ErrCode: Integer): Integer; |
| 3252 |
begin |
| 3253 |
case ErrCode of |
| 3254 |
0..High(ErrCode): |
| 3255 |
Result := ErrCode; // no error |
| 3256 |
BZ_SEQUENCE_ERROR: |
| 3257 |
raise EJclCompressionError.CreateRes(@RsCompressionBZIP2SequenceError); |
| 3258 |
BZ_PARAM_ERROR: |
| 3259 |
raise EJclCompressionError.CreateRes(@RsCompressionBZIP2ParameterError); |
| 3260 |
BZ_MEM_ERROR: |
| 3261 |
raise EJclCompressionError.CreateRes(@RsCompressionBZIP2MemoryError); |
| 3262 |
BZ_DATA_ERROR: |
| 3263 |
raise EJclCompressionError.CreateRes(@RsCompressionBZIP2DataError); |
| 3264 |
BZ_DATA_ERROR_MAGIC: |
| 3265 |
raise EJclCompressionError.CreateRes(@RsCompressionBZIP2HeaderError); |
| 3266 |
BZ_IO_ERROR: |
| 3267 |
raise EJclCompressionError.CreateRes(@RsCompressionBZIP2IOError); |
| 3268 |
BZ_UNEXPECTED_EOF: |
| 3269 |
raise EJclCompressionError.CreateRes(@RsCompressionBZIP2EOFError); |
| 3270 |
BZ_OUTBUFF_FULL: |
| 3271 |
raise EJclCompressionError.CreateRes(@RsCompressionBZIP2OutBuffError); |
| 3272 |
BZ_CONFIG_ERROR: |
| 3273 |
raise EJclCompressionError.CreateRes(@RsCompressionBZIP2ConfigError); |
| 3274 |
else |
| 3275 |
raise EJclCompressionError.CreateResFmt(@RsCompressionBZIP2Error, [ErrCode]); |
| 3276 |
end; |
| 3277 |
end; |
| 3278 |
|
| 3279 |
constructor TJclBZIP2CompressionStream.Create(Destination: TStream; ACompressionLevel: TJclCompressionLevel); |
| 3280 |
begin |
| 3281 |
inherited Create(Destination); |
| 3282 |
|
| 3283 |
LoadBZip2; |
| 3284 |
|
| 3285 |
Assert(FBuffer <> nil); |
| 3286 |
Assert(FBufferSize > 0); |
| 3287 |
|
| 3288 |
// Initialize ZLib StreamRecord |
| 3289 |
BZLibRecord.bzalloc := nil; // Use build-in memory allocation functionality |
| 3290 |
BZLibRecord.bzfree := nil; |
| 3291 |
BZLibRecord.next_in := nil; |
| 3292 |
BZLibRecord.avail_in := 0; |
| 3293 |
BZLibRecord.next_out := FBuffer; |
| 3294 |
BZLibRecord.avail_out := FBufferSize; |
| 3295 |
|
| 3296 |
FDeflateInitialized := False; |
| 3297 |
|
| 3298 |
FCompressionLevel := ACompressionLevel; |
| 3299 |
end; |
| 3300 |
|
| 3301 |
destructor TJclBZIP2CompressionStream.Destroy; |
| 3302 |
begin |
| 3303 |
Flush; |
| 3304 |
if FDeflateInitialized then |
| 3305 |
BZIP2LibCheck(BZ2_bzCompressEnd(BZLibRecord)); |
| 3306 |
|
| 3307 |
inherited Destroy; |
| 3308 |
end; |
| 3309 |
|
| 3310 |
function TJclBZIP2CompressionStream.Flush: Integer; |
| 3311 |
begin |
| 3312 |
Result := 0; |
| 3313 |
|
| 3314 |
if FDeflateInitialized then |
| 3315 |
begin |
| 3316 |
BZLibRecord.next_in := nil; |
| 3317 |
BZLibRecord.avail_in := 0; |
| 3318 |
|
| 3319 |
while (BZIP2LibCheck(BZ2_bzCompress(BZLibRecord, BZ_FINISH)) <> BZ_STREAM_END) and (BZLibRecord.avail_out = 0) do |
| 3320 |
begin |
| 3321 |
FStream.WriteBuffer(FBuffer^, FBufferSize); |
| 3322 |
Progress(Self); |
| 3323 |
|
| 3324 |
BZLibRecord.next_out := FBuffer; |
| 3325 |
BZLibRecord.avail_out := FBufferSize; |
| 3326 |
Inc(Result, FBufferSize); |
| 3327 |
end; |
| 3328 |
|
| 3329 |
if BZLibRecord.avail_out < FBufferSize then |
| 3330 |
begin |
| 3331 |
FStream.WriteBuffer(FBuffer^, FBufferSize - BZLibRecord.avail_out); |
| 3332 |
Progress(Self); |
| 3333 |
Inc(Result, FBufferSize - BZLibRecord.avail_out); |
| 3334 |
BZLibRecord.next_out := FBuffer; |
| 3335 |
BZLibRecord.avail_out := FBufferSize; |
| 3336 |
end; |
| 3337 |
end; |
| 3338 |
end; |
| 3339 |
|
| 3340 |
function TJclBZIP2CompressionStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; |
| 3341 |
begin |
| 3342 |
if (Offset = 0) and (Origin = soCurrent) then |
| 3343 |
Result := (BZLibRecord.total_in_hi32 shl 32) or BZLibRecord.total_in_lo32 |
| 3344 |
else |
| 3345 |
if (Offset = 0) and (Origin = soBeginning) and (BZLibRecord.total_in_lo32 = 0) then |
| 3346 |
Result := 0 |
| 3347 |
else |
| 3348 |
Result := inherited Seek(Offset, Origin); |
| 3349 |
end; |
| 3350 |
|
| 3351 |
procedure TJclBZIP2CompressionStream.SetCompressionLevel(const Value: Integer); |
| 3352 |
begin |
| 3353 |
if not FDeflateInitialized then |
| 3354 |
FCompressionLevel := Value |
| 3355 |
else |
| 3356 |
raise EJclCompressionError.CreateRes(@RsCompressionBZIP2SequenceError); |
| 3357 |
end; |
| 3358 |
|
| 3359 |
class function TJclBZIP2CompressionStream.StreamExtensions: string; |
| 3360 |
begin |
| 3361 |
Result := LoadResString(@RsCompressionBZip2Extensions); |
| 3362 |
end; |
| 3363 |
|
| 3364 |
class function TJclBZIP2CompressionStream.StreamName: string; |
| 3365 |
begin |
| 3366 |
Result := LoadResString(@RsCompressionBZip2Name); |
| 3367 |
end; |
| 3368 |
|
| 3369 |
class function TJclBZIP2CompressionStream.StreamSubExtensions: string; |
| 3370 |
begin |
| 3371 |
Result := LoadResString(@RsCompressionBZip2SubExtensions); |
| 3372 |
end; |
| 3373 |
|
| 3374 |
function TJclBZIP2CompressionStream.Write(const Buffer; Count: Longint): Longint; |
| 3375 |
begin |
| 3376 |
if not FDeflateInitialized then |
| 3377 |
begin |
| 3378 |
BZIP2LibCheck(BZ2_bzCompressInit(BZLibRecord, FCompressionLevel, 0, 0)); |
| 3379 |
FDeflateInitialized := True; |
| 3380 |
end; |
| 3381 |
|
| 3382 |
BZLibRecord.next_in := @Buffer; |
| 3383 |
BZLibRecord.avail_in := Count; |
| 3384 |
|
| 3385 |
while BZLibRecord.avail_in > 0 do |
| 3386 |
begin |
| 3387 |
BZIP2LibCheck(BZ2_bzCompress(BZLibRecord, BZ_RUN)); |
| 3388 |
|
| 3389 |
if BZLibRecord.avail_out = 0 then // Output buffer empty. Write to stream and go on... |
| 3390 |
begin |
| 3391 |
FStream.WriteBuffer(FBuffer^, FBufferSize); |
| 3392 |
Progress(Self); |
| 3393 |
BZLibRecord.next_out := FBuffer; |
| 3394 |
BZLibRecord.avail_out := FBufferSize; |
| 3395 |
end; |
| 3396 |
end; |
| 3397 |
|
| 3398 |
Result := Count; |
| 3399 |
end; |
| 3400 |
|
| 3401 |
//=== { TJclBZip2DecompressionStream } ======================================= |
| 3402 |
|
| 3403 |
constructor TJclBZIP2DecompressionStream.Create(Source: TStream; AOwnsStream: Boolean); |
| 3404 |
begin |
| 3405 |
inherited Create(Source, AOwnsStream); |
| 3406 |
|
| 3407 |
LoadBZip2; |
| 3408 |
|
| 3409 |
// Initialize ZLib StreamRecord |
| 3410 |
BZLibRecord.bzalloc := nil; // Use build-in memory allocation functionality |
| 3411 |
BZLibRecord.bzfree := nil; |
| 3412 |
BZLibRecord.opaque := nil; |
| 3413 |
BZLibRecord.next_in := nil; |
| 3414 |
BZLibRecord.state := nil; |
| 3415 |
BZLibRecord.avail_in := 0; |
| 3416 |
BZLibRecord.next_out := FBuffer; |
| 3417 |
BZLibRecord.avail_out := FBufferSize; |
| 3418 |
|
| 3419 |
FInflateInitialized := False; |
| 3420 |
end; |
| 3421 |
|
| 3422 |
destructor TJclBZIP2DecompressionStream.Destroy; |
| 3423 |
begin |
| 3424 |
if FInflateInitialized then |
| 3425 |
begin |
| 3426 |
FStream.Seek(-BZLibRecord.avail_in, soCurrent); |
| 3427 |
BZIP2LibCheck(BZ2_bzDecompressEnd(BZLibRecord)); |
| 3428 |
end; |
| 3429 |
|
| 3430 |
inherited Destroy; |
| 3431 |
end; |
| 3432 |
|
| 3433 |
function TJclBZIP2DecompressionStream.Read(var Buffer; Count: Longint): Longint; |
| 3434 |
begin |
| 3435 |
if not FInflateInitialized then |
| 3436 |
begin |
| 3437 |
BZIP2LibCheck(BZ2_bzDecompressInit(BZLibRecord, 0, 0)); |
| 3438 |
FInflateInitialized := True; |
| 3439 |
end; |
| 3440 |
|
| 3441 |
BZLibRecord.next_out := @Buffer; |
| 3442 |
BZLibRecord.avail_out := Count; |
| 3443 |
Result := 0; |
| 3444 |
|
| 3445 |
while Result < Count do // as long as we need data |
| 3446 |
begin |
| 3447 |
if BZLibRecord.avail_in = 0 then // no more compressed data |
| 3448 |
begin |
| 3449 |
BZLibRecord.avail_in := FStream.Read(FBuffer^, FBufferSize); |
| 3450 |
if BZLibRecord.avail_in = 0 then |
| 3451 |
Exit; |
| 3452 |
|
| 3453 |
BZLibRecord.next_in := FBuffer; |
| 3454 |
end; |
| 3455 |
|
| 3456 |
if BZLibRecord.avail_in > 0 then |
| 3457 |
begin |
| 3458 |
BZIP2LibCheck(BZ2_bzDecompress(BZLibRecord)); |
| 3459 |
Result := Count; |
| 3460 |
Dec(Result, BZLibRecord.avail_out); |
| 3461 |
end |
| 3462 |
end; |
| 3463 |
|
| 3464 |
Result := Count; |
| 3465 |
end; |
| 3466 |
|
| 3467 |
function TJclBZIP2DecompressionStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; |
| 3468 |
begin |
| 3469 |
if (Offset = 0) and (Origin = soCurrent) then |
| 3470 |
Result := (BZLibRecord.total_out_hi32 shl 32) or BZLibRecord.total_out_lo32 |
| 3471 |
else |
| 3472 |
Result := inherited Seek(Offset, Origin); |
| 3473 |
end; |
| 3474 |
|
| 3475 |
class function TJclBZIP2DecompressionStream.StreamExtensions: string; |
| 3476 |
begin |
| 3477 |
Result := LoadResString(@RsCompressionBZip2Extensions); |
| 3478 |
end; |
| 3479 |
|
| 3480 |
class function TJclBZIP2DecompressionStream.StreamName: string; |
| 3481 |
begin |
| 3482 |
Result := LoadResString(@RsCompressionBZip2Name); |
| 3483 |
end; |
| 3484 |
|
| 3485 |
class function TJclBZIP2DecompressionStream.StreamSubExtensions: string; |
| 3486 |
begin |
| 3487 |
Result := LoadResString(@RsCompressionBZip2SubExtensions); |
| 3488 |
end; |
| 3489 |
|
| 3490 |
procedure InternalCompress(SourceStream: TStream; CompressStream: TJclCompressStream; |
| 3491 |
ProgressCallback: TJclCompressStreamProgressCallback; UserData: Pointer); |
| 3492 |
var |
| 3493 |
SourceStreamSize, SourceStreamPosition: Int64; |
| 3494 |
Buffer: Pointer; |
| 3495 |
ReadBytes: Integer; |
| 3496 |
EofFlag: Boolean; |
| 3497 |
begin |
| 3498 |
SourceStreamSize := SourceStream.Size; // source file size |
| 3499 |
SourceStreamPosition := 0; |
| 3500 |
|
| 3501 |
GetMem(Buffer, JclDefaultBufferSize + 2); |
| 3502 |
try |
| 3503 |
// ZLibStream.CopyFrom(SourceStream, 0 ); // One line way to do it! may not |
| 3504 |
// // be reliable idea to do this! also, |
| 3505 |
// //no progress callbacks! |
| 3506 |
EofFlag := False; |
| 3507 |
while not EofFlag do |
| 3508 |
begin |
| 3509 |
if Assigned(ProgressCallback) then |
| 3510 |
ProgressCallback(SourceStreamSize, SourceStreamPosition, UserData); |
| 3511 |
|
| 3512 |
ReadBytes := SourceStream.Read(Buffer^, JclDefaultBufferSize); |
| 3513 |
SourceStreamPosition := SourceStreamPosition + ReadBytes; |
| 3514 |
|
| 3515 |
CompressStream.WriteBuffer(Buffer^, ReadBytes); |
| 3516 |
|
| 3517 |
// short block indicates end of zlib stream |
| 3518 |
EofFlag := ReadBytes < JclDefaultBufferSize; |
| 3519 |
end; |
| 3520 |
//CompressStream.Flush; (called by the destructor of compression streams |
| 3521 |
finally |
| 3522 |
FreeMem(Buffer); |
| 3523 |
end; |
| 3524 |
if Assigned(ProgressCallback) then |
| 3525 |
ProgressCallback(SourceStreamSize, SourceStreamPosition, UserData); |
| 3526 |
end; |
| 3527 |
|
| 3528 |
procedure InternalDecompress(SourceStream, DestStream: TStream; |
| 3529 |
DecompressStream: TJclDecompressStream; |
| 3530 |
ProgressCallback: TJclCompressStreamProgressCallback; UserData: Pointer); |
| 3531 |
var |
| 3532 |
SourceStreamSize: Int64; |
| 3533 |
Buffer: Pointer; |
| 3534 |
ReadBytes: Integer; |
| 3535 |
EofFlag: Boolean; |
| 3536 |
begin |
| 3537 |
SourceStreamSize := SourceStream.Size; // source file size |
| 3538 |
|
| 3539 |
GetMem(Buffer, JclDefaultBufferSize + 2); |
| 3540 |
try |
| 3541 |
// ZLibStream.CopyFrom(SourceStream, 0 ); // One line way to do it! may not |
| 3542 |
// // be reliable idea to do this! also, |
| 3543 |
// //no progress callbacks! |
| 3544 |
EofFlag := False; |
| 3545 |
while not EofFlag do |
| 3546 |
begin |
| 3547 |
if Assigned(ProgressCallback) then |
| 3548 |
ProgressCallback(SourceStreamSize, SourceStream.Position, UserData); |
| 3549 |
|
| 3550 |
ReadBytes := DecompressStream.Read(Buffer^, JclDefaultBufferSize); |
| 3551 |
|
| 3552 |
DestStream.WriteBuffer(Buffer^, ReadBytes); |
| 3553 |
|
| 3554 |
// short block indicates end of zlib stream |
| 3555 |
EofFlag := ReadBytes < JclDefaultBufferSize; |
| 3556 |
end; |
| 3557 |
finally |
| 3558 |
FreeMem(Buffer); |
| 3559 |
end; |
| 3560 |
if Assigned(ProgressCallback) then |
| 3561 |
ProgressCallback(SourceStreamSize, SourceStream.Position, UserData); |
| 3562 |
end; |
| 3563 |
|
| 3564 |
{ Compress to a .gz file - one liner - NEW MARCH 2007 } |
| 3565 |
|
| 3566 |
function GZipFile(SourceFile, DestinationFile: TFileName; CompressionLevel: Integer; |
| 3567 |
ProgressCallback: TJclCompressStreamProgressCallback; UserData: Pointer): Boolean; |
| 3568 |
var |
| 3569 |
GZipStream: TJclGZIPCompressionStream; |
| 3570 |
DestStream: TFileStream; |
| 3571 |
SourceStream: TFileStream; |
| 3572 |
GZipStreamDateTime: TDateTime; |
| 3573 |
begin |
| 3574 |
Result := False; |
| 3575 |
if not FileExists(SourceFile) then // can't copy what doesn't exist! |
| 3576 |
Exit; |
| 3577 |
|
| 3578 |
GetFileLastWrite(SourceFile, GZipStreamDateTime); |
| 3579 |
|
| 3580 |
{destination and source streams first and second} |
| 3581 |
SourceStream := TFileStream.Create(SourceFile, fmOpenRead or fmShareDenyWrite); |
| 3582 |
try |
| 3583 |
DestStream := TFileStream.Create(DestinationFile, fmCreate); // see SysUtils |
| 3584 |
try |
| 3585 |
{ create compressionstream third, and copy from source, |
| 3586 |
through zlib compress layer, |
| 3587 |
out through file stream} |
| 3588 |
GZipStream := TJclGZIPCompressionStream.Create(DestStream, CompressionLevel); |
| 3589 |
try |
| 3590 |
GZipStream.DosTime := GZipStreamDateTime; |
| 3591 |
InternalCompress(SourceStream, GZipStream, ProgressCallback, UserData); |
| 3592 |
finally |
| 3593 |
GZipStream.Free; |
| 3594 |
end; |
| 3595 |
finally |
| 3596 |
DestStream.Free; |
| 3597 |
end; |
| 3598 |
finally |
| 3599 |
SourceStream.Free; |
| 3600 |
end; |
| 3601 |
Result := FileExists(DestinationFile); |
| 3602 |
end; |
| 3603 |
|
| 3604 |
{ Decompress a .gz file } |
| 3605 |
|
| 3606 |
function UnGZipFile(SourceFile, DestinationFile: TFileName; |
| 3607 |
ProgressCallback: TJclCompressStreamProgressCallback; UserData: Pointer): Boolean; |
| 3608 |
var |
| 3609 |
GZipStream: TJclGZIPDecompressionStream; |
| 3610 |
DestStream: TFileStream; |
| 3611 |
SourceStream: TFileStream; |
| 3612 |
GZipStreamDateTime: TDateTime; |
| 3613 |
begin |
| 3614 |
Result := False; |
| 3615 |
if not FileExists(SourceFile) then // can't copy what doesn't exist! |
| 3616 |
Exit; |
| 3617 |
|
| 3618 |
{destination and source streams first and second} |
| 3619 |
SourceStream := TFileStream.Create(SourceFile, {mode} fmOpenRead or fmShareDenyWrite); |
| 3620 |
try |
| 3621 |
DestStream := TFileStream.Create(DestinationFile, {mode} fmCreate); // see SysUtils |
| 3622 |
try |
| 3623 |
{ create decompressionstream third, and copy from source, |
| 3624 |
through zlib decompress layer, out through file stream |
| 3625 |
} |
| 3626 |
GZipStream := TJclGZIPDecompressionStream.Create(SourceStream); |
| 3627 |
try |
| 3628 |
InternalDecompress(SourceStream, DestStream, GZipStream, ProgressCallback, UserData); |
| 3629 |
GZipStreamDateTime := GZipStream.DosTime; |
| 3630 |
finally |
| 3631 |
GZipStream.Free; |
| 3632 |
end; |
| 3633 |
finally |
| 3634 |
DestStream.Free; |
| 3635 |
end; |
| 3636 |
finally |
| 3637 |
SourceStream.Free; |
| 3638 |
end; |
| 3639 |
Result := FileExists(DestinationFile); |
| 3640 |
if Result and (GZipStreamDateTime <> 0) then |
| 3641 |
// preserve datetime when unpacking! (see JclFileUtils) |
| 3642 |
SetFileLastWrite(DestinationFile, GZipStreamDateTime); |
| 3643 |
end; |
| 3644 |
|
| 3645 |
procedure GZipStream(SourceStream, DestinationStream: TStream; CompressionLevel: Integer = Z_DEFAULT_COMPRESSION; |
| 3646 |
ProgressCallback: TJclCompressStreamProgressCallback = nil; UserData: Pointer = nil); |
| 3647 |
var |
| 3648 |
GZStream: TJclGZIPCompressionStream; |
| 3649 |
begin |
| 3650 |
GZStream := TJclGZIPCompressionStream.Create(DestinationStream, CompressionLevel); |
| 3651 |
try |
| 3652 |
InternalCompress(SourceStream, GZStream, ProgressCallback, UserData); |
| 3653 |
finally |
| 3654 |
GZStream.Free; |
| 3655 |
end; |
| 3656 |
end; |
| 3657 |
|
| 3658 |
procedure UnGZipStream(SourceStream, DestinationStream: TStream; |
| 3659 |
ProgressCallback: TJclCompressStreamProgressCallback = nil; UserData: Pointer = nil); |
| 3660 |
var |
| 3661 |
GZipStream: TJclGZIPDecompressionStream; |
| 3662 |
begin |
| 3663 |
GZipStream := TJclGZIPDecompressionStream.Create(SourceStream); |
| 3664 |
try |
| 3665 |
InternalDecompress(SourceStream, DestinationStream, GZipStream, ProgressCallback, UserData); |
| 3666 |
finally |
| 3667 |
GZipStream.Free; |
| 3668 |
end; |
| 3669 |
end; |
| 3670 |
|
| 3671 |
{ Compress to a .bz2 file - one liner } |
| 3672 |
|
| 3673 |
function BZip2File(SourceFile, DestinationFile: TFileName; CompressionLevel: Integer; |
| 3674 |
ProgressCallback: TJclCompressStreamProgressCallback; UserData: Pointer): Boolean; |
| 3675 |
var |
| 3676 |
BZip2Stream: TJclBZIP2CompressionStream; |
| 3677 |
DestStream: TFileStream; |
| 3678 |
SourceStream: TFileStream; |
| 3679 |
begin |
| 3680 |
Result := False; |
| 3681 |
if not FileExists(SourceFile) then // can't copy what doesn't exist! |
| 3682 |
Exit; |
| 3683 |
|
| 3684 |
{destination and source streams first and second} |
| 3685 |
SourceStream := TFileStream.Create(SourceFile, fmOpenRead or fmShareDenyWrite); |
| 3686 |
try |
| 3687 |
DestStream := TFileStream.Create(DestinationFile, fmCreate); // see SysUtils |
| 3688 |
try |
| 3689 |
{ create compressionstream third, and copy from source, |
| 3690 |
through zlib compress layer, |
| 3691 |
out through file stream} |
| 3692 |
BZip2Stream := TJclBZIP2CompressionStream.Create(DestStream, CompressionLevel); |
| 3693 |
try |
| 3694 |
InternalCompress(SourceStream, BZip2Stream, ProgressCallback, UserData); |
| 3695 |
finally |
| 3696 |
BZip2Stream.Free; |
| 3697 |
end; |
| 3698 |
finally |
| 3699 |
DestStream.Free; |
| 3700 |
end; |
| 3701 |
finally |
| 3702 |
SourceStream.Free; |
| 3703 |
end; |
| 3704 |
Result := FileExists(DestinationFile); |
| 3705 |
end; |
| 3706 |
|
| 3707 |
{ Decompress a .bzip2 file } |
| 3708 |
|
| 3709 |
function UnBZip2File(SourceFile, DestinationFile: TFileName; |
| 3710 |
ProgressCallback: TJclCompressStreamProgressCallback; UserData: Pointer): Boolean; |
| 3711 |
var |
| 3712 |
BZip2Stream: TJclBZIP2DecompressionStream; |
| 3713 |
DestStream: TFileStream; |
| 3714 |
SourceStream: TFileStream; |
| 3715 |
begin |
| 3716 |
Result := False; |
| 3717 |
if not FileExists(SourceFile) then // can't copy what doesn't exist! |
| 3718 |
Exit; |
| 3719 |
|
| 3720 |
{destination and source streams first and second} |
| 3721 |
SourceStream := TFileStream.Create(SourceFile, {mode} fmOpenRead or fmShareDenyWrite); |
| 3722 |
try |
| 3723 |
DestStream := TFileStream.Create(DestinationFile, {mode} fmCreate); // see SysUtils |
| 3724 |
try |
| 3725 |
{ create decompressionstream third, and copy from source, |
| 3726 |
through zlib decompress layer, out through file stream |
| 3727 |
} |
| 3728 |
BZip2Stream := TJclBZIP2DecompressionStream.Create(SourceStream); |
| 3729 |
try |
| 3730 |
InternalDecompress(SourceStream, DestStream, BZip2Stream, ProgressCallback, UserData); |
| 3731 |
finally |
| 3732 |
BZip2Stream.Free; |
| 3733 |
end; |
| 3734 |
finally |
| 3735 |
DestStream.Free; |
| 3736 |
end; |
| 3737 |
finally |
| 3738 |
SourceStream.Free; |
| 3739 |
end; |
| 3740 |
Result := FileExists(DestinationFile); |
| 3741 |
end; |
| 3742 |
|
| 3743 |
procedure BZip2Stream(SourceStream, DestinationStream: TStream; CompressionLevel: Integer = 5; |
| 3744 |
ProgressCallback: TJclCompressStreamProgressCallback = nil; UserData: Pointer = nil); |
| 3745 |
var |
| 3746 |
BZ2Stream: TJclBZIP2CompressionStream; |
| 3747 |
begin |
| 3748 |
BZ2Stream := TJclBZIP2CompressionStream.Create(DestinationStream, CompressionLevel); |
| 3749 |
try |
| 3750 |
InternalCompress(SourceStream, BZ2Stream, ProgressCallback, UserData); |
| 3751 |
finally |
| 3752 |
BZ2Stream.Free; |
| 3753 |
end; |
| 3754 |
end; |
| 3755 |
|
| 3756 |
procedure UnBZip2Stream(SourceStream, DestinationStream: TStream; |
| 3757 |
ProgressCallback: TJclCompressStreamProgressCallback = nil; UserData: Pointer = nil); |
| 3758 |
var |
| 3759 |
BZip2Stream: TJclBZIP2DecompressionStream; |
| 3760 |
begin |
| 3761 |
BZip2Stream := TJclBZIP2DecompressionStream.Create(SourceStream); |
| 3762 |
try |
| 3763 |
InternalDecompress(SourceStream, DestinationStream, BZip2Stream, ProgressCallback, UserData); |
| 3764 |
finally |
| 3765 |
BZip2Stream.Free; |
| 3766 |
end; |
| 3767 |
end; |
| 3768 |
|
| 3769 |
{$ENDIF FPC} |
| 3770 |
|
| 3771 |
{$IFDEF MSWINDOWS} |
| 3772 |
|
| 3773 |
function OpenFileStream(const FileName: TFileName; StreamAccess: TJclStreamAccess): TStream; |
| 3774 |
begin |
| 3775 |
Result := nil; |
| 3776 |
case StreamAccess of |
| 3777 |
saCreate: |
| 3778 |
Result := TFileStream.Create(FileName, fmCreate); |
| 3779 |
saReadOnly: |
| 3780 |
if FileExists(FileName) then |
| 3781 |
Result := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); |
| 3782 |
saReadOnlyDenyNone: |
| 3783 |
if FileExists(FileName) then |
| 3784 |
Result := TFileStream.Create(FileName, fmOpenRead or fmShareDenyNone); |
| 3785 |
saWriteOnly: |
| 3786 |
if FileExists(FileName) then |
| 3787 |
Result := TFileStream.Create(FileName, fmOpenWrite) |
| 3788 |
else |
| 3789 |
if FileName <> '' then |
| 3790 |
Result := TFileStream.Create(FileName, fmCreate); |
| 3791 |
saReadWrite: |
| 3792 |
if FileExists(FileName) then |
| 3793 |
Result := TFileStream.Create(FileName, fmOpenReadWrite) |
| 3794 |
else |
| 3795 |
if FileName <> '' then |
| 3796 |
Result := TFileStream.Create(FileName, fmCreate); |
| 3797 |
end; |
| 3798 |
end; |
| 3799 |
|
| 3800 |
//=== { TJclCompressionItem } ================================================ |
| 3801 |
|
| 3802 |
constructor TJclCompressionItem.Create(AArchive: TJclCompressionArchive); |
| 3803 |
begin |
| 3804 |
inherited Create; |
| 3805 |
FArchive := AArchive; |
| 3806 |
FPackedIndex := $FFFFFFFF; |
| 3807 |
end; |
| 3808 |
|
| 3809 |
function TJclCompressionItem.DeleteOutputFile: Boolean; |
| 3810 |
begin |
| 3811 |
Result := (FFileName <> '') and FileExists(FFileName) and FileDelete(FFileName); |
| 3812 |
end; |
| 3813 |
|
| 3814 |
destructor TJclCompressionItem.Destroy; |
| 3815 |
begin |
| 3816 |
ReleaseStream; |
| 3817 |
|
| 3818 |
inherited Destroy; |
| 3819 |
end; |
| 3820 |
|
| 3821 |
function TJclCompressionItem.GetAttributes: Cardinal; |
| 3822 |
begin |
| 3823 |
CheckGetProperty(ipAttributes); |
| 3824 |
Result := FAttributes; |
| 3825 |
end; |
| 3826 |
|
| 3827 |
function TJclCompressionItem.GetComment: WideString; |
| 3828 |
begin |
| 3829 |
CheckGetProperty(ipComment); |
| 3830 |
Result := FComment; |
| 3831 |
end; |
| 3832 |
|
| 3833 |
function TJclCompressionItem.GetCRC: Cardinal; |
| 3834 |
begin |
| 3835 |
CheckGetProperty(ipCRC); |
| 3836 |
Result := FCRC; |
| 3837 |
end; |
| 3838 |
|
| 3839 |
function TJclCompressionItem.GetCreationTime: TFileTime; |
| 3840 |
begin |
| 3841 |
CheckGetProperty(ipCreationTime); |
| 3842 |
Result := FCreationTime; |
| 3843 |
end; |
| 3844 |
|
| 3845 |
function TJclCompressionItem.GetDirectory: Boolean; |
| 3846 |
begin |
| 3847 |
Result := (Attributes and FILE_ATTRIBUTE_DIRECTORY) <> 0; |
| 3848 |
end; |
| 3849 |
|
| 3850 |
function TJclCompressionItem.GetEncrypted: Boolean; |
| 3851 |
begin |
| 3852 |
CheckGetProperty(ipEncrypted); |
| 3853 |
Result := FEncrypted; |
| 3854 |
end; |
| 3855 |
|
| 3856 |
function TJclCompressionItem.GetFileName: TFileName; |
| 3857 |
begin |
| 3858 |
CheckGetProperty(ipFileName); |
| 3859 |
Result := FFileName; |
| 3860 |
end; |
| 3861 |
|
| 3862 |
function TJclCompressionItem.GetFileSize: Int64; |
| 3863 |
begin |
| 3864 |
CheckGetProperty(ipFileSize); |
| 3865 |
Result := FFileSize; |
| 3866 |
end; |
| 3867 |
|
| 3868 |
function TJclCompressionItem.GetGroup: WideString; |
| 3869 |
begin |
| 3870 |
CheckGetProperty(ipGroup); |
| 3871 |
Result := FGroup; |
| 3872 |
end; |
| 3873 |
|
| 3874 |
function TJclCompressionItem.GetHostFS: WideString; |
| 3875 |
begin |
| 3876 |
CheckGetProperty(ipHostFS); |
| 3877 |
Result := FHostFS; |
| 3878 |
end; |
| 3879 |
|
| 3880 |
function TJclCompressionItem.GetHostOS: WideString; |
| 3881 |
begin |
| 3882 |
CheckGetProperty(ipHostOS); |
| 3883 |
Result := FHostOS; |
| 3884 |
end; |
| 3885 |
|
| 3886 |
function TJclCompressionItem.GetItemKind: TJclCompressionItemKind; |
| 3887 |
begin |
| 3888 |
if (Attributes and FILE_ATTRIBUTE_DIRECTORY) <> 0 then |
| 3889 |
Result := ikDirectory |
| 3890 |
else |
| 3891 |
Result := ikFile; |
| 3892 |
end; |
| 3893 |
|
| 3894 |
function TJclCompressionItem.GetLastAccessTime: TFileTime; |
| 3895 |
begin |
| 3896 |
CheckGetProperty(ipLastAccessTime); |
| 3897 |
Result := FLastAccessTime; |
| 3898 |
end; |
| 3899 |
|
| 3900 |
function TJclCompressionItem.GetLastWriteTime: TFileTime; |
| 3901 |
begin |
| 3902 |
CheckGetProperty(ipLastWriteTime); |
| 3903 |
Result := FLastWriteTime; |
| 3904 |
end; |
| 3905 |
|
| 3906 |
function TJclCompressionItem.GetMethod: WideString; |
| 3907 |
begin |
| 3908 |
CheckGetProperty(ipMethod); |
| 3909 |
Result := FMethod; |
| 3910 |
end; |
| 3911 |
|
| 3912 |
function TJclCompressionItem.GetNestedArchiveName: WideString; |
| 3913 |
var |
| 3914 |
ParentArchiveExtension, ArchiveFileName, ArchiveExtension: WideString; |
| 3915 |
ExtensionMap: TStrings; |
| 3916 |
begin |
| 3917 |
if ipPackedName in ValidProperties then |
| 3918 |
Result := PackedName |
| 3919 |
else |
| 3920 |
begin |
| 3921 |
ArchiveFileName := ''; |
| 3922 |
ArchiveExtension := ''; |
| 3923 |
|
| 3924 |
// find archive file name |
| 3925 |
if Archive.VolumeCount > 0 then |
| 3926 |
ArchiveFileName := WideExtractFileName(WideString(Archive.Volumes[0].FileName)); |
| 3927 |
if (ArchiveFileName <> '') and (WideExtractFileExt(ArchiveFileName) = '.001') then |
| 3928 |
ArchiveFileName := WideChangeFileExt(ArchiveFileName, ''); |
| 3929 |
ParentArchiveExtension := WideExtractFileExt(ArchiveFileName); |
| 3930 |
ArchiveFileName := WideChangeFileExt(ArchiveFileName, ''); |
| 3931 |
|
| 3932 |
// find item extension |
| 3933 |
ArchiveExtension := WideExtractFileExt(ArchiveFileName); |
| 3934 |
if ArchiveExtension <> '' then |
| 3935 |
ArchiveFileName := WideChangeFileExt(ArchiveFileName, '') |
| 3936 |
else |
| 3937 |
if ipPackedExtension in ValidProperties then |
| 3938 |
ArchiveExtension := PackedExtension |
| 3939 |
else |
| 3940 |
if ArchiveFileName <> '' then |
| 3941 |
begin |
| 3942 |
ExtensionMap := TStringList.Create; |
| 3943 |
try |
| 3944 |
ExtensionMap.Delimiter := ';'; |
| 3945 |
ExtensionMap.DelimitedText := Archive.ArchiveSubExtensions; |
| 3946 |
ArchiveExtension := ExtensionMap.Values[ParentArchiveExtension]; |
| 3947 |
finally |
| 3948 |
ExtensionMap.Free; |
| 3949 |
end; |
| 3950 |
end; |
| 3951 |
|
| 3952 |
// elaborate result |
| 3953 |
if (ArchiveFileName = '') and (ArchiveExtension = '') then |
| 3954 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty) |
| 3955 |
else |
| 3956 |
if ArchiveFileName = '' then |
| 3957 |
Result := ArchiveExtension |
| 3958 |
else |
| 3959 |
Result := WideChangeFileExt(ArchiveFileName, ArchiveExtension); |
| 3960 |
end; |
| 3961 |
end; |
| 3962 |
|
| 3963 |
function TJclCompressionItem.GetNestedArchiveStream: TStream; |
| 3964 |
begin |
| 3965 |
raise EJclCompressionError.CreateRes(@RsCompressionNoNestedArchive); |
| 3966 |
end; |
| 3967 |
|
| 3968 |
function TJclCompressionItem.GetPackedExtension: WideString; |
| 3969 |
begin |
| 3970 |
CheckGetProperty(ipPackedExtension); |
| 3971 |
if FPackedName = '' then |
| 3972 |
Result := FPackedExtension |
| 3973 |
else |
| 3974 |
Result := WideExtractFileExt(FPackedName); |
| 3975 |
end; |
| 3976 |
|
| 3977 |
function TJclCompressionItem.GetPackedName: WideString; |
| 3978 |
begin |
| 3979 |
CheckGetProperty(ipPackedName); |
| 3980 |
Result := FPackedName; |
| 3981 |
end; |
| 3982 |
|
| 3983 |
function TJclCompressionItem.GetPackedSize: Int64; |
| 3984 |
begin |
| 3985 |
CheckGetProperty(ipPackedSize); |
| 3986 |
Result := FPackedSize; |
| 3987 |
end; |
| 3988 |
|
| 3989 |
function TJclCompressionItem.GetStream: TStream; |
| 3990 |
var |
| 3991 |
AItemAccess: TJclStreamAccess; |
| 3992 |
begin |
| 3993 |
if not Assigned(FStream) and (FileName <> '') then |
| 3994 |
begin |
| 3995 |
AItemAccess:= Archive.ItemAccess; |
| 3996 |
if (AItemAccess = saReadOnly) and JclCompressSharedFiles then |
| 3997 |
AItemAccess:= saReadOnlyDenyNone; |
| 3998 |
FStream := OpenFileStream(FileName, AItemAccess); |
| 3999 |
end; |
| 4000 |
|
| 4001 |
Result := FStream; |
| 4002 |
end; |
| 4003 |
|
| 4004 |
function TJclCompressionItem.GetUser: WideString; |
| 4005 |
begin |
| 4006 |
CheckGetProperty(ipUser); |
| 4007 |
Result := FUser; |
| 4008 |
end; |
| 4009 |
|
| 4010 |
procedure TJclCompressionItem.ReleaseStream; |
| 4011 |
begin |
| 4012 |
if OwnsStream or (FileName <> '') then |
| 4013 |
FreeAndNil(FStream); |
| 4014 |
end; |
| 4015 |
|
| 4016 |
procedure TJclCompressionItem.SetAttributes(Value: Cardinal); |
| 4017 |
begin |
| 4018 |
CheckSetProperty(ipAttributes); |
| 4019 |
FAttributes := Value; |
| 4020 |
Include(FModifiedProperties, ipAttributes); |
| 4021 |
Include(FValidProperties, ipAttributes); |
| 4022 |
end; |
| 4023 |
|
| 4024 |
procedure TJclCompressionItem.SetComment(const Value: WideString); |
| 4025 |
begin |
| 4026 |
CheckSetProperty(ipComment); |
| 4027 |
FComment := Value; |
| 4028 |
Include(FModifiedProperties, ipComment); |
| 4029 |
Include(FValidProperties, ipComment); |
| 4030 |
end; |
| 4031 |
|
| 4032 |
procedure TJclCompressionItem.SetCRC(Value: Cardinal); |
| 4033 |
begin |
| 4034 |
CheckSetProperty(ipCRC); |
| 4035 |
FCRC := Value; |
| 4036 |
Include(FModifiedProperties, ipCRC); |
| 4037 |
Include(FValidProperties, ipCRC); |
| 4038 |
end; |
| 4039 |
|
| 4040 |
procedure TJclCompressionItem.SetCreationTime(const Value: TFileTime); |
| 4041 |
begin |
| 4042 |
CheckSetProperty(ipCreationTime); |
| 4043 |
FCreationTime := Value; |
| 4044 |
Include(FModifiedProperties, ipCreationTime); |
| 4045 |
Include(FValidProperties, ipCreationTime); |
| 4046 |
end; |
| 4047 |
|
| 4048 |
procedure TJclCompressionItem.SetDirectory(Value: Boolean); |
| 4049 |
begin |
| 4050 |
CheckSetProperty(ipAttributes); |
| 4051 |
if Value then |
| 4052 |
FAttributes := FAttributes or FILE_ATTRIBUTE_DIRECTORY |
| 4053 |
else |
| 4054 |
FAttributes := FAttributes and (not FILE_ATTRIBUTE_DIRECTORY); |
| 4055 |
Include(FModifiedProperties, ipAttributes); |
| 4056 |
Include(FValidProperties, ipAttributes); |
| 4057 |
end; |
| 4058 |
|
| 4059 |
procedure TJclCompressionItem.SetEncrypted(Value: Boolean); |
| 4060 |
begin |
| 4061 |
CheckSetProperty(ipEncrypted); |
| 4062 |
FEncrypted := Value; |
| 4063 |
Include(FModifiedProperties, ipEncrypted); |
| 4064 |
Include(FValidProperties, ipEncrypted); |
| 4065 |
end; |
| 4066 |
|
| 4067 |
procedure TJclCompressionItem.SetFileName(const Value: TFileName); |
| 4068 |
var |
| 4069 |
AFindData: TWin32FindData; |
| 4070 |
begin |
| 4071 |
CheckSetProperty(ipFileName); |
| 4072 |
FFileName := Value; |
| 4073 |
if Value <> '' then |
| 4074 |
begin |
| 4075 |
Include(FModifiedProperties, ipFileName); |
| 4076 |
Include(FValidProperties, ipFileName); |
| 4077 |
end |
| 4078 |
else |
| 4079 |
begin |
| 4080 |
Exclude(FModifiedProperties, ipFileName); |
| 4081 |
Exclude(FValidProperties, ipFileName); |
| 4082 |
end; |
| 4083 |
|
| 4084 |
if (Value <> '') and (FArchive is TJclCompressionArchive) |
| 4085 |
and GetFileAttributesEx(PChar(Value), GetFileExInfoStandard, @AFindData) then |
| 4086 |
begin |
| 4087 |
FileSize := (Int64(AFindData.nFileSizeHigh) shl 32) or AFindData.nFileSizeLow; |
| 4088 |
Attributes := AFindData.dwFileAttributes; |
| 4089 |
CreationTime := AFindData.ftCreationTime; |
| 4090 |
LastAccessTime := AFindData.ftLastAccessTime; |
| 4091 |
LastWriteTime := AFindData.ftLastWriteTime; |
| 4092 |
// TODO: user name and group (using file handle and GetSecurityInfo) |
| 4093 |
{$IFDEF MSWINDOWS} |
| 4094 |
HostOS := LoadResString(@RsCompression7zWindows); |
| 4095 |
{$ENDIF MSWINDOWS} |
| 4096 |
{$IFDEF UNIX} |
| 4097 |
HostOS := LoadResString(@RsCompression7zUnix); |
| 4098 |
{$ENDIF UNIX} |
| 4099 |
end; |
| 4100 |
end; |
| 4101 |
|
| 4102 |
procedure TJclCompressionItem.SetFileSize(const Value: Int64); |
| 4103 |
begin |
| 4104 |
CheckSetProperty(ipFileSize); |
| 4105 |
FFileSize := Value; |
| 4106 |
Include(FModifiedProperties, ipFileSize); |
| 4107 |
Include(FValidProperties, ipFileSize); |
| 4108 |
end; |
| 4109 |
|
| 4110 |
procedure TJclCompressionItem.SetGroup(const Value: WideString); |
| 4111 |
begin |
| 4112 |
CheckSetProperty(ipGroup); |
| 4113 |
FGroup := Value; |
| 4114 |
Include(FModifiedProperties, ipGroup); |
| 4115 |
Include(FValidProperties, ipGroup); |
| 4116 |
end; |
| 4117 |
|
| 4118 |
procedure TJclCompressionItem.SetHostFS(const Value: WideString); |
| 4119 |
begin |
| 4120 |
CheckSetProperty(ipHostFS); |
| 4121 |
FHostFS := Value; |
| 4122 |
Include(FModifiedProperties, ipHostFS); |
| 4123 |
Include(FValidProperties, ipHostFS); |
| 4124 |
end; |
| 4125 |
|
| 4126 |
procedure TJclCompressionItem.SetHostOS(const Value: WideString); |
| 4127 |
begin |
| 4128 |
CheckSetProperty(ipHostOS); |
| 4129 |
FHostOS := Value; |
| 4130 |
Include(FModifiedProperties, ipHostOS); |
| 4131 |
Include(FValidProperties, ipHostOS); |
| 4132 |
end; |
| 4133 |
|
| 4134 |
procedure TJclCompressionItem.SetLastAccessTime(const Value: TFileTime); |
| 4135 |
begin |
| 4136 |
CheckSetProperty(ipLastAccessTime); |
| 4137 |
FLastAccessTime := Value; |
| 4138 |
Include(FModifiedProperties, ipLastAccessTime); |
| 4139 |
Include(FValidProperties, ipLastAccessTime); |
| 4140 |
end; |
| 4141 |
|
| 4142 |
procedure TJclCompressionItem.SetLastWriteTime(const Value: TFileTime); |
| 4143 |
begin |
| 4144 |
CheckSetProperty(ipLastWriteTime); |
| 4145 |
FLastWriteTime := Value; |
| 4146 |
Include(FModifiedProperties, ipLastWriteTime); |
| 4147 |
Include(FValidProperties, ipLastWriteTime); |
| 4148 |
end; |
| 4149 |
|
| 4150 |
procedure TJclCompressionItem.SetMethod(const Value: WideString); |
| 4151 |
begin |
| 4152 |
CheckSetProperty(ipMethod); |
| 4153 |
FMethod := Value; |
| 4154 |
Include(FModifiedProperties, ipMethod); |
| 4155 |
Include(FValidProperties, ipMethod); |
| 4156 |
end; |
| 4157 |
|
| 4158 |
procedure TJclCompressionItem.SetPackedExtension(const Value: WideString); |
| 4159 |
begin |
| 4160 |
CheckSetProperty(ipPackedExtension); |
| 4161 |
if (Value <> '') and (Value[1] <> '.') then |
| 4162 |
// force heading '.' |
| 4163 |
FPackedExtension := '.' + Value |
| 4164 |
else |
| 4165 |
FPackedExtension := Value; |
| 4166 |
Include(FModifiedProperties, ipPackedExtension); |
| 4167 |
Include(FValidProperties, ipPackedExtension); |
| 4168 |
end; |
| 4169 |
|
| 4170 |
procedure TJclCompressionItem.SetPackedName(const Value: WideString); |
| 4171 |
var |
| 4172 |
PackedNamesIndex: Integer; |
| 4173 |
begin |
| 4174 |
if FPackedName <> Value then |
| 4175 |
begin |
| 4176 |
CheckSetProperty(ipPackedName); |
| 4177 |
if FArchive is TJclCompressArchive then |
| 4178 |
begin |
| 4179 |
PackedNamesIndex := -1; |
| 4180 |
if (TJclCompressArchive(FArchive).FPackedNames <> nil) and |
| 4181 |
TJclCompressArchive(FArchive).FPackedNames.Find(FPackedName, PackedNamesIndex) then |
| 4182 |
begin |
| 4183 |
TJclCompressArchive(FArchive).FPackedNames.Delete(PackedNamesIndex); |
| 4184 |
try |
| 4185 |
TJclCompressArchive(FArchive).FPackedNames.Add(Value); |
| 4186 |
except |
| 4187 |
raise EJclCompressionError(Format(LoadResString(@RsCompressionDuplicate), [Value])); |
| 4188 |
end; |
| 4189 |
end; |
| 4190 |
end; |
| 4191 |
FPackedName := Value; |
| 4192 |
Include(FModifiedProperties, ipPackedName); |
| 4193 |
Include(FValidProperties, ipPackedName); |
| 4194 |
end; |
| 4195 |
end; |
| 4196 |
|
| 4197 |
procedure TJclCompressionItem.SetPackedSize(const Value: Int64); |
| 4198 |
begin |
| 4199 |
CheckSetProperty(ipPackedSize); |
| 4200 |
FPackedSize := Value; |
| 4201 |
Include(FModifiedProperties, ipPackedSize); |
| 4202 |
Include(FValidProperties, ipPackedSize); |
| 4203 |
end; |
| 4204 |
|
| 4205 |
procedure TJclCompressionItem.SetStream(const Value: TStream); |
| 4206 |
begin |
| 4207 |
CheckSetProperty(ipStream); |
| 4208 |
ReleaseStream; |
| 4209 |
FStream := Value; |
| 4210 |
if Value <> nil then begin |
| 4211 |
Include(FModifiedProperties, ipStream); |
| 4212 |
Include(FValidProperties, ipStream); |
| 4213 |
end |
| 4214 |
else begin |
| 4215 |
Exclude(FModifiedProperties, ipStream); |
| 4216 |
Exclude(FValidProperties, ipStream); |
| 4217 |
end; |
| 4218 |
end; |
| 4219 |
|
| 4220 |
procedure TJclCompressionItem.SetUser(const Value: WideString); |
| 4221 |
begin |
| 4222 |
CheckSetProperty(ipUser); |
| 4223 |
FUser := Value; |
| 4224 |
Include(FModifiedProperties, ipUser); |
| 4225 |
Include(FValidProperties, ipUser); |
| 4226 |
end; |
| 4227 |
|
| 4228 |
function TJclCompressionItem.UpdateFileTimes: Boolean; |
| 4229 |
const |
| 4230 |
FILE_WRITE_ATTRIBUTES = $00000100; |
| 4231 |
var |
| 4232 |
FileHandle: HFILE; |
| 4233 |
ACreationTime, ALastAccessTime, ALastWriteTime: PFileTime; |
| 4234 |
begin |
| 4235 |
ReleaseStream; |
| 4236 |
Result := FFileName <> ''; |
| 4237 |
if Result then |
| 4238 |
begin |
| 4239 |
FileHandle := CreateFile(PChar(FFileName), FILE_WRITE_ATTRIBUTES, FILE_SHARE_READ, nil, OPEN_ALWAYS, 0, 0); |
| 4240 |
try |
| 4241 |
// creation time should be the oldest |
| 4242 |
if ipCreationTime in FValidProperties then |
| 4243 |
ACreationTime := @FCreationTime |
| 4244 |
else |
| 4245 |
if ipLastWriteTime in FValidProperties then |
| 4246 |
ACreationTime := @FLastWriteTime |
| 4247 |
else |
| 4248 |
if ipLastAccessTime in FValidProperties then |
| 4249 |
ACreationTime := @FLastAccessTime |
| 4250 |
else |
| 4251 |
ACreationTime := nil; |
| 4252 |
|
| 4253 |
// last access time may default to now if not set |
| 4254 |
if ipLastAccessTime in FValidProperties then |
| 4255 |
ALastAccessTime := @FLastAccessTime |
| 4256 |
else |
| 4257 |
ALastAccessTime := nil; |
| 4258 |
|
| 4259 |
// last write time may, if not set, be the creation time or last access time |
| 4260 |
if ipLastWriteTime in FValidProperties then |
| 4261 |
ALastWriteTime := @FLastWriteTime |
| 4262 |
else |
| 4263 |
if ipCreationTime in FValidProperties then |
| 4264 |
ALastWriteTime := @FCreationTime |
| 4265 |
else |
| 4266 |
if ipLastAccessTime in FValidProperties then |
| 4267 |
ALastWriteTime := @FLastAccessTime |
| 4268 |
else |
| 4269 |
ALastWriteTime := nil; |
| 4270 |
|
| 4271 |
Result := (FileHandle <> INVALID_HANDLE_VALUE) and SetFileTime(FileHandle, ACreationTime, ALastAccessTime, |
| 4272 |
ALastWriteTime); |
| 4273 |
finally |
| 4274 |
CloseHandle(FileHandle); |
| 4275 |
end; |
| 4276 |
end; |
| 4277 |
end; |
| 4278 |
|
| 4279 |
function TJclCompressionItem.ValidateExtraction(Index: Integer): Boolean; |
| 4280 |
begin |
| 4281 |
Result := False; |
| 4282 |
end; |
| 4283 |
|
| 4284 |
function TJclCompressionItem.WideChangeFileExt(const AFileName, |
| 4285 |
AExtension: WideString): WideString; |
| 4286 |
var |
| 4287 |
Index: Integer; |
| 4288 |
begin |
| 4289 |
Result := AFileName; |
| 4290 |
// Unicode version of ChangeFileExt |
| 4291 |
for Index := Length(Result) downto 1 do |
| 4292 |
begin |
| 4293 |
case Result[Index] of |
| 4294 |
'.': |
| 4295 |
begin |
| 4296 |
Result := Copy(Result, 1, Index - 1) + AExtension; |
| 4297 |
Exit; |
| 4298 |
end; |
| 4299 |
DirSeparator, |
| 4300 |
DirDelimiter: |
| 4301 |
// no extension |
| 4302 |
Break; |
| 4303 |
end; |
| 4304 |
end; |
| 4305 |
Result := Result + AExtension; |
| 4306 |
end; |
| 4307 |
|
| 4308 |
function TJclCompressionItem.WideExtractFileExt( |
| 4309 |
const AFileName: WideString): WideString; |
| 4310 |
var |
| 4311 |
Index: Integer; |
| 4312 |
begin |
| 4313 |
Result := ''; |
| 4314 |
// Unicode version of ExtractFileExt |
| 4315 |
for Index := Length(AFileName) downto 1 do |
| 4316 |
begin |
| 4317 |
case AFileName[Index] of |
| 4318 |
'.': |
| 4319 |
begin |
| 4320 |
Result := Copy(AFileName, Index, Length(AFileName) - Index + 1); |
| 4321 |
Break; |
| 4322 |
end; |
| 4323 |
DirSeparator, |
| 4324 |
DirDelimiter: |
| 4325 |
// no extension |
| 4326 |
Break; |
| 4327 |
end; |
| 4328 |
end; |
| 4329 |
end; |
| 4330 |
|
| 4331 |
function TJclCompressionItem.WideExtractFileName( |
| 4332 |
const AFileName: WideString): WideString; |
| 4333 |
var |
| 4334 |
Index: Integer; |
| 4335 |
begin |
| 4336 |
Result := AFileName; |
| 4337 |
// Unicode version of ExtractFileName |
| 4338 |
for Index := Length(AFileName) downto 1 do |
| 4339 |
begin |
| 4340 |
case AFileName[Index] of |
| 4341 |
DirSeparator, |
| 4342 |
DirDelimiter: |
| 4343 |
begin |
| 4344 |
Result := Copy(AFileName, Index + 1, Length(AFileName) - Index); |
| 4345 |
Break; |
| 4346 |
end; |
| 4347 |
end; |
| 4348 |
end; |
| 4349 |
end; |
| 4350 |
|
| 4351 |
//=== { TJclCompressionArchiveFormats } ====================================== |
| 4352 |
|
| 4353 |
constructor TJclCompressionArchiveFormats.Create; |
| 4354 |
begin |
| 4355 |
inherited Create; |
| 4356 |
FCompressFormats := TList.Create; |
| 4357 |
FDecompressFormats := TList.Create; |
| 4358 |
FUpdateFormats := TList.Create; |
| 4359 |
// register compression archives |
| 4360 |
RegisterFormat(TJclZipCompressArchive); |
| 4361 |
RegisterFormat(TJclBZ2CompressArchive); |
| 4362 |
RegisterFormat(TJcl7zCompressArchive); |
| 4363 |
RegisterFormat(TJclTarCompressArchive); |
| 4364 |
RegisterFormat(TJclGZipCompressArchive); |
| 4365 |
RegisterFormat(TJclXzCompressArchive); |
| 4366 |
RegisterFormat(TJclSwfcCompressArchive); |
| 4367 |
RegisterFormat(TJclWimCompressArchive); |
| 4368 |
// register decompression archives |
| 4369 |
RegisterFormat(TJclZipDecompressArchive); |
| 4370 |
RegisterFormat(TJclBZ2DecompressArchive); |
| 4371 |
RegisterFormat(TJclRarDecompressArchive); |
| 4372 |
RegisterFormat(TJclArjDecompressArchive); |
| 4373 |
RegisterFormat(TJclZDecompressArchive); |
| 4374 |
RegisterFormat(TJclLzhDecompressArchive); |
| 4375 |
RegisterFormat(TJcl7zDecompressArchive); |
| 4376 |
RegisterFormat(TJclCabDecompressArchive); |
| 4377 |
RegisterFormat(TJclNsisDecompressArchive); |
| 4378 |
RegisterFormat(TJclLzmaDecompressArchive); |
| 4379 |
RegisterFormat(TJclLzma86DecompressArchive); |
| 4380 |
RegisterFormat(TJclPeDecompressArchive); |
| 4381 |
RegisterFormat(TJclElfDecompressArchive); |
| 4382 |
RegisterFormat(TJclMachoDecompressArchive); |
| 4383 |
RegisterFormat(TJclUdfDecompressArchive); |
| 4384 |
RegisterFormat(TJclXarDecompressArchive); |
| 4385 |
RegisterFormat(TJclMubDecompressArchive); |
| 4386 |
RegisterFormat(TJclHfsDecompressArchive); |
| 4387 |
RegisterFormat(TJclDmgDecompressArchive); |
| 4388 |
RegisterFormat(TJclCompoundDecompressArchive); |
| 4389 |
RegisterFormat(TJclWimDecompressArchive); |
| 4390 |
RegisterFormat(TJclIsoDecompressArchive); |
| 4391 |
RegisterFormat(TJclChmDecompressArchive); |
| 4392 |
RegisterFormat(TJclSplitDecompressArchive); |
| 4393 |
RegisterFormat(TJclRpmDecompressArchive); |
| 4394 |
RegisterFormat(TJclDebDecompressArchive); |
| 4395 |
RegisterFormat(TJclCpioDecompressArchive); |
| 4396 |
RegisterFormat(TJclTarDecompressArchive); |
| 4397 |
RegisterFormat(TJclGZipDecompressArchive); |
| 4398 |
RegisterFormat(TJclNtfsDecompressArchive); |
| 4399 |
RegisterFormat(TJclFatDecompressArchive); |
| 4400 |
RegisterFormat(TJclMbrDecompressArchive); |
| 4401 |
RegisterFormat(TJclVhdDecompressArchive); |
| 4402 |
RegisterFormat(TJclMslzDecompressArchive); |
| 4403 |
RegisterFormat(TJclFlvDecompressArchive); |
| 4404 |
RegisterFormat(TJclSwfDecompressArchive); |
| 4405 |
RegisterFormat(TJclSwfcDecompressArchive); |
| 4406 |
RegisterFormat(TJclAPMDecompressArchive); |
| 4407 |
RegisterFormat(TJclPpmdDecompressArchive); |
| 4408 |
RegisterFormat(TJclTEDecompressArchive); |
| 4409 |
RegisterFormat(TJclUEFIcDecompressArchive); |
| 4410 |
RegisterFormat(TJclUEFIsDecompressArchive); |
| 4411 |
RegisterFormat(TJclSquashFSDecompressArchive); |
| 4412 |
RegisterFormat(TJclCramFSDecompressArchive); |
| 4413 |
// register update archives |
| 4414 |
RegisterFormat(TJclZipUpdateArchive); |
| 4415 |
RegisterFormat(TJclBZ2UpdateArchive); |
| 4416 |
RegisterFormat(TJcl7zUpdateArchive); |
| 4417 |
RegisterFormat(TJclTarUpdateArchive); |
| 4418 |
RegisterFormat(TJclGZipUpdateArchive); |
| 4419 |
RegisterFormat(TJclSwfcUpdateArchive); |
| 4420 |
end; |
| 4421 |
|
| 4422 |
destructor TJclCompressionArchiveFormats.Destroy; |
| 4423 |
begin |
| 4424 |
FCompressFormats.Free; |
| 4425 |
FDecompressFormats.Free; |
| 4426 |
FUpdateFormats.Free; |
| 4427 |
inherited Destroy; |
| 4428 |
end; |
| 4429 |
|
| 4430 |
function TJclCompressionArchiveFormats.FindCompressFormat(const AFileName: TFileName): TJclCompressArchiveClass; |
| 4431 |
var |
| 4432 |
IndexFormat, IndexFilter: Integer; |
| 4433 |
Filters: TStrings; |
| 4434 |
AFormat: TJclCompressArchiveClass; |
| 4435 |
begin |
| 4436 |
Result := nil; |
| 4437 |
Filters := TStringList.Create; |
| 4438 |
try |
| 4439 |
for IndexFormat := 0 to CompressFormatCount - 1 do |
| 4440 |
begin |
| 4441 |
AFormat := CompressFormats[IndexFormat]; |
| 4442 |
StrTokenToStrings(AFormat.ArchiveExtensions, DirSeparator, Filters); |
| 4443 |
for IndexFilter := 0 to Filters.Count - 1 do |
| 4444 |
if IsFileNameMatch(AFileName, Filters.Strings[IndexFilter]) then |
| 4445 |
begin |
| 4446 |
Result := AFormat; |
| 4447 |
Break; |
| 4448 |
end; |
| 4449 |
if Result <> nil then |
| 4450 |
Break; |
| 4451 |
end; |
| 4452 |
finally |
| 4453 |
Filters.Free; |
| 4454 |
end; |
| 4455 |
end; |
| 4456 |
|
| 4457 |
function TJclCompressionArchiveFormats.FindCompressFormats( |
| 4458 |
const AFileName: TFileName): TJclCompressArchiveClassArray; |
| 4459 |
var |
| 4460 |
IndexFormat, IndexFilter: Integer; |
| 4461 |
Filters: TStrings; |
| 4462 |
AFormat: TJclCompressArchiveClass; |
| 4463 |
begin |
| 4464 |
SetLength(Result, 0); |
| 4465 |
Filters := TStringList.Create; |
| 4466 |
try |
| 4467 |
for IndexFormat := 0 to CompressFormatCount - 1 do |
| 4468 |
begin |
| 4469 |
AFormat := CompressFormats[IndexFormat]; |
| 4470 |
StrTokenToStrings(AFormat.ArchiveExtensions, DirSeparator, Filters); |
| 4471 |
for IndexFilter := 0 to Filters.Count - 1 do |
| 4472 |
if IsFileNameMatch(AFileName, Filters.Strings[IndexFilter]) then |
| 4473 |
begin |
| 4474 |
SetLength(Result, Length(Result) + 1); |
| 4475 |
Result[High(Result)] := AFormat; |
| 4476 |
Break; |
| 4477 |
end; |
| 4478 |
end; |
| 4479 |
finally |
| 4480 |
Filters.Free; |
| 4481 |
end; |
| 4482 |
end; |
| 4483 |
|
| 4484 |
{function TJclCompressionArchiveFormats.FindDecompressFormat(const AFileName: TFileName; |
| 4485 |
TestArchiveSignature: Boolean): TJclDecompressArchiveClass; |
| 4486 |
var |
| 4487 |
MatchingFormats: TJclDecompressArchiveClassArray; |
| 4488 |
Index: Integer; |
| 4489 |
ArchiveStream: TStream; |
| 4490 |
Buffer: TDynByteArray; |
| 4491 |
begin |
| 4492 |
SetLength(Buffer, 0); |
| 4493 |
|
| 4494 |
// enumerate formats based on filename |
| 4495 |
MatchingFormats := FindDecompressFormats(AFileName); |
| 4496 |
if (Length(MatchingFormats) >= 1) and (not TestArchiveSignature) then |
| 4497 |
begin |
| 4498 |
Result := MatchingFormats[0]; |
| 4499 |
Exit; |
| 4500 |
end |
| 4501 |
else |
| 4502 |
Result := nil; |
| 4503 |
|
| 4504 |
// load archive to test signature |
| 4505 |
ArchiveStream := TFileStream.Create(AFileName, fmOpenRead and fmShareDenyNone); |
| 4506 |
try |
| 4507 |
for Index := Low(MatchingFormats) to High(MatchingFormats) do |
| 4508 |
if SignatureMatches(MatchingFormats[Index], ArchiveStream, Buffer) then |
| 4509 |
begin |
| 4510 |
Result := MatchingFormats[Index]; |
| 4511 |
Exit; |
| 4512 |
end; |
| 4513 |
finally |
| 4514 |
ArchiveStream.Free; |
| 4515 |
end; |
| 4516 |
end;} |
| 4517 |
|
| 4518 |
function TJclCompressionArchiveFormats.FindDecompressFormat(const AFileName: TFileName): TJclDecompressArchiveClass; |
| 4519 |
var |
| 4520 |
MatchingFormats: TJclDecompressArchiveClassArray; |
| 4521 |
begin |
| 4522 |
// enumerate formats based on filename |
| 4523 |
MatchingFormats := FindDecompressFormats(AFileName); |
| 4524 |
if Length(MatchingFormats) >= 1 then |
| 4525 |
begin |
| 4526 |
Result := MatchingFormats[0]; |
| 4527 |
Exit; |
| 4528 |
end |
| 4529 |
else |
| 4530 |
Result := nil; |
| 4531 |
end; |
| 4532 |
|
| 4533 |
function TJclCompressionArchiveFormats.FindDecompressFormats( |
| 4534 |
const AFileName: TFileName): TJclDecompressArchiveClassArray; |
| 4535 |
var |
| 4536 |
IndexFormat, IndexFilter: Integer; |
| 4537 |
Filters: TStrings; |
| 4538 |
AFormat: TJclDecompressArchiveClass; |
| 4539 |
begin |
| 4540 |
SetLength(Result, 0); |
| 4541 |
Filters := TStringList.Create; |
| 4542 |
try |
| 4543 |
for IndexFormat := 0 to DecompressFormatCount - 1 do |
| 4544 |
begin |
| 4545 |
AFormat := DecompressFormats[IndexFormat]; |
| 4546 |
StrTokenToStrings(AFormat.ArchiveExtensions, DirSeparator, Filters); |
| 4547 |
for IndexFilter := 0 to Filters.Count - 1 do |
| 4548 |
if IsFileNameMatch(AFileName, Filters.Strings[IndexFilter]) then |
| 4549 |
begin |
| 4550 |
SetLength(Result, Length(Result) + 1); |
| 4551 |
Result[High(Result)] := AFormat; |
| 4552 |
Break; |
| 4553 |
end; |
| 4554 |
end; |
| 4555 |
finally |
| 4556 |
Filters.Free; |
| 4557 |
end; |
| 4558 |
end; |
| 4559 |
|
| 4560 |
{function TJclCompressionArchiveFormats.FindUpdateFormat(const AFileName: TFileName; |
| 4561 |
TestArchiveSignature: Boolean): TJclUpdateArchiveClass; |
| 4562 |
var |
| 4563 |
MatchingFormats: TJclUpdateArchiveClassArray; |
| 4564 |
Index: Integer; |
| 4565 |
ArchiveStream: TStream; |
| 4566 |
Buffer: TDynByteArray; |
| 4567 |
begin |
| 4568 |
SetLength(Buffer, 0); |
| 4569 |
|
| 4570 |
// enumerate formats based on filename |
| 4571 |
MatchingFormats := FindUpdateFormats(AFileName); |
| 4572 |
if (Length(MatchingFormats) >= 1) and (not TestArchiveSignature) then |
| 4573 |
begin |
| 4574 |
Result := MatchingFormats[0]; |
| 4575 |
Exit; |
| 4576 |
end |
| 4577 |
else |
| 4578 |
Result := nil; |
| 4579 |
|
| 4580 |
// load archive to test signature |
| 4581 |
ArchiveStream := TFileStream.Create(AFileName, fmOpenRead and fmShareDenyNone); |
| 4582 |
try |
| 4583 |
for Index := Low(MatchingFormats) to High(MatchingFormats) do |
| 4584 |
if SignatureMatches(MatchingFormats[Index], ArchiveStream, Buffer) then |
| 4585 |
begin |
| 4586 |
Result := MatchingFormats[Index]; |
| 4587 |
Exit; |
| 4588 |
end; |
| 4589 |
finally |
| 4590 |
ArchiveStream.Free; |
| 4591 |
end; |
| 4592 |
end;} |
| 4593 |
|
| 4594 |
function TJclCompressionArchiveFormats.FindUpdateFormat(const AFileName: TFileName): TJclUpdateArchiveClass; |
| 4595 |
var |
| 4596 |
MatchingFormats: TJclUpdateArchiveClassArray; |
| 4597 |
begin |
| 4598 |
// enumerate formats based on filename |
| 4599 |
MatchingFormats := FindUpdateFormats(AFileName); |
| 4600 |
if Length(MatchingFormats) >= 1 then |
| 4601 |
begin |
| 4602 |
Result := MatchingFormats[0]; |
| 4603 |
Exit; |
| 4604 |
end |
| 4605 |
else |
| 4606 |
Result := nil; |
| 4607 |
end; |
| 4608 |
|
| 4609 |
function TJclCompressionArchiveFormats.FindUpdateFormats( |
| 4610 |
const AFileName: TFileName): TJclUpdateArchiveClassArray; |
| 4611 |
var |
| 4612 |
IndexFormat, IndexFilter: Integer; |
| 4613 |
Filters: TStrings; |
| 4614 |
AFormat: TJclUpdateArchiveClass; |
| 4615 |
begin |
| 4616 |
SetLength(Result, 0); |
| 4617 |
Filters := TStringList.Create; |
| 4618 |
try |
| 4619 |
for IndexFormat := 0 to UpdateFormatCount - 1 do |
| 4620 |
begin |
| 4621 |
AFormat := UpdateFormats[IndexFormat]; |
| 4622 |
StrTokenToStrings(AFormat.ArchiveExtensions, DirSeparator, Filters); |
| 4623 |
for IndexFilter := 0 to Filters.Count - 1 do |
| 4624 |
if IsFileNameMatch(AFileName, Filters.Strings[IndexFilter]) then |
| 4625 |
begin |
| 4626 |
SetLength(Result, Length(Result) + 1); |
| 4627 |
Result[High(Result)] := AFormat; |
| 4628 |
Break; |
| 4629 |
end; |
| 4630 |
end; |
| 4631 |
finally |
| 4632 |
Filters.Free; |
| 4633 |
end; |
| 4634 |
end; |
| 4635 |
|
| 4636 |
function TJclCompressionArchiveFormats.GetCompressFormat(Index: Integer): TJclCompressArchiveClass; |
| 4637 |
begin |
| 4638 |
Result := TJclCompressArchiveClass(FCompressFormats.Items[Index]); |
| 4639 |
end; |
| 4640 |
|
| 4641 |
function TJclCompressionArchiveFormats.GetCompressFormatCount: Integer; |
| 4642 |
begin |
| 4643 |
Result := FCompressFormats.Count; |
| 4644 |
end; |
| 4645 |
|
| 4646 |
function TJclCompressionArchiveFormats.GetDecompressFormat(Index: Integer): TJclDecompressArchiveClass; |
| 4647 |
begin |
| 4648 |
Result := TJclDecompressArchiveClass(FDecompressFormats.Items[Index]); |
| 4649 |
end; |
| 4650 |
|
| 4651 |
function TJclCompressionArchiveFormats.GetDecompressFormatCount: Integer; |
| 4652 |
begin |
| 4653 |
Result := FDecompressFormats.Count; |
| 4654 |
end; |
| 4655 |
|
| 4656 |
function TJclCompressionArchiveFormats.GetUpdateFormat(Index: Integer): TJclUpdateArchiveClass; |
| 4657 |
begin |
| 4658 |
Result := TJclUpdateArchiveClass(FUpdateFormats.Items[Index]); |
| 4659 |
end; |
| 4660 |
|
| 4661 |
function TJclCompressionArchiveFormats.GetUpdateFormatCount: Integer; |
| 4662 |
begin |
| 4663 |
Result := FUpdateFormats.Count; |
| 4664 |
end; |
| 4665 |
|
| 4666 |
procedure TJclCompressionArchiveFormats.RegisterFormat(AClass: TJclCompressionArchiveClass); |
| 4667 |
begin |
| 4668 |
if AClass.InheritsFrom(TJclUpdateArchive) then |
| 4669 |
FUpdateFormats.Add(AClass) |
| 4670 |
else |
| 4671 |
if AClass.InheritsFrom(TJclDecompressArchive) then |
| 4672 |
FDecompressFormats.Add(AClass) |
| 4673 |
else |
| 4674 |
if AClass.InheritsFrom(TJclCompressArchive) then |
| 4675 |
FCompressFormats.Add(AClass); |
| 4676 |
end; |
| 4677 |
|
| 4678 |
{function TJclCompressionArchiveFormats.SignatureMatches( |
| 4679 |
Format: TJclCompressionArchiveClass; ArchiveStream: TStream; |
| 4680 |
var Buffer: TDynByteArray): Boolean; |
| 4681 |
var |
| 4682 |
Index, StartPos, EndPos: Integer; |
| 4683 |
Signature: TDynByteArray; |
| 4684 |
begin |
| 4685 |
// must match empty signatures |
| 4686 |
Result := True; |
| 4687 |
Signature := Format.ArchiveSignature; |
| 4688 |
|
| 4689 |
// fill buffer if needed |
| 4690 |
StartPos := Length(Buffer); // High(Buffer) + 1 |
| 4691 |
EndPos := Length(Signature); |
| 4692 |
if StartPos < EndPos then |
| 4693 |
begin |
| 4694 |
SetLength(Buffer, EndPos); |
| 4695 |
for Index := StartPos to EndPos - 1 do |
| 4696 |
ArchiveStream.ReadBuffer(Buffer[Index], SizeOf(Buffer[Index])); |
| 4697 |
end; |
| 4698 |
|
| 4699 |
// compare buffer and signature |
| 4700 |
for Index := 0 to EndPos - 1 do |
| 4701 |
if Buffer[Index] <> Signature[Index] then |
| 4702 |
begin |
| 4703 |
Result := False; |
| 4704 |
Break; |
| 4705 |
end; |
| 4706 |
end;} |
| 4707 |
|
| 4708 |
procedure TJclCompressionArchiveFormats.UnregisterFormat(AClass: TJclCompressionArchiveClass); |
| 4709 |
begin |
| 4710 |
if AClass.InheritsFrom(TJclUpdateArchive) then |
| 4711 |
FUpdateFormats.Remove(AClass) |
| 4712 |
else |
| 4713 |
if AClass.InheritsFrom(TJclDecompressArchive) then |
| 4714 |
FDecompressFormats.Remove(AClass) |
| 4715 |
else |
| 4716 |
if AClass.InheritsFrom(TJclCompressArchive) then |
| 4717 |
FCompressFormats.Remove(AClass); |
| 4718 |
end; |
| 4719 |
|
| 4720 |
function GetArchiveFormats: TJclCompressionArchiveFormats; |
| 4721 |
begin |
| 4722 |
if not Assigned(GlobalArchiveFormats) then |
| 4723 |
GlobalArchiveFormats := TJclCompressionArchiveFormats.Create; |
| 4724 |
Result := TJclCompressionArchiveFormats(GlobalArchiveFormats); |
| 4725 |
end; |
| 4726 |
|
| 4727 |
//=== { TJclCompressionVolume } ============================================== |
| 4728 |
|
| 4729 |
constructor TJclCompressionVolume.Create(AStream, ATmpStream: TStream; AOwnsStream, AOwnsTmpStream: Boolean; |
| 4730 |
AFileName, ATmpFileName: TFileName; AVolumeMaxSize: Int64); |
| 4731 |
begin |
| 4732 |
inherited Create; |
| 4733 |
FStream := AStream; |
| 4734 |
FTmpStream := ATmpStream; |
| 4735 |
FOwnsStream := AOwnsStream; |
| 4736 |
FOwnsTmpStream := AOwnsTmpStream; |
| 4737 |
FFileName := AFileName; |
| 4738 |
FTmpFileName := ATmpFileName; |
| 4739 |
FVolumeMaxSize := AVolumeMaxSize; |
| 4740 |
end; |
| 4741 |
|
| 4742 |
destructor TJclCompressionVolume.Destroy; |
| 4743 |
begin |
| 4744 |
ReleaseStreams; |
| 4745 |
inherited Destroy; |
| 4746 |
end; |
| 4747 |
|
| 4748 |
procedure TJclCompressionVolume.ReleaseStreams; |
| 4749 |
begin |
| 4750 |
if OwnsStream then |
| 4751 |
FreeAndNil(FStream); |
| 4752 |
if OwnsTmpStream then |
| 4753 |
FreeAndNil(FTmpStream); |
| 4754 |
end; |
| 4755 |
|
| 4756 |
//=== { TJclCompressionArchive } ============================================= |
| 4757 |
|
| 4758 |
constructor TJclCompressionArchive.Create(Volume0: TStream; |
| 4759 |
AVolumeMaxSize: Int64 = 0; AOwnVolume: Boolean = False); |
| 4760 |
begin |
| 4761 |
inherited Create; |
| 4762 |
FVolumeIndex := -1; |
| 4763 |
FVolumeIndexOffset := 1; |
| 4764 |
FVolumeMaxSize := AVolumeMaxSize; |
| 4765 |
FItems := TObjectList.Create(True); |
| 4766 |
FVolumes := TObjectList.Create(True); |
| 4767 |
if Assigned(Volume0) then |
| 4768 |
AddVolume(Volume0, AVolumeMaxSize, AOwnVolume); |
| 4769 |
InitializeArchiveProperties; |
| 4770 |
end; |
| 4771 |
|
| 4772 |
constructor TJclCompressionArchive.Create(const VolumeFileName: TFileName; |
| 4773 |
AVolumeMaxSize: Int64 = 0; VolumeMask: Boolean = False); |
| 4774 |
begin |
| 4775 |
inherited Create; |
| 4776 |
FVolumeIndex := -1; |
| 4777 |
FVolumeIndexOffset := 1; |
| 4778 |
FVolumeMaxSize := AVolumeMaxSize; |
| 4779 |
FItems := TObjectList.Create(True); |
| 4780 |
FVolumes := TObjectList.Create(True); |
| 4781 |
if VolumeMask then |
| 4782 |
FVolumeFileNameMask := VolumeFileName |
| 4783 |
else |
| 4784 |
AddVolume(VolumeFileName, AVolumeMaxSize); |
| 4785 |
InitializeArchiveProperties; |
| 4786 |
end; |
| 4787 |
|
| 4788 |
destructor TJclCompressionArchive.Destroy; |
| 4789 |
begin |
| 4790 |
FItems.Free; |
| 4791 |
FVolumes.Free; |
| 4792 |
|
| 4793 |
inherited Destroy; |
| 4794 |
end; |
| 4795 |
|
| 4796 |
function TJclCompressionArchive.AddVolume(VolumeStream: TStream; |
| 4797 |
AVolumeMaxSize: Int64; AOwnsStream: Boolean): Integer; |
| 4798 |
begin |
| 4799 |
Result := FVolumes.Add(TJclCompressionVolume.Create(VolumeStream, nil, AOwnsStream, True, '', '', AVolumeMaxSize)); |
| 4800 |
end; |
| 4801 |
|
| 4802 |
function TJclCompressionArchive.AddVolume(VolumeStream, TmpVolumeStream: TStream; |
| 4803 |
AVolumeMaxSize: Int64; AOwnsStream, AOwnsTmpStream: Boolean): Integer; |
| 4804 |
begin |
| 4805 |
Result := FVolumes.Add(TJclCompressionVolume.Create(VolumeStream, TmpVolumeStream, AOwnsStream, AOwnsTmpStream, '', '', AVolumeMaxSize)); |
| 4806 |
end; |
| 4807 |
|
| 4808 |
function TJclCompressionArchive.AddVolume(const VolumeFileName: TFileName; |
| 4809 |
AVolumeMaxSize: Int64): Integer; |
| 4810 |
begin |
| 4811 |
Result := FVolumes.Add(TJclCompressionVolume.Create(nil, nil, True, True, VolumeFileName, '', AVolumeMaxSize)); |
| 4812 |
end; |
| 4813 |
|
| 4814 |
function TJclCompressionArchive.AddVolume(const VolumeFileName, TmpVolumeFileName: TFileName; |
| 4815 |
AVolumeMaxSize: Int64): Integer; |
| 4816 |
begin |
| 4817 |
Result := FVolumes.Add(TJclCompressionVolume.Create(nil, nil, True, True, VolumeFileName, TmpVolumeFileName, AVolumeMaxSize)); |
| 4818 |
end; |
| 4819 |
|
| 4820 |
class function TJclCompressionArchive.ArchiveExtensions: string; |
| 4821 |
begin |
| 4822 |
Result := ''; |
| 4823 |
end; |
| 4824 |
|
| 4825 |
class function TJclCompressionArchive.ArchiveName: string; |
| 4826 |
begin |
| 4827 |
Result := ''; |
| 4828 |
end; |
| 4829 |
|
| 4830 |
class function TJclCompressionArchive.ArchiveSignature: TDynByteArray; |
| 4831 |
begin |
| 4832 |
SetLength(Result, 0); |
| 4833 |
end; |
| 4834 |
|
| 4835 |
class function TJclCompressionArchive.ArchiveSubExtensions: string; |
| 4836 |
begin |
| 4837 |
Result := ''; |
| 4838 |
end; |
| 4839 |
|
| 4840 |
procedure TJclCompressionArchive.CheckOperationSuccess; |
| 4841 |
var |
| 4842 |
Index: Integer; |
| 4843 |
begin |
| 4844 |
for Index := 0 to FItems.Count - 1 do |
| 4845 |
begin |
| 4846 |
case TJclCompressionItem(FItems.Items[Index]).OperationSuccess of |
| 4847 |
osNoOperation: ; |
| 4848 |
osOK: ; |
| 4849 |
osUnsupportedMethod: |
| 4850 |
raise EJclCompressionError.CreateRes(@RsCompressionUnsupportedMethod); |
| 4851 |
osDataError: |
| 4852 |
raise EJclCompressionError.CreateRes(@RsCompressionDataError); |
| 4853 |
osCRCError: |
| 4854 |
raise EJclCompressionError.CreateRes(@RsCompressionCRCError); |
| 4855 |
else |
| 4856 |
raise EJclCompressionError.CreateRes(@RsCompressionUnknownError); |
| 4857 |
end; |
| 4858 |
end; |
| 4859 |
end; |
| 4860 |
|
| 4861 |
procedure TJclCompressionArchive.ClearItems; |
| 4862 |
begin |
| 4863 |
FItems.Clear; |
| 4864 |
end; |
| 4865 |
|
| 4866 |
procedure TJclCompressionArchive.ClearOperationSuccess; |
| 4867 |
var |
| 4868 |
Index: Integer; |
| 4869 |
begin |
| 4870 |
for Index := 0 to FItems.Count - 1 do |
| 4871 |
TJclCompressionItem(FItems.Items[Index]).OperationSuccess := osNoOperation; |
| 4872 |
end; |
| 4873 |
|
| 4874 |
procedure TJclCompressionArchive.ClearVolumes; |
| 4875 |
begin |
| 4876 |
FVolumes.Clear; |
| 4877 |
end; |
| 4878 |
|
| 4879 |
procedure TJclCompressionArchive.InitializeArchiveProperties; |
| 4880 |
begin |
| 4881 |
// override to customize |
| 4882 |
end; |
| 4883 |
|
| 4884 |
function TJclCompressionArchive.DoProgress(const Value, MaxValue: Int64): Boolean; |
| 4885 |
begin |
| 4886 |
if Assigned(FOnProgress) then |
| 4887 |
FOnProgress(Self, Value, MaxValue); |
| 4888 |
Result := not FCancelCurrentOperation; |
| 4889 |
end; |
| 4890 |
|
| 4891 |
function TJclCompressionArchive.DoRatio(const InSize, OutSize: Int64): Boolean; |
| 4892 |
begin |
| 4893 |
if Assigned(FOnRatio) then |
| 4894 |
FOnRatio(Self, InSize, OutSize); |
| 4895 |
Result := not FCancelCurrentOperation; |
| 4896 |
end; |
| 4897 |
|
| 4898 |
function TJclCompressionArchive.GetItem(Index: Integer): TJclCompressionItem; |
| 4899 |
begin |
| 4900 |
Result := TJclCompressionItem(FItems.Items[Index]); |
| 4901 |
end; |
| 4902 |
|
| 4903 |
function TJclCompressionArchive.GetItemCount: Integer; |
| 4904 |
begin |
| 4905 |
Result := FItems.Count; |
| 4906 |
end; |
| 4907 |
|
| 4908 |
function TJclCompressionArchive.GetSupportsNestedArchive: Boolean; |
| 4909 |
begin |
| 4910 |
Result := False; |
| 4911 |
end; |
| 4912 |
|
| 4913 |
function TJclCompressionArchive.GetVolume(Index: Integer): TJclCompressionVolume; |
| 4914 |
begin |
| 4915 |
Result := TJclCompressionVolume(FVolumes.Items[Index]); |
| 4916 |
end; |
| 4917 |
|
| 4918 |
function TJclCompressionArchive.GetVolumeCount: Integer; |
| 4919 |
begin |
| 4920 |
Result := FVolumes.Count; |
| 4921 |
end; |
| 4922 |
|
| 4923 |
function TJclCompressionArchive.InternalOpenStream( |
| 4924 |
const FileName: TFileName): TStream; |
| 4925 |
begin |
| 4926 |
Result := OpenFileStream(FileName, VolumeAccess); |
| 4927 |
end; |
| 4928 |
|
| 4929 |
function TJclCompressionArchive.ItemAccess: TJclStreamAccess; |
| 4930 |
begin |
| 4931 |
Result := saReadOnly; |
| 4932 |
end; |
| 4933 |
|
| 4934 |
class function TJclCompressionArchive.MultipleItemContainer: Boolean; |
| 4935 |
begin |
| 4936 |
Result := True; |
| 4937 |
end; |
| 4938 |
|
| 4939 |
function TJclCompressionArchive.NeedStream(Index: Integer): TStream; |
| 4940 |
var |
| 4941 |
AVolume: TJclCompressionVolume; |
| 4942 |
AOwnsStream: Boolean; |
| 4943 |
AFileName: TFileName; |
| 4944 |
begin |
| 4945 |
Result := nil; |
| 4946 |
|
| 4947 |
if Index <> FVolumeIndex then |
| 4948 |
begin |
| 4949 |
AOwnsStream := VolumeFileNameMask <> ''; |
| 4950 |
AVolume := nil; |
| 4951 |
AFileName := Format(VolumeFileNameMask, [Index + VolumeIndexOffset]); |
| 4952 |
if (Index >= 0) and (Index < FVolumes.Count) then |
| 4953 |
begin |
| 4954 |
AVolume := TJclCompressionVolume(FVolumes.Items[Index]); |
| 4955 |
Result := AVolume.Stream; |
| 4956 |
AOwnsStream := AVolume.OwnsStream; |
| 4957 |
AFileName := AVolume.FileName; |
| 4958 |
end; |
| 4959 |
|
| 4960 |
if Assigned(FOnVolume) then |
| 4961 |
FOnVolume(Self, Index, AFileName, Result, AOwnsStream); |
| 4962 |
|
| 4963 |
if Assigned(AVolume) then |
| 4964 |
begin |
| 4965 |
if not Assigned(Result) then |
| 4966 |
Result := InternalOpenStream(AFileName); |
| 4967 |
AVolume.FFileName := AFileName; |
| 4968 |
AVolume.FStream := Result; |
| 4969 |
AVolume.FOwnsStream := AOwnsStream; |
| 4970 |
end |
| 4971 |
else |
| 4972 |
begin |
| 4973 |
while FVolumes.Count < Index do |
| 4974 |
FVolumes.Add(TJclCompressionVolume.Create(nil, nil, True, True, Format(VolumeFileNameMask, [Index + VolumeIndexOffset]), '', FVolumeMaxSize)); |
| 4975 |
if not Assigned(Result) then |
| 4976 |
Result := InternalOpenStream(AFileName); |
| 4977 |
if Assigned(Result) then |
| 4978 |
begin |
| 4979 |
if Index < FVolumes.Count then |
| 4980 |
begin |
| 4981 |
AVolume := TJclCompressionVolume(FVolumes.Items[Index]); |
| 4982 |
AVolume.FFileName := AFileName; |
| 4983 |
AVolume.FStream := Result; |
| 4984 |
AVolume.FOwnsStream := AOwnsStream; |
| 4985 |
AVolume.FVolumeMaxSize := FVolumeMaxSize; |
| 4986 |
end |
| 4987 |
else |
| 4988 |
FVolumes.Add(TJclCompressionVolume.Create(Result, nil, AOwnsStream, True, AFileName, '', FVolumeMaxSize)); |
| 4989 |
end; |
| 4990 |
end; |
| 4991 |
FVolumeIndex := Index; |
| 4992 |
end |
| 4993 |
else |
| 4994 |
if (Index >= 0) and (Index < FVolumes.Count) then |
| 4995 |
begin |
| 4996 |
AVolume := TJclCompressionVolume(FVolumes.Items[Index]); |
| 4997 |
Result := AVolume.Stream; |
| 4998 |
if Assigned(Result) then |
| 4999 |
Result.Seek(0, soBeginning); |
| 5000 |
end |
| 5001 |
else |
| 5002 |
FVolumeIndex := Index; |
| 5003 |
end; |
| 5004 |
|
| 5005 |
function TJclCompressionArchive.NeedStreamMaxSize(Index: Integer): Int64; |
| 5006 |
var |
| 5007 |
AVolume: TJclCompressionVolume; |
| 5008 |
begin |
| 5009 |
if (Index <> FVolumeIndex) then |
| 5010 |
begin |
| 5011 |
AVolume := nil; |
| 5012 |
if (Index >= 0) and (Index < FVolumes.Count) then |
| 5013 |
begin |
| 5014 |
AVolume := TJclCompressionVolume(FVolumes.Items[Index]); |
| 5015 |
FVolumeMaxSize := AVolume.VolumeMaxSize; |
| 5016 |
end; |
| 5017 |
if Assigned(FOnVolumeMaxSize) then |
| 5018 |
FOnVolumeMaxSize(Self, Index, FVolumeMaxSize); |
| 5019 |
if Assigned(AVolume) then |
| 5020 |
AVolume.FVolumeMaxSize := FVolumeMaxSize |
| 5021 |
else |
| 5022 |
begin |
| 5023 |
while FVolumes.Count < Index do |
| 5024 |
FVolumes.Add(TJclCompressionVolume.Create(nil, nil, True, True, Format(VolumeFileNameMask, [Index + VolumeIndexOffset]), '', FVolumeMaxSize)); |
| 5025 |
if Index < FVolumes.Count then |
| 5026 |
begin |
| 5027 |
AVolume := TJclCompressionVolume(FVolumes.Items[Index]); |
| 5028 |
AVolume.FFileName := Format(VolumeFileNameMask, [Index + VolumeIndexOffset]); |
| 5029 |
AVolume.FStream := nil; |
| 5030 |
AVolume.FOwnsStream := True; |
| 5031 |
AVolume.FVolumeMaxSize := FVolumeMaxSize; |
| 5032 |
end |
| 5033 |
else |
| 5034 |
FVolumes.Add(TJclCompressionVolume.Create(nil, nil, True, True, Format(VolumeFileNameMask, [Index + VolumeIndexOffset]), '', FVolumeMaxSize)); |
| 5035 |
end; |
| 5036 |
end; |
| 5037 |
Result := FVolumeMaxSize; |
| 5038 |
end; |
| 5039 |
|
| 5040 |
procedure TJclCompressionArchive.ReleaseVolumes; |
| 5041 |
var |
| 5042 |
Index: Integer; |
| 5043 |
begin |
| 5044 |
for Index := 0 to FVolumes.Count - 1 do |
| 5045 |
TJclCompressionVolume(FVolumes.Items[Index]).ReleaseStreams; |
| 5046 |
end; |
| 5047 |
|
| 5048 |
procedure TJclCompressionArchive.SelectAll; |
| 5049 |
var |
| 5050 |
Index: Integer; |
| 5051 |
begin |
| 5052 |
for Index := 0 to FItems.Count - 1 do |
| 5053 |
TJclCompressionItem(FItems.Items[Index]).Selected := True; |
| 5054 |
end; |
| 5055 |
|
| 5056 |
function TJclCompressionArchive.TranslateItemPath(const ItemPath, OldBase, |
| 5057 |
NewBase: WideString): WideString; |
| 5058 |
begin |
| 5059 |
Result := PathCanonicalize(PathAddSeparator(NewBase) + PathGetRelativePath(OldBase, ItemPath)); |
| 5060 |
end; |
| 5061 |
|
| 5062 |
procedure TJclCompressionArchive.UnselectAll; |
| 5063 |
var |
| 5064 |
Index: Integer; |
| 5065 |
begin |
| 5066 |
for Index := 0 to FItems.Count - 1 do |
| 5067 |
TJclCompressionItem(FItems.Items[Index]).Selected := False; |
| 5068 |
end; |
| 5069 |
|
| 5070 |
class function TJclCompressionArchive.VolumeAccess: TJclStreamAccess; |
| 5071 |
begin |
| 5072 |
Result := saReadOnly; |
| 5073 |
end; |
| 5074 |
|
| 5075 |
function TJclCompressionArchive._AddRef: Integer; |
| 5076 |
begin |
| 5077 |
Result := -1; |
| 5078 |
end; |
| 5079 |
|
| 5080 |
function TJclCompressionArchive._Release: Integer; |
| 5081 |
begin |
| 5082 |
Result := -1; |
| 5083 |
end; |
| 5084 |
|
| 5085 |
//=== { TJclCompressItem } =================================================== |
| 5086 |
|
| 5087 |
procedure TJclCompressItem.CheckGetProperty( |
| 5088 |
AProperty: TJclCompressionItemProperty); |
| 5089 |
begin |
| 5090 |
// always valid |
| 5091 |
end; |
| 5092 |
|
| 5093 |
procedure TJclCompressItem.CheckSetProperty( |
| 5094 |
AProperty: TJclCompressionItemProperty); |
| 5095 |
begin |
| 5096 |
if AProperty in [ipMethod] then |
| 5097 |
raise EJclCompressionError.CreateRes(@RsCompressionWriteNotSupported); |
| 5098 |
(Archive as TJclCompressArchive).CheckNotCompressing; |
| 5099 |
end; |
| 5100 |
|
| 5101 |
//=== { TJclCompressArchive } ================================================ |
| 5102 |
|
| 5103 |
destructor TJclCompressArchive.Destroy; |
| 5104 |
begin |
| 5105 |
FPackedNames.Free; |
| 5106 |
inherited Destroy; |
| 5107 |
end; |
| 5108 |
|
| 5109 |
function TJclCompressArchive.AddDirectory(const PackedName: WideString; |
| 5110 |
const DirName: string; RecurseIntoDir: Boolean; AddFilesInDir: Boolean): Integer; |
| 5111 |
var |
| 5112 |
AItem: TJclCompressionItem; |
| 5113 |
begin |
| 5114 |
CheckNotCompressing; |
| 5115 |
|
| 5116 |
if DirName <> '' then |
| 5117 |
begin |
| 5118 |
FBaseRelName := PackedName; |
| 5119 |
FBaseDirName := PathRemoveSeparator(DirName); |
| 5120 |
FAddFilesInDir := AddFilesInDir; |
| 5121 |
|
| 5122 |
if RecurseIntoDir then |
| 5123 |
begin |
| 5124 |
Result := FItems.Count; |
| 5125 |
EnumDirectories(DirName, InternalAddDirectory, True, '', nil); |
| 5126 |
Exit; |
| 5127 |
end; |
| 5128 |
end; |
| 5129 |
|
| 5130 |
AItem := GetItemClass.Create(Self); |
| 5131 |
try |
| 5132 |
AItem.PackedName := PackedName; |
| 5133 |
AItem.FileName := DirName; |
| 5134 |
except |
| 5135 |
AItem.Destroy; |
| 5136 |
raise; |
| 5137 |
end; |
| 5138 |
|
| 5139 |
Result := AddFileCheckDuplicate(AItem); |
| 5140 |
|
| 5141 |
if (DirName <> '') and AddFilesInDir then |
| 5142 |
EnumFiles(PathAddSeparator(DirName) + '*', InternalAddFile, faDirectory); |
| 5143 |
end; |
| 5144 |
|
| 5145 |
function TJclCompressArchive.AddFile(const PackedName: WideString; |
| 5146 |
const FileName: TFileName): Integer; |
| 5147 |
var |
| 5148 |
AItem: TJclCompressionItem; |
| 5149 |
begin |
| 5150 |
CheckNotCompressing; |
| 5151 |
|
| 5152 |
AItem := GetItemClass.Create(Self); |
| 5153 |
try |
| 5154 |
AItem.PackedName := PackedName; |
| 5155 |
AItem.FileName := FileName; |
| 5156 |
except |
| 5157 |
AItem.Destroy; |
| 5158 |
raise; |
| 5159 |
end; |
| 5160 |
|
| 5161 |
Result := AddFileCheckDuplicate(AItem); |
| 5162 |
end; |
| 5163 |
|
| 5164 |
function TJclCompressArchive.AddFile(const PackedName: WideString; |
| 5165 |
AStream: TStream; AOwnsStream: Boolean): Integer; |
| 5166 |
var |
| 5167 |
AItem: TJclCompressionItem; |
| 5168 |
NowFileTime: TFileTime; |
| 5169 |
begin |
| 5170 |
CheckNotCompressing; |
| 5171 |
|
| 5172 |
AItem := GetItemClass.Create(Self); |
| 5173 |
try |
| 5174 |
AItem.PackedName := PackedName; |
| 5175 |
AItem.Stream := AStream; |
| 5176 |
AItem.OwnsStream := AOwnsStream; |
| 5177 |
AItem.FileSize := AStream.Size - AStream.Position; |
| 5178 |
NowFileTime := LocalDateTimeToFileTime(Now); |
| 5179 |
AItem.Attributes := faReadOnly and faArchive; |
| 5180 |
AItem.CreationTime := NowFileTime; |
| 5181 |
AItem.LastAccessTime := NowFileTime; |
| 5182 |
AItem.LastWriteTime := NowFileTime; |
| 5183 |
{$IFDEF MSWINDOWS} |
| 5184 |
AItem.HostOS := LoadResString(@RsCompression7zWindows); |
| 5185 |
{$ENDIF MSWINDOWS} |
| 5186 |
{$IFDEF UNIX} |
| 5187 |
AItem.HostOS := LoadResString(@RsCompression7zUnix); |
| 5188 |
{$ENDIF UNIX} |
| 5189 |
except |
| 5190 |
AItem.Destroy; |
| 5191 |
raise; |
| 5192 |
end; |
| 5193 |
|
| 5194 |
Result := AddFileCheckDuplicate(AItem); |
| 5195 |
end; |
| 5196 |
|
| 5197 |
function TJclCompressArchive.AddFileCheckDuplicate(NewItem: TJclCompressionItem): Integer; |
| 5198 |
var |
| 5199 |
I, PackedNamesIndex: Integer; |
| 5200 |
S: string; |
| 5201 |
begin |
| 5202 |
if FDuplicateCheck = dcNone then |
| 5203 |
Result := FItems.Add(NewItem) |
| 5204 |
else |
| 5205 |
begin |
| 5206 |
if FPackedNames = nil then |
| 5207 |
begin |
| 5208 |
FPackedNames := TJclWideStringList.Create; |
| 5209 |
FPackedNames.Sorted := True; |
| 5210 |
{$IFDEF UNIX} |
| 5211 |
FPackedNames.CaseSensitive := True; |
| 5212 |
{$ELSE ~UNIX} |
| 5213 |
FPackedNames.CaseSensitive := False; |
| 5214 |
{$ENDIF ~UNIX} |
| 5215 |
FPackedNames.Duplicates := dupIgnore; |
| 5216 |
for I := ItemCount - 1 downto 0 do |
| 5217 |
FPackedNames.AddObject(Items[I].PackedName, Items[I]); |
| 5218 |
FPackedNames.Duplicates := dupError; |
| 5219 |
end; |
| 5220 |
if DuplicateCheck = dcAll then |
| 5221 |
begin |
| 5222 |
try |
| 5223 |
PackedNamesIndex := -1; |
| 5224 |
FPackedNames.AddObject(NewItem.PackedName, NewItem); |
| 5225 |
Result := FItems.Add(NewItem); |
| 5226 |
except |
| 5227 |
Result := -1; |
| 5228 |
end; |
| 5229 |
end |
| 5230 |
else |
| 5231 |
if FPackedNames.Find(NewItem.PackedName, PackedNamesIndex) then |
| 5232 |
Result := -1 |
| 5233 |
else |
| 5234 |
Result := FItems.Add(NewItem); |
| 5235 |
if Result < 0 then |
| 5236 |
begin |
| 5237 |
case DuplicateAction of |
| 5238 |
daOverwrite: |
| 5239 |
begin |
| 5240 |
if PackedNamesIndex < 0 then |
| 5241 |
PackedNamesIndex := FPackedNames.IndexOf(NewItem.PackedName); |
| 5242 |
FItems.Remove(FPackedNames.Objects[PackedNamesIndex]); |
| 5243 |
Result := FItems.Add(NewItem); |
| 5244 |
if DuplicateCheck = dcAll then |
| 5245 |
FPackedNames.Objects[PackedNamesIndex] := NewItem |
| 5246 |
else |
| 5247 |
FPackedNames.Delete(PackedNamesIndex); |
| 5248 |
end; |
| 5249 |
daError: |
| 5250 |
begin |
| 5251 |
S := Format(LoadResString(@RsCompressionDuplicate), [NewItem.PackedName]); |
| 5252 |
NewItem.Free; |
| 5253 |
raise EJclCompressionError.Create(S); |
| 5254 |
end; |
| 5255 |
daSkip: |
| 5256 |
begin |
| 5257 |
NewItem.Free; |
| 5258 |
Result := -1; |
| 5259 |
end; |
| 5260 |
end |
| 5261 |
end; |
| 5262 |
end; |
| 5263 |
end; |
| 5264 |
|
| 5265 |
procedure TJclCompressArchive.CheckNotCompressing; |
| 5266 |
begin |
| 5267 |
if FCompressing then |
| 5268 |
raise EJclCompressionError.CreateRes(@RsCompressionCompressingError); |
| 5269 |
end; |
| 5270 |
|
| 5271 |
procedure TJclCompressArchive.Compress; |
| 5272 |
begin |
| 5273 |
// Calling ReleaseVolumes here causes subsequent operations on the archive to fail with an "unsupported method" exception |
| 5274 |
// ReleaseVolumes; |
| 5275 |
end; |
| 5276 |
|
| 5277 |
procedure TJclCompressArchive.InternalAddDirectory(const Directory: string); |
| 5278 |
begin |
| 5279 |
AddDirectory(TranslateItemPath(Directory, FBaseDirName, FBaseRelName), Directory, False, FAddFilesInDir); |
| 5280 |
end; |
| 5281 |
|
| 5282 |
procedure TJclCompressArchive.InternalAddFile(const Directory: string; |
| 5283 |
const FileInfo: TSearchRec); |
| 5284 |
var |
| 5285 |
AFileName: TFileName; |
| 5286 |
AItem: TJclCompressionItem; |
| 5287 |
begin |
| 5288 |
AFileName := PathAddSeparator(Directory) + FileInfo.Name; |
| 5289 |
|
| 5290 |
AItem := GetItemClass.Create(Self); |
| 5291 |
try |
| 5292 |
AItem.PackedName := TranslateItemPath(AFileName, FBaseDirName, FBaseRelName); |
| 5293 |
AItem.FileName := AFileName; |
| 5294 |
except |
| 5295 |
AItem.Destroy; |
| 5296 |
raise; |
| 5297 |
end; |
| 5298 |
|
| 5299 |
AddFileCheckDuplicate(AItem); |
| 5300 |
end; |
| 5301 |
|
| 5302 |
function TJclCompressArchive.ItemAccess: TJclStreamAccess; |
| 5303 |
begin |
| 5304 |
Result := saReadOnly; |
| 5305 |
end; |
| 5306 |
|
| 5307 |
class function TJclCompressArchive.VolumeAccess: TJclStreamAccess; |
| 5308 |
begin |
| 5309 |
Result := saWriteOnly; |
| 5310 |
end; |
| 5311 |
|
| 5312 |
//=== { TJclDecompressItem } ================================================= |
| 5313 |
|
| 5314 |
procedure TJclDecompressItem.CheckGetProperty( |
| 5315 |
AProperty: TJclCompressionItemProperty); |
| 5316 |
begin |
| 5317 |
// TODO |
| 5318 |
end; |
| 5319 |
|
| 5320 |
procedure TJclDecompressItem.CheckSetProperty( |
| 5321 |
AProperty: TJclCompressionItemProperty); |
| 5322 |
begin |
| 5323 |
(Archive as TJclDecompressArchive).CheckNotDecompressing; |
| 5324 |
end; |
| 5325 |
|
| 5326 |
function TJclDecompressItem.ValidateExtraction(Index: Integer): Boolean; |
| 5327 |
begin |
| 5328 |
Result := (FArchive as TJclDecompressArchive).ValidateExtraction(Index, |
| 5329 |
FFileName, FStream, FOwnsStream); |
| 5330 |
end; |
| 5331 |
|
| 5332 |
//=== { TJclDecompressArchive } ============================================== |
| 5333 |
|
| 5334 |
procedure TJclDecompressArchive.CheckListing; |
| 5335 |
begin |
| 5336 |
if not FListing then |
| 5337 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty); |
| 5338 |
end; |
| 5339 |
|
| 5340 |
procedure TJclDecompressArchive.CheckNotDecompressing; |
| 5341 |
begin |
| 5342 |
if FDecompressing then |
| 5343 |
raise EJclCompressionError.CreateRes(@RsCompressionDecompressingError); |
| 5344 |
end; |
| 5345 |
|
| 5346 |
procedure TJclDecompressArchive.ExtractAll(const ADestinationDir: string; |
| 5347 |
AAutoCreateSubDir: Boolean); |
| 5348 |
begin |
| 5349 |
// Calling ReleaseVolumes here causes subsequent operations on the archive to fail with an "unsupported method" exception |
| 5350 |
// ReleaseVolumes; |
| 5351 |
end; |
| 5352 |
|
| 5353 |
procedure TJclDecompressArchive.ExtractSelected(const ADestinationDir: string; |
| 5354 |
AAutoCreateSubDir: Boolean); |
| 5355 |
begin |
| 5356 |
// Calling ReleaseVolumes here causes subsequent operations on the archive to fail with an "unsupported method" exception |
| 5357 |
// ReleaseVolumes; |
| 5358 |
end; |
| 5359 |
|
| 5360 |
function TJclDecompressArchive.ItemAccess: TJclStreamAccess; |
| 5361 |
begin |
| 5362 |
Result := saCreate; |
| 5363 |
end; |
| 5364 |
|
| 5365 |
function TJclDecompressArchive.ValidateExtraction(Index: Integer; |
| 5366 |
var FileName: TFileName; var AStream: TStream; var AOwnsStream: Boolean): Boolean; |
| 5367 |
var |
| 5368 |
AItem: TJclCompressionItem; |
| 5369 |
PackedName: TFileName; |
| 5370 |
begin |
| 5371 |
if FExtractingAllIndex <> -1 then |
| 5372 |
// extracting all |
| 5373 |
FExtractingAllIndex := Index; |
| 5374 |
|
| 5375 |
AItem := Items[Index]; |
| 5376 |
|
| 5377 |
if (FileName = '') and not Assigned(AStream) then |
| 5378 |
begin |
| 5379 |
PackedName := AItem.PackedName; |
| 5380 |
|
| 5381 |
if PackedName = '' then |
| 5382 |
PackedName := ChangeFileExt(ExtractFileName(Volumes[0].FileName), AItem.PackedExtension); |
| 5383 |
|
| 5384 |
FileName := PathGetRelativePath(FDestinationDir, PackedName); |
| 5385 |
end; |
| 5386 |
Result := True; |
| 5387 |
|
| 5388 |
if Assigned(FOnExtract) then |
| 5389 |
Result := FOnExtract(Self, Index, FileName, AStream, AOwnsStream); |
| 5390 |
|
| 5391 |
if Result and not Assigned(AStream) and AutoCreateSubDir then |
| 5392 |
begin |
| 5393 |
if (AItem.Attributes and faDirectory) <> 0 then |
| 5394 |
ForceDirectories(FileName) |
| 5395 |
else |
| 5396 |
ForceDirectories(ExtractFilePath(FileName)); |
| 5397 |
end; |
| 5398 |
end; |
| 5399 |
|
| 5400 |
class function TJclDecompressArchive.VolumeAccess: TJclStreamAccess; |
| 5401 |
begin |
| 5402 |
Result := saReadOnly; |
| 5403 |
end; |
| 5404 |
|
| 5405 |
//=== { TJclUpdateItem } ===================================================== |
| 5406 |
|
| 5407 |
procedure TJclUpdateItem.CheckGetProperty( |
| 5408 |
AProperty: TJclCompressionItemProperty); |
| 5409 |
begin |
| 5410 |
// TODO |
| 5411 |
end; |
| 5412 |
|
| 5413 |
procedure TJclUpdateItem.CheckSetProperty( |
| 5414 |
AProperty: TJclCompressionItemProperty); |
| 5415 |
begin |
| 5416 |
(Archive as TJclCompressArchive).CheckNotCompressing; |
| 5417 |
end; |
| 5418 |
|
| 5419 |
function TJclUpdateItem.ValidateExtraction(Index: Integer): Boolean; |
| 5420 |
begin |
| 5421 |
Result := (Archive as TJclUpdateArchive).ValidateExtraction(Index, FFileName, |
| 5422 |
FStream, FOwnsStream); |
| 5423 |
end; |
| 5424 |
|
| 5425 |
//=== { TJclUpdateArchive } ================================================== |
| 5426 |
|
| 5427 |
procedure TJclUpdateArchive.CheckListing; |
| 5428 |
begin |
| 5429 |
if not FListing then |
| 5430 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty); |
| 5431 |
end; |
| 5432 |
|
| 5433 |
procedure TJclUpdateArchive.CheckNotDecompressing; |
| 5434 |
begin |
| 5435 |
if FDecompressing then |
| 5436 |
raise EJclCompressionError.CreateRes(@RsCompressionDecompressingError); |
| 5437 |
end; |
| 5438 |
|
| 5439 |
procedure TJclUpdateArchive.ExtractAll(const ADestinationDir: string; |
| 5440 |
AAutoCreateSubDir: Boolean); |
| 5441 |
begin |
| 5442 |
// Calling ReleaseVolumes here causes subsequent operations on the archive to fail with an "unsupported method" exception |
| 5443 |
// ReleaseVolumes; |
| 5444 |
end; |
| 5445 |
|
| 5446 |
procedure TJclUpdateArchive.ExtractSelected(const ADestinationDir: string; |
| 5447 |
AAutoCreateSubDir: Boolean); |
| 5448 |
begin |
| 5449 |
// Calling ReleaseVolumes here causes subsequent operations on the archive to fail with an "unsupported method" exception |
| 5450 |
// ReleaseVolumes; |
| 5451 |
end; |
| 5452 |
|
| 5453 |
procedure TJclUpdateArchive.InitializeArchiveProperties; |
| 5454 |
begin |
| 5455 |
inherited InitializeArchiveProperties; |
| 5456 |
FDuplicateCheck := dcExisting; |
| 5457 |
end; |
| 5458 |
|
| 5459 |
function TJclUpdateArchive.ItemAccess: TJclStreamAccess; |
| 5460 |
begin |
| 5461 |
if FDecompressing then Result := saCreate |
| 5462 |
else Result := saReadOnly; |
| 5463 |
end; |
| 5464 |
|
| 5465 |
function TJclUpdateArchive.ValidateExtraction(Index: Integer; |
| 5466 |
var FileName: TFileName; var AStream: TStream; |
| 5467 |
var AOwnsStream: Boolean): Boolean; |
| 5468 |
var |
| 5469 |
AItem: TJclCompressionItem; |
| 5470 |
PackedName: TFileName; |
| 5471 |
begin |
| 5472 |
if FExtractingAllIndex <> -1 then |
| 5473 |
// extracting all |
| 5474 |
FExtractingAllIndex := Index; |
| 5475 |
|
| 5476 |
AItem := Items[Index]; |
| 5477 |
|
| 5478 |
if (FileName = '') and not Assigned(AStream) then |
| 5479 |
begin |
| 5480 |
PackedName := AItem.PackedName; |
| 5481 |
|
| 5482 |
if PackedName = '' then |
| 5483 |
PackedName := ChangeFileExt(ExtractFileName(Volumes[0].FileName), AItem.PackedExtension); |
| 5484 |
|
| 5485 |
FileName := PathGetRelativePath(FDestinationDir, PackedName); |
| 5486 |
end; |
| 5487 |
Result := True; |
| 5488 |
|
| 5489 |
if Assigned(FOnExtract) then |
| 5490 |
Result := FOnExtract(Self, Index, FileName, AStream, AOwnsStream); |
| 5491 |
|
| 5492 |
if Result and not Assigned(AStream) and AutoCreateSubDir then |
| 5493 |
begin |
| 5494 |
if (AItem.Attributes and faDirectory) <> 0 then |
| 5495 |
ForceDirectories(FileName) |
| 5496 |
else |
| 5497 |
ForceDirectories(ExtractFilePath(FileName)); |
| 5498 |
end; |
| 5499 |
end; |
| 5500 |
|
| 5501 |
class function TJclUpdateArchive.VolumeAccess: TJclStreamAccess; |
| 5502 |
begin |
| 5503 |
Result := saReadOnly; |
| 5504 |
end; |
| 5505 |
|
| 5506 |
//=== { TJclOutOfPlaceUpdateArchive } ======================================== |
| 5507 |
|
| 5508 |
procedure TJclOutOfPlaceUpdateArchive.Compress; |
| 5509 |
var |
| 5510 |
Index: Integer; |
| 5511 |
AVolume: TJclCompressionVolume; |
| 5512 |
SrcFileName, DestFileName: TFileName; |
| 5513 |
SrcStream, DestStream: TStream; |
| 5514 |
OwnsSrcStream, OwnsDestStream, AllHandled, Handled: Boolean; |
| 5515 |
CopiedSize: Int64; |
| 5516 |
begin |
| 5517 |
// release volume streams and other finalization |
| 5518 |
inherited Compress; |
| 5519 |
|
| 5520 |
if ReplaceVolumes then |
| 5521 |
begin |
| 5522 |
AllHandled := True; |
| 5523 |
|
| 5524 |
// replace streams by tmp streams |
| 5525 |
for Index := 0 to FVolumes.Count - 1 do |
| 5526 |
begin |
| 5527 |
AVolume := TJclCompressionVolume(FVolumes.Items[Index]); |
| 5528 |
|
| 5529 |
SrcFileName := AVolume.TmpFileName; |
| 5530 |
DestFileName := AVolume.FileName; |
| 5531 |
SrcStream := AVolume.TmpStream; |
| 5532 |
DestStream := AVolume.Stream; |
| 5533 |
OwnsSrcStream := AVolume.OwnsTmpStream; |
| 5534 |
OwnsDestStream := AVolume.OwnsStream; |
| 5535 |
|
| 5536 |
Handled := Assigned(FOnReplace) and FOnReplace(Self, SrcFileName, DestFileName, SrcStream, DestStream, OwnsSrcStream, OwnsDestStream); |
| 5537 |
|
| 5538 |
if not Handled then |
| 5539 |
begin |
| 5540 |
if (SrcFileName <> '') and (DestFileName <> '') and |
| 5541 |
(OwnsSrcStream or not Assigned(SrcStream)) and |
| 5542 |
(OwnsDestStream or not Assigned(DestStream)) then |
| 5543 |
begin |
| 5544 |
// close references before moving files |
| 5545 |
if OwnsSrcStream then |
| 5546 |
FreeAndNil(SrcStream); |
| 5547 |
if OwnsDestStream then |
| 5548 |
FreeAndNil(DestStream); |
| 5549 |
Handled := FileMove(SrcFileName, DestFileName, True); |
| 5550 |
end |
| 5551 |
else |
| 5552 |
if (SrcFileName = '') and (DestFileName = '') and Assigned(SrcStream) and Assigned(DestStream) then |
| 5553 |
begin |
| 5554 |
// in-memory moves |
| 5555 |
SrcStream.Seek(0, soBeginning); |
| 5556 |
DestStream.Seek(0, soBeginning); |
| 5557 |
CopiedSize := StreamCopy(SrcStream, DestStream); |
| 5558 |
// reset size |
| 5559 |
DestStream.Size := CopiedSize; |
| 5560 |
Handled := True; |
| 5561 |
end; |
| 5562 |
// identity |
| 5563 |
// else |
| 5564 |
// Handled := False; |
| 5565 |
end; |
| 5566 |
|
| 5567 |
// update volume information |
| 5568 |
AVolume.FTmpStream := SrcStream; |
| 5569 |
AVolume.FStream := DestStream; |
| 5570 |
AVolume.FOwnsTmpStream := OwnsSrcStream; |
| 5571 |
AVolume.FOwnsStream := OwnsDestStream; |
| 5572 |
AVolume.FTmpFileName := SrcFileName; |
| 5573 |
AVolume.FFileName := DestFileName; |
| 5574 |
|
| 5575 |
AllHandled := AllHandled and Handled; |
| 5576 |
end; |
| 5577 |
if not AllHandled then |
| 5578 |
raise EJclCompressionError.CreateRes(@RsCompressionReplaceError); |
| 5579 |
end |
| 5580 |
else begin |
| 5581 |
// Remove temporary files |
| 5582 |
for Index := 0 to FVolumes.Count - 1 do |
| 5583 |
begin |
| 5584 |
AVolume := TJclCompressionVolume(FVolumes.Items[Index]); |
| 5585 |
if AVolume.OwnsTmpStream then |
| 5586 |
begin |
| 5587 |
FreeAndNil(AVolume.FTmpStream); |
| 5588 |
FileDelete(AVolume.TmpFileName); |
| 5589 |
end; |
| 5590 |
end; |
| 5591 |
end; |
| 5592 |
end; |
| 5593 |
|
| 5594 |
procedure TJclOutOfPlaceUpdateArchive.InitializeArchiveProperties; |
| 5595 |
begin |
| 5596 |
inherited InitializeArchiveProperties; |
| 5597 |
FReplaceVolumes := True; |
| 5598 |
FTmpVolumeIndex := -1; |
| 5599 |
end; |
| 5600 |
|
| 5601 |
function TJclOutOfPlaceUpdateArchive.InternalOpenTmpStream( |
| 5602 |
const FileName: TFileName): TStream; |
| 5603 |
begin |
| 5604 |
Result := OpenFileStream(FileName, TmpVolumeAccess); |
| 5605 |
end; |
| 5606 |
|
| 5607 |
function TJclOutOfPlaceUpdateArchive.NeedTmpStream(Index: Integer): TStream; |
| 5608 |
var |
| 5609 |
AVolume: TJclCompressionVolume; |
| 5610 |
AOwnsStream: Boolean; |
| 5611 |
AFileName: TFileName; |
| 5612 |
begin |
| 5613 |
Result := nil; |
| 5614 |
|
| 5615 |
if Index <> FTmpVolumeIndex then |
| 5616 |
begin |
| 5617 |
AOwnsStream := VolumeFileNameMask <> ''; |
| 5618 |
AVolume := nil; |
| 5619 |
if VolumeFileNameMask = '' then AFileName := '' |
| 5620 |
else AFileName := FindUnusedFileName(Format(VolumeFileNameMask, [Index + VolumeIndexOffset]), '.tmp'); |
| 5621 |
if (Index >= 0) and (Index < FVolumes.Count) then |
| 5622 |
begin |
| 5623 |
AVolume := TJclCompressionVolume(FVolumes.Items[Index]); |
| 5624 |
Result := AVolume.TmpStream; |
| 5625 |
AOwnsStream := AVolume.OwnsTmpStream; |
| 5626 |
AFileName := AVolume.TmpFileName; |
| 5627 |
if (AFileName = '') and (AVolume.FileName <> '') then |
| 5628 |
AFileName := FindUnusedFileName(AVolume.FileName, '.tmp'); |
| 5629 |
end; |
| 5630 |
|
| 5631 |
if Assigned(FOnTmpVolume) then |
| 5632 |
FOnTmpVolume(Self, Index, AFileName, Result, AOwnsStream); |
| 5633 |
|
| 5634 |
if Assigned(AVolume) then |
| 5635 |
begin |
| 5636 |
if not Assigned(Result) then |
| 5637 |
Result := InternalOpenTmpStream(AFileName); |
| 5638 |
AVolume.FTmpFileName := AFileName; |
| 5639 |
AVolume.FTmpStream := Result; |
| 5640 |
AVolume.FOwnsTmpStream := AOwnsStream; |
| 5641 |
end |
| 5642 |
else |
| 5643 |
begin |
| 5644 |
while FVolumes.Count < Index do |
| 5645 |
FVolumes.Add(TJclCompressionVolume.Create(nil, nil, True, True, Format(VolumeFileNameMask, [Index + VolumeIndexOffset]), '', FVolumeMaxSize)); |
| 5646 |
if not Assigned(Result) then |
| 5647 |
Result := InternalOpenTmpStream(AFileName); |
| 5648 |
if Assigned(Result) then |
| 5649 |
begin |
| 5650 |
if Index < FVolumes.Count then |
| 5651 |
begin |
| 5652 |
AVolume := TJclCompressionVolume(FVolumes.Items[Index]); |
| 5653 |
AVolume.FTmpFileName := AFileName; |
| 5654 |
AVolume.FTmpStream := Result; |
| 5655 |
AVolume.FOwnsTmpStream := AOwnsStream; |
| 5656 |
AVolume.FVolumeMaxSize := FVolumeMaxSize; |
| 5657 |
end |
| 5658 |
else |
| 5659 |
FVolumes.Add(TJclCompressionVolume.Create(nil, Result, True, AOwnsStream, '', AFileName, FVolumeMaxSize)); |
| 5660 |
end; |
| 5661 |
end; |
| 5662 |
FTmpVolumeIndex := Index; |
| 5663 |
end |
| 5664 |
else |
| 5665 |
if (Index >= 0) and (Index < FVolumes.Count) then |
| 5666 |
begin |
| 5667 |
AVolume := TJclCompressionVolume(FVolumes.Items[Index]); |
| 5668 |
Result := AVolume.TmpStream; |
| 5669 |
if Assigned(Result) then |
| 5670 |
Result.Seek(0, soBeginning); |
| 5671 |
end |
| 5672 |
else |
| 5673 |
FTmpVolumeIndex := Index; |
| 5674 |
end; |
| 5675 |
|
| 5676 |
class function TJclOutOfPlaceUpdateArchive.TmpVolumeAccess: TJclStreamAccess; |
| 5677 |
begin |
| 5678 |
Result := saWriteOnly; |
| 5679 |
end; |
| 5680 |
|
| 5681 |
//=== { TJclSevenzipOutStream } ============================================== |
| 5682 |
|
| 5683 |
constructor TJclSevenzipOutStream.Create(AArchive: TJclCompressionArchive; AItemIndex: Integer); |
| 5684 |
begin |
| 5685 |
inherited Create; |
| 5686 |
|
| 5687 |
FArchive := AArchive; |
| 5688 |
FItemIndex := AItemIndex; |
| 5689 |
FStream := nil; |
| 5690 |
FOwnsStream := False; |
| 5691 |
FMaximumPosition := 0; |
| 5692 |
FTruncateOnRelease := False; |
| 5693 |
|
| 5694 |
NeedStream; |
| 5695 |
end; |
| 5696 |
|
| 5697 |
constructor TJclSevenzipOutStream.Create(AStream: TStream; AOwnsStream: Boolean; ATruncateOnRelease: Boolean); |
| 5698 |
begin |
| 5699 |
inherited Create; |
| 5700 |
|
| 5701 |
FArchive := nil; |
| 5702 |
FItemIndex := -1; |
| 5703 |
FStream := AStream; |
| 5704 |
FOwnsStream := AOwnsStream; |
| 5705 |
FMaximumPosition := 0; |
| 5706 |
FTruncateOnRelease := ATruncateOnRelease; |
| 5707 |
end; |
| 5708 |
|
| 5709 |
destructor TJclSevenzipOutStream.Destroy; |
| 5710 |
begin |
| 5711 |
ReleaseStream; |
| 5712 |
|
| 5713 |
inherited Destroy; |
| 5714 |
end; |
| 5715 |
|
| 5716 |
procedure TJclSevenzipOutStream.NeedStream; |
| 5717 |
begin |
| 5718 |
if Assigned(FArchive) then |
| 5719 |
begin |
| 5720 |
FArchive.FCurrentItemIndex := FItemIndex; |
| 5721 |
if not Assigned(FStream) then |
| 5722 |
FStream := FArchive.Items[FItemIndex].Stream; |
| 5723 |
end; |
| 5724 |
end; |
| 5725 |
|
| 5726 |
procedure TJclSevenzipOutStream.ReleaseStream; |
| 5727 |
begin |
| 5728 |
// truncate to the maximum position that was written |
| 5729 |
if FTruncateOnRelease then |
| 5730 |
FStream.Size := FMaximumPosition; |
| 5731 |
|
| 5732 |
if Assigned(FArchive) then |
| 5733 |
FArchive.Items[FItemIndex].ReleaseStream |
| 5734 |
else |
| 5735 |
if FOwnsStream then |
| 5736 |
FStream.Free; |
| 5737 |
end; |
| 5738 |
|
| 5739 |
function TJclSevenzipOutStream.Seek(Offset: Int64; SeekOrigin: Cardinal; |
| 5740 |
NewPosition: PInt64): HRESULT; |
| 5741 |
var |
| 5742 |
NewPos: Int64; |
| 5743 |
begin |
| 5744 |
NeedStream; |
| 5745 |
|
| 5746 |
if Assigned(FStream) then |
| 5747 |
begin |
| 5748 |
Result := S_OK; |
| 5749 |
// STREAM_SEEK_SET = 0 = soBeginning |
| 5750 |
// STREAM_SEEK_CUR = 1 = soCurrent |
| 5751 |
// STREAM_SEEK_END = 2 = soEnd |
| 5752 |
NewPos := FStream.Seek(Offset, TSeekOrigin(SeekOrigin)); |
| 5753 |
if Assigned(NewPosition) then |
| 5754 |
NewPosition^ := NewPos; |
| 5755 |
end |
| 5756 |
else |
| 5757 |
Result := S_FALSE; |
| 5758 |
end; |
| 5759 |
|
| 5760 |
function TJclSevenzipOutStream.SetSize(NewSize: Int64): HRESULT; |
| 5761 |
begin |
| 5762 |
NeedStream; |
| 5763 |
|
| 5764 |
if Assigned(FStream) then |
| 5765 |
begin |
| 5766 |
Result := S_OK; |
| 5767 |
FStream.Size := NewSize; |
| 5768 |
if FTruncateOnRelease and (FMaximumPosition < NewSize) then |
| 5769 |
FMaximumPosition := NewSize; |
| 5770 |
end |
| 5771 |
else |
| 5772 |
Result := S_FALSE; |
| 5773 |
end; |
| 5774 |
|
| 5775 |
function TJclSevenzipOutStream.Write(Data: Pointer; Size: Cardinal; |
| 5776 |
ProcessedSize: PCardinal): HRESULT; |
| 5777 |
var |
| 5778 |
Processed: Cardinal; |
| 5779 |
APosition: Int64; |
| 5780 |
begin |
| 5781 |
NeedStream; |
| 5782 |
|
| 5783 |
if Assigned(FStream) then |
| 5784 |
begin |
| 5785 |
Result := S_OK; |
| 5786 |
Processed := FStream.Write(Data^, Size); |
| 5787 |
if Assigned(ProcessedSize) then |
| 5788 |
ProcessedSize^ := Processed; |
| 5789 |
if FTruncateOnRelease then |
| 5790 |
begin |
| 5791 |
APosition := FStream.Position; |
| 5792 |
if FMaximumPosition < APosition then |
| 5793 |
FMaximumPosition := APosition; |
| 5794 |
end; |
| 5795 |
end |
| 5796 |
else |
| 5797 |
Result := S_FALSE; |
| 5798 |
end; |
| 5799 |
|
| 5800 |
//=== { TJclSevenzipNestedInStream } ========================================= |
| 5801 |
|
| 5802 |
constructor TJclSevenzipNestedInStream.Create(AInStream: IInStream); |
| 5803 |
begin |
| 5804 |
inherited Create; |
| 5805 |
FInStream := AInStream; |
| 5806 |
end; |
| 5807 |
|
| 5808 |
function TJclSevenzipNestedInStream.Read(var Buffer; Count: Integer): Longint; |
| 5809 |
begin |
| 5810 |
SevenzipCheck(FInStream.Read(@Buffer, Count, @Result)); |
| 5811 |
end; |
| 5812 |
|
| 5813 |
function TJclSevenzipNestedInStream.Seek(const Offset: Int64; |
| 5814 |
Origin: TSeekOrigin): Int64; |
| 5815 |
begin |
| 5816 |
SevenzipCheck(FInStream.Seek(Offset, Cardinal(Origin), @Result)); |
| 5817 |
end; |
| 5818 |
|
| 5819 |
procedure TJclSevenzipNestedInStream.SetSize(const NewSize: Int64); |
| 5820 |
begin |
| 5821 |
raise EJclCompressionError.CreateRes(@RsCompressionWriteNotSupported); |
| 5822 |
end; |
| 5823 |
|
| 5824 |
function TJclSevenzipNestedInStream.Write(const Buffer; |
| 5825 |
Count: Integer): Longint; |
| 5826 |
begin |
| 5827 |
raise EJclCompressionError.CreateRes(@RsCompressionWriteNotSupported); |
| 5828 |
end; |
| 5829 |
|
| 5830 |
//=== { TJclSevenzipInStream } =============================================== |
| 5831 |
|
| 5832 |
constructor TJclSevenzipInStream.Create(AArchive: TJclCompressionArchive; AItemIndex: Integer); |
| 5833 |
begin |
| 5834 |
inherited Create; |
| 5835 |
|
| 5836 |
FArchive := AArchive; |
| 5837 |
FItemIndex := AItemIndex; |
| 5838 |
FStream := nil; |
| 5839 |
FOwnsStream := False; |
| 5840 |
|
| 5841 |
NeedStream; |
| 5842 |
end; |
| 5843 |
|
| 5844 |
constructor TJclSevenzipInStream.Create(AStream: TStream; AOwnsStream: Boolean); |
| 5845 |
begin |
| 5846 |
inherited Create; |
| 5847 |
|
| 5848 |
FArchive := nil; |
| 5849 |
FItemIndex := -1; |
| 5850 |
FStream := AStream; |
| 5851 |
FOwnsStream := AOwnsStream; |
| 5852 |
end; |
| 5853 |
|
| 5854 |
destructor TJclSevenzipInStream.Destroy; |
| 5855 |
begin |
| 5856 |
ReleaseStream; |
| 5857 |
inherited Destroy; |
| 5858 |
end; |
| 5859 |
|
| 5860 |
function TJclSevenzipInStream.GetSize(Size: PInt64): HRESULT; |
| 5861 |
begin |
| 5862 |
NeedStream; |
| 5863 |
|
| 5864 |
if Assigned(FStream) then |
| 5865 |
begin |
| 5866 |
if Assigned(Size) then |
| 5867 |
Size^ := FStream.Size; |
| 5868 |
Result := S_OK; |
| 5869 |
end |
| 5870 |
else |
| 5871 |
Result := S_FALSE; |
| 5872 |
end; |
| 5873 |
|
| 5874 |
procedure TJclSevenzipInStream.NeedStream; |
| 5875 |
begin |
| 5876 |
if Assigned(FArchive) then |
| 5877 |
begin |
| 5878 |
FArchive.FCurrentItemIndex := FItemIndex; |
| 5879 |
if not Assigned(FStream) then |
| 5880 |
FStream := FArchive.Items[FItemIndex].Stream; |
| 5881 |
end; |
| 5882 |
end; |
| 5883 |
|
| 5884 |
function TJclSevenzipInStream.Read(Data: Pointer; Size: Cardinal; |
| 5885 |
ProcessedSize: PCardinal): HRESULT; |
| 5886 |
var |
| 5887 |
Processed: Cardinal; |
| 5888 |
begin |
| 5889 |
NeedStream; |
| 5890 |
|
| 5891 |
if Assigned(FStream) then |
| 5892 |
begin |
| 5893 |
Processed := FStream.Read(Data^, Size); |
| 5894 |
if Assigned(ProcessedSize) then |
| 5895 |
ProcessedSize^ := Processed; |
| 5896 |
Result := S_OK; |
| 5897 |
end |
| 5898 |
else |
| 5899 |
Result := S_FALSE; |
| 5900 |
end; |
| 5901 |
|
| 5902 |
procedure TJclSevenzipInStream.ReleaseStream; |
| 5903 |
begin |
| 5904 |
if Assigned(FArchive) then |
| 5905 |
FArchive.Items[FItemIndex].ReleaseStream |
| 5906 |
else |
| 5907 |
if FOwnsStream then |
| 5908 |
FStream.Free; |
| 5909 |
end; |
| 5910 |
|
| 5911 |
function TJclSevenzipInStream.Seek(Offset: Int64; SeekOrigin: Cardinal; |
| 5912 |
NewPosition: PInt64): HRESULT; |
| 5913 |
var |
| 5914 |
NewPos: Int64; |
| 5915 |
begin |
| 5916 |
NeedStream; |
| 5917 |
|
| 5918 |
if Assigned(FStream) then |
| 5919 |
begin |
| 5920 |
// STREAM_SEEK_SET = 0 = soBeginning |
| 5921 |
// STREAM_SEEK_CUR = 1 = soCurrent |
| 5922 |
// STREAM_SEEK_END = 2 = soEnd |
| 5923 |
NewPos := FStream.Seek(Offset, TSeekOrigin(SeekOrigin)); |
| 5924 |
if Assigned(NewPosition) then |
| 5925 |
NewPosition^ := NewPos; |
| 5926 |
Result := S_OK; |
| 5927 |
end |
| 5928 |
else |
| 5929 |
Result := S_FALSE; |
| 5930 |
end; |
| 5931 |
|
| 5932 |
// sevenzip helper functions |
| 5933 |
|
| 5934 |
procedure SevenzipCheck(Value: HRESULT); |
| 5935 |
begin |
| 5936 |
if (Value <> S_OK) and (Value <> E_ABORT) then |
| 5937 |
raise EJclCompressionError.CreateResFmt(@RsCompression7zReturnError, [Value, SysErrorMessage(Value)]); |
| 5938 |
end; |
| 5939 |
|
| 5940 |
function Get7zWideStringProp(const AArchive: IInArchive; ItemIndex: Integer; |
| 5941 |
PropID: Cardinal; const Setter: TWideStringSetter): Boolean; |
| 5942 |
var |
| 5943 |
Value: TPropVariant; |
| 5944 |
begin |
| 5945 |
ZeroMemory(@Value, SizeOf(Value)); |
| 5946 |
SevenzipCheck(AArchive.GetProperty(ItemIndex, PropID, Value)); |
| 5947 |
case Value.vt of |
| 5948 |
VT_EMPTY, VT_NULL: |
| 5949 |
Result := False; |
| 5950 |
VT_LPSTR: |
| 5951 |
begin |
| 5952 |
Result := True; |
| 5953 |
Setter(WideString(AnsiString(Value.pszVal))); |
| 5954 |
end; |
| 5955 |
VT_LPWSTR: |
| 5956 |
begin |
| 5957 |
Result := True; |
| 5958 |
Setter(Value.pwszVal); |
| 5959 |
end; |
| 5960 |
VT_BSTR: |
| 5961 |
begin |
| 5962 |
Result := True; |
| 5963 |
Setter(Value.bstrVal); |
| 5964 |
SysFreeString(Value.bstrVal); |
| 5965 |
end; |
| 5966 |
VT_I1: |
| 5967 |
begin |
| 5968 |
Result := True; |
| 5969 |
Setter(IntToStr(Value.iVal)); |
| 5970 |
end; |
| 5971 |
VT_I2: |
| 5972 |
begin |
| 5973 |
Result := True; |
| 5974 |
Setter(IntToStr(Value.iVal)); |
| 5975 |
end; |
| 5976 |
VT_INT, VT_I4: |
| 5977 |
begin |
| 5978 |
Result := True; |
| 5979 |
Setter(IntToStr(Value.lVal)); |
| 5980 |
end; |
| 5981 |
VT_I8: |
| 5982 |
begin |
| 5983 |
Result := True; |
| 5984 |
Setter(IntToStr(Value.hVal.QuadPart)); |
| 5985 |
end; |
| 5986 |
VT_UI1: |
| 5987 |
begin |
| 5988 |
Result := True; |
| 5989 |
Setter(IntToStr(Value.bVal)); |
| 5990 |
end; |
| 5991 |
VT_UI2: |
| 5992 |
begin |
| 5993 |
Result := True; |
| 5994 |
Setter(IntToStr(Value.uiVal)); |
| 5995 |
end; |
| 5996 |
VT_UINT, VT_UI4: |
| 5997 |
begin |
| 5998 |
Result := True; |
| 5999 |
Setter(IntToStr(Value.ulVal)); |
| 6000 |
end; |
| 6001 |
VT_UI8: |
| 6002 |
begin |
| 6003 |
Result := True; |
| 6004 |
Setter(IntToStr(Value.uhVal.QuadPart)); |
| 6005 |
end; |
| 6006 |
else |
| 6007 |
raise EJclCompressionError.CreateResFmt(@RsCompression7zUnknownValueType, [Value.vt, PropID]); |
| 6008 |
end; |
| 6009 |
end; |
| 6010 |
|
| 6011 |
function Get7zCardinalProp(const AArchive: IInArchive; ItemIndex: Integer; |
| 6012 |
PropID: Cardinal; const Setter: TCardinalSetter): Boolean; |
| 6013 |
var |
| 6014 |
Value: TPropVariant; |
| 6015 |
begin |
| 6016 |
ZeroMemory(@Value, SizeOf(Value)); |
| 6017 |
SevenzipCheck(AArchive.GetProperty(ItemIndex, PropID, Value)); |
| 6018 |
case Value.vt of |
| 6019 |
VT_EMPTY, VT_NULL: |
| 6020 |
Result := False; |
| 6021 |
VT_I1, VT_I2, VT_INT, VT_I4, VT_I8, |
| 6022 |
VT_UI1, VT_UI2, VT_UINT, VT_UI4, VT_UI8: |
| 6023 |
begin |
| 6024 |
Result := True; |
| 6025 |
case Value.vt of |
| 6026 |
VT_I1: |
| 6027 |
Setter(Value.iVal); |
| 6028 |
VT_I2: |
| 6029 |
Setter(Value.iVal); |
| 6030 |
VT_INT, VT_I4: |
| 6031 |
Setter(Value.lVal); |
| 6032 |
VT_I8: |
| 6033 |
Setter(Value.hVal.QuadPart); |
| 6034 |
VT_UI1: |
| 6035 |
Setter(Value.bVal); |
| 6036 |
VT_UI2: |
| 6037 |
Setter(Value.uiVal); |
| 6038 |
VT_UINT, VT_UI4: |
| 6039 |
Setter(Value.ulVal); |
| 6040 |
VT_UI8: |
| 6041 |
Setter(Value.uhVal.QuadPart); |
| 6042 |
end; |
| 6043 |
end; |
| 6044 |
else |
| 6045 |
raise EJclCompressionError.CreateResFmt(@RsCompression7zUnknownValueType, [Value.vt, PropID]); |
| 6046 |
end; |
| 6047 |
end; |
| 6048 |
|
| 6049 |
function Get7zInt64Prop(const AArchive: IInArchive; ItemIndex: Integer; |
| 6050 |
PropID: Cardinal; const Setter: TInt64Setter): Boolean; |
| 6051 |
var |
| 6052 |
Value: TPropVariant; |
| 6053 |
begin |
| 6054 |
ZeroMemory(@Value, SizeOf(Value)); |
| 6055 |
SevenzipCheck(AArchive.GetProperty(ItemIndex, PropID, Value)); |
| 6056 |
case Value.vt of |
| 6057 |
VT_EMPTY, VT_NULL: |
| 6058 |
Result := False; |
| 6059 |
VT_I1, VT_I2, VT_INT, VT_I4, VT_I8, |
| 6060 |
VT_UI1, VT_UI2, VT_UINT, VT_UI4, VT_UI8: |
| 6061 |
begin |
| 6062 |
Result := True; |
| 6063 |
case Value.vt of |
| 6064 |
VT_I1: |
| 6065 |
Setter(Value.iVal); |
| 6066 |
VT_I2: |
| 6067 |
Setter(Value.iVal); |
| 6068 |
VT_INT, VT_I4: |
| 6069 |
Setter(Value.lVal); |
| 6070 |
VT_I8: |
| 6071 |
Setter(Value.hVal.QuadPart); |
| 6072 |
VT_UI1: |
| 6073 |
Setter(Value.bVal); |
| 6074 |
VT_UI2: |
| 6075 |
Setter(Value.uiVal); |
| 6076 |
VT_UINT, VT_UI4: |
| 6077 |
Setter(Value.ulVal); |
| 6078 |
VT_UI8: |
| 6079 |
Setter(Value.uhVal.QuadPart); |
| 6080 |
end; |
| 6081 |
end; |
| 6082 |
else |
| 6083 |
raise EJclCompressionError.CreateResFmt(@RsCompression7zUnknownValueType, [Value.vt, PropID]); |
| 6084 |
end; |
| 6085 |
end; |
| 6086 |
|
| 6087 |
function Get7zFileTimeProp(const AArchive: IInArchive; ItemIndex: Integer; |
| 6088 |
PropID: Cardinal; const Setter: TFileTimeSetter): Boolean; |
| 6089 |
var |
| 6090 |
Value: TPropVariant; |
| 6091 |
begin |
| 6092 |
ZeroMemory(@Value, SizeOf(Value)); |
| 6093 |
SevenzipCheck(AArchive.GetProperty(ItemIndex, PropID, Value)); |
| 6094 |
case Value.vt of |
| 6095 |
VT_EMPTY, VT_NULL: |
| 6096 |
Result := False; |
| 6097 |
VT_FILETIME: |
| 6098 |
begin |
| 6099 |
Result := True; |
| 6100 |
Setter(Value.filetime); |
| 6101 |
end; |
| 6102 |
else |
| 6103 |
raise EJclCompressionError.CreateResFmt(@RsCompression7zUnknownValueType, [Value.vt, PropID]); |
| 6104 |
end; |
| 6105 |
end; |
| 6106 |
|
| 6107 |
function Get7zBoolProp(const AArchive: IInArchive; ItemIndex: Integer; |
| 6108 |
PropID: Cardinal; const Setter: TBoolSetter): Boolean; |
| 6109 |
var |
| 6110 |
Value: TPropVariant; |
| 6111 |
begin |
| 6112 |
ZeroMemory(@Value, SizeOf(Value)); |
| 6113 |
SevenzipCheck(AArchive.GetProperty(ItemIndex, PropID, Value)); |
| 6114 |
case Value.vt of |
| 6115 |
VT_EMPTY, VT_NULL: |
| 6116 |
Result := False; |
| 6117 |
VT_BOOL: |
| 6118 |
begin |
| 6119 |
Result := True; |
| 6120 |
Setter(Value.bool); |
| 6121 |
end; |
| 6122 |
else |
| 6123 |
raise EJclCompressionError.CreateResFmt(@RsCompression7zUnknownValueType, [Value.vt, PropID]); |
| 6124 |
end; |
| 6125 |
end; |
| 6126 |
|
| 6127 |
// TODO: Are changes for UTF-8 filenames (>= 4.58 beta) necessary? |
| 6128 |
procedure Load7zFileAttribute(AInArchive: IInArchive; ItemIndex: Integer; |
| 6129 |
AItem: TJclCompressionItem); |
| 6130 |
begin |
| 6131 |
AItem.FValidProperties := []; |
| 6132 |
AItem.FPackedIndex := ItemIndex; |
| 6133 |
AItem.FileName := ''; |
| 6134 |
AItem.Stream := nil; |
| 6135 |
AItem.OwnsStream := False; |
| 6136 |
|
| 6137 |
// sometimes, items have neither names nor extension although other properties may succeed |
| 6138 |
Get7zWideStringProp(AInArchive, ItemIndex, kpidPath, AItem.SetPackedName); |
| 6139 |
Get7zWideStringProp(AInArchive, ItemIndex, kpidExtension, AItem.SetPackedExtension); |
| 6140 |
Get7zCardinalProp(AInArchive, ItemIndex, kpidAttrib, AItem.SetAttributes); |
| 6141 |
// SetDirectory must be after SetAttributes |
| 6142 |
Get7zBoolProp(AInArchive, ItemIndex, kpidIsDir, AItem.SetDirectory); |
| 6143 |
Get7zInt64Prop(AInArchive, ItemIndex, kpidSize, AItem.SetFileSize); |
| 6144 |
Get7zInt64Prop(AInArchive, ItemIndex, kpidPackSize, AItem.SetPackedSize); |
| 6145 |
Get7zFileTimeProp(AInArchive, ItemIndex, kpidCTime, AItem.SetCreationTime); |
| 6146 |
Get7zFileTimeProp(AInArchive, ItemIndex, kpidATime, AItem.SetLastAccessTime); |
| 6147 |
Get7zFileTimeProp(AInArchive, ItemIndex, kpidMTime, AItem.SetLastWriteTime); |
| 6148 |
Get7zWideStringProp(AInArchive, ItemIndex, kpidComment, AItem.SetComment); |
| 6149 |
Get7zWideStringProp(AInArchive, ItemIndex, kpidHostOS, AItem.SetHostOS); |
| 6150 |
Get7zWideStringProp(AInArchive, ItemIndex, kpidFileSystem, AItem.SetHostFS); |
| 6151 |
Get7zWideStringProp(AInArchive, ItemIndex, kpidUser, AItem.SetUser); |
| 6152 |
Get7zWideStringProp(AInArchive, ItemIndex, kpidGroup, AItem.SetGroup); |
| 6153 |
Get7zCardinalProp(AInArchive, ItemIndex, kpidCRC, AItem.SetCRC); |
| 6154 |
Get7zWideStringProp(AInArchive, ItemIndex, kpidMethod, AItem.SetMethod); |
| 6155 |
Get7zBoolProp(AInArchive, ItemIndex, kpidEncrypted, AItem.SetEncrypted); |
| 6156 |
|
| 6157 |
// reset modified flags |
| 6158 |
AItem.ModifiedProperties := []; |
| 6159 |
end; |
| 6160 |
|
| 6161 |
procedure GetSevenzipArchiveCompressionProperties(AJclArchive: IInterface; ASevenzipArchive: IInterface); |
| 6162 |
begin |
| 6163 |
// TODO properties from ASevenzipArchive to AJclArchive |
| 6164 |
end; |
| 6165 |
|
| 6166 |
procedure SetSevenzipArchiveCompressionProperties(AJclArchive: IInterface; ASevenzipArchive: IInterface); |
| 6167 |
var |
| 6168 |
Index: Integer; |
| 6169 |
JclArchive: TJclCompressionArchive; |
| 6170 |
PropertySetter: Sevenzip.ISetProperties; |
| 6171 |
InArchive, OutArchive: Boolean; |
| 6172 |
Unused: IInterface; |
| 6173 |
MultiThreadStrategy: IJclArchiveNumberOfThreads; |
| 6174 |
CompressionMethod: IJclArchiveCompressionMethod; |
| 6175 |
CompressionLevel: IJclArchiveCompressionLevel; |
| 6176 |
EncryptionMethod: IJclArchiveEncryptionMethod; |
| 6177 |
DictionarySize: IJclArchiveDictionarySize; |
| 6178 |
NumberOfPasses: IJclArchiveNumberOfPasses; |
| 6179 |
RemoveSfxBlock: IJclArchiveRemoveSfxBlock; |
| 6180 |
CompressHeader: IJclArchiveCompressHeader; |
| 6181 |
EncryptHeader: IJclArchiveEncryptHeader; |
| 6182 |
SaveCreationDateTime: IJclArchiveSaveCreationDateTime; |
| 6183 |
SaveLastAccessDateTime: IJclArchiveSaveLastAccessDateTime; |
| 6184 |
SaveLastWriteDateTime: IJclArchiveSaveLastWriteDateTime; |
| 6185 |
Algorithm: IJclArchiveAlgorithm; |
| 6186 |
Solid: IJclArchiveSolid; |
| 6187 |
PropNames: array of PWideChar; |
| 6188 |
PropValues: array of TPropVariant; |
| 6189 |
|
| 6190 |
procedure AddProperty(const Name: PWideChar; const Value: TPropVariant); |
| 6191 |
begin |
| 6192 |
SetLength(PropNames, Length(PropNames)+1); |
| 6193 |
PropNames[High(PropNames)] := Name; |
| 6194 |
SetLength(PropValues, Length(PropValues)+1); |
| 6195 |
PropValues[High(PropValues)] := Value; |
| 6196 |
end; |
| 6197 |
|
| 6198 |
procedure AddCardinalProperty(const Name: PWideChar; Value: Cardinal); |
| 6199 |
var |
| 6200 |
PropValue: TPropVariant; |
| 6201 |
begin |
| 6202 |
PropValue.vt := VT_UI4; |
| 6203 |
PropValue.ulVal := Value; |
| 6204 |
AddProperty(Name, PropValue); |
| 6205 |
end; |
| 6206 |
|
| 6207 |
procedure AddWideStringProperty(const Name: PWideChar; const Value: WideString); |
| 6208 |
var |
| 6209 |
PropValue: TPropVariant; |
| 6210 |
begin |
| 6211 |
PropValue.vt := VT_BSTR; |
| 6212 |
PropValue.bstrVal := SysAllocString(PWideChar(Value)); |
| 6213 |
AddProperty(Name, PropValue); |
| 6214 |
end; |
| 6215 |
|
| 6216 |
procedure AddBooleanProperty(const Name: PWideChar; Value: Boolean); |
| 6217 |
var |
| 6218 |
PropValue: TPropVariant; |
| 6219 |
const |
| 6220 |
BooleanValues: array [False..True] of WideString = ( 'OFF', 'ON' ); |
| 6221 |
begin |
| 6222 |
PropValue.vt := VT_BSTR; |
| 6223 |
PropValue.bstrVal := SysAllocString(PWideChar(BooleanValues[Value])); |
| 6224 |
AddProperty(Name, PropValue); |
| 6225 |
end; |
| 6226 |
const |
| 6227 |
EncryptionMethodNames: array [TJclEncryptionMethod] of WideString = |
| 6228 |
( '' {emNone}, |
| 6229 |
kAES128MethodName {emAES128}, |
| 6230 |
kAES192MethodName {emAES192}, |
| 6231 |
kAES256MethodName {emAES256}, |
| 6232 |
kZipCryptoMethodName {emZipCrypto} ); |
| 6233 |
CompressionMethodNames: array [TJclCompressionMethod] of WideString = |
| 6234 |
( kCopyMethodName {cmCopy}, |
| 6235 |
kDeflateMethodName {cmDeflate}, |
| 6236 |
kDeflate64MethodName {cmDeflate64}, |
| 6237 |
kBZip2MethodName {cmBZip2}, |
| 6238 |
kLZMAMethodName {cmLZMA}, |
| 6239 |
kLZMA2MethodName {cmLZMA2}, |
| 6240 |
kPPMdMethodName {cmPPMd} ); |
| 6241 |
begin |
| 6242 |
if Supports(ASevenzipArchive, Sevenzip.ISetProperties, PropertySetter) and Assigned(PropertySetter) then |
| 6243 |
begin |
| 6244 |
InArchive := Supports(ASevenzipArchive, Sevenzip.IInArchive, Unused); |
| 6245 |
OutArchive := Supports(ASevenzipArchive, Sevenzip.IOutArchive, Unused); |
| 6246 |
if (InArchive or OutArchive) and Supports(AJclArchive, IJclArchiveNumberOfThreads, MultiThreadStrategy) |
| 6247 |
and Assigned(MultiThreadStrategy) and (MultiThreadStrategy.NumberOfThreads > 1) then |
| 6248 |
AddCardinalProperty('MT', MultiThreadStrategy.NumberOfThreads); |
| 6249 |
|
| 6250 |
if OutArchive then |
| 6251 |
begin |
| 6252 |
if Supports(AJclArchive, IJclArchiveCompressionMethod, CompressionMethod) and Assigned(CompressionMethod) then |
| 6253 |
AddWideStringProperty('M', CompressionMethodNames[CompressionMethod.CompressionMethod]); |
| 6254 |
|
| 6255 |
if Supports(AJclArchive, IJclArchiveCompressionLevel, CompressionLevel) and Assigned(CompressionLevel) then |
| 6256 |
AddCardinalProperty('X', CompressionLevel.CompressionLevel); |
| 6257 |
|
| 6258 |
if Supports(AJclArchive, IJclArchiveEncryptionMethod, EncryptionMethod) and Assigned(EncryptionMethod) |
| 6259 |
and (EncryptionMethod.EncryptionMethod <> emNone) then |
| 6260 |
AddWideStringProperty('EM', EncryptionMethodNames[EncryptionMethod.EncryptionMethod]); |
| 6261 |
|
| 6262 |
if Supports(AJclArchive, IJclArchiveDictionarySize, DictionarySize) and Assigned(DictionarySize) and |
| 6263 |
Supports(AJclArchive, IJclArchiveCompressionMethod, CompressionMethod) and Assigned(CompressionMethod) and |
| 6264 |
(CompressionMethod.CompressionMethod in [cmBZip2,cmLZMA,cmLZMA2]) then |
| 6265 |
AddWideStringProperty('D', IntToStr(DictionarySize.DictionarySize) + 'B'); |
| 6266 |
|
| 6267 |
if Supports(AJclArchive, IJclArchiveNumberOfPasses, NumberOfPasses) and Assigned(NumberOfPasses) then |
| 6268 |
AddCardinalProperty('PASS', NumberOfPasses.NumberOfPasses); |
| 6269 |
|
| 6270 |
if Supports(AJclArchive, IJclArchiveRemoveSfxBlock, RemoveSfxBlock) and Assigned(RemoveSfxBlock) then |
| 6271 |
AddBooleanProperty('RSFX', RemoveSfxBlock.RemoveSfxBlock); |
| 6272 |
|
| 6273 |
if Supports(AJclArchive, IJclArchiveCompressHeader, CompressHeader) and Assigned(CompressHeader) then |
| 6274 |
begin |
| 6275 |
AddBooleanProperty('HC', CompressHeader.CompressHeader); |
| 6276 |
if CompressHeader.CompressHeaderFull then |
| 6277 |
AddBooleanProperty('HCF', CompressHeader.CompressHeaderFull); |
| 6278 |
end; |
| 6279 |
|
| 6280 |
if Supports(AJclArchive, IJclArchiveEncryptHeader, EncryptHeader) and Assigned(EncryptHeader) then |
| 6281 |
AddBooleanProperty('HE', EncryptHeader.EncryptHeader); |
| 6282 |
|
| 6283 |
if Supports(AJclArchive, IJclArchiveSaveCreationDateTime, SaveCreationDateTime) |
| 6284 |
and Assigned(SaveCreationDateTime) then |
| 6285 |
AddBooleanProperty('TC', SaveCreationDateTime.SaveCreationDateTime); |
| 6286 |
|
| 6287 |
if Supports(AJclArchive, IJclArchiveSaveLastAccessDateTime, SaveLastAccessDateTime) |
| 6288 |
and Assigned(SaveLastAccessDateTime) then |
| 6289 |
AddBooleanProperty('TA', SaveLastAccessDateTime.SaveLastAccessDateTime); |
| 6290 |
|
| 6291 |
if Supports(AJclArchive, IJclArchiveSaveLastWriteDateTime, SaveLastWriteDateTime) |
| 6292 |
and Assigned(SaveLastWriteDateTime) then |
| 6293 |
AddBooleanProperty('TM', SaveLastWriteDateTime.SaveLastWriteDateTime); |
| 6294 |
|
| 6295 |
if Supports(AJclArchive, IJclArchiveAlgorithm, Algorithm) and Assigned(Algorithm) then |
| 6296 |
AddCardinalProperty('A', Algorithm.Algorithm); |
| 6297 |
|
| 6298 |
if Supports(AJclArchive, IJclArchiveSolid, Solid) and Assigned(Solid) then |
| 6299 |
begin |
| 6300 |
if Solid.SolidExtension then |
| 6301 |
AddWideStringProperty('S', 'E'); |
| 6302 |
if Solid.SolidBlockSize > 0 then |
| 6303 |
AddWideStringProperty('S', IntToStr(Solid.SolidBlockSize) + 'B') |
| 6304 |
else |
| 6305 |
AddWideStringProperty('S', IntToStr(Solid.SolidBlockSize) + 'F'); |
| 6306 |
end; |
| 6307 |
|
| 6308 |
JclArchive := AJclArchive as TJclCompressionArchive; |
| 6309 |
for Index := Low(JclArchive.PropNames) to High(JclArchive.PropNames) do |
| 6310 |
begin |
| 6311 |
AddProperty(PWideChar(JclArchive.PropNames[Index]), JclArchive.PropValues[Index]); |
| 6312 |
end; |
| 6313 |
end; |
| 6314 |
if Length(PropNames) > 0 then |
| 6315 |
try |
| 6316 |
SevenZipCheck(PropertySetter.SetProperties(@PropNames[0], @PropValues[0], Length(PropNames))); |
| 6317 |
finally |
| 6318 |
for Index := 0 to High(PropValues) do |
| 6319 |
begin |
| 6320 |
if (PropValues[Index].vt = VT_BSTR) and (PropValues[Index].bstrVal <> nil) then |
| 6321 |
begin |
| 6322 |
SysFreeString(PropValues[Index].bstrVal); |
| 6323 |
end; |
| 6324 |
SetLength(JclArchive.PropNames, 0); SetLength(JclArchive.PropValues, 0); |
| 6325 |
end |
| 6326 |
end; |
| 6327 |
end; |
| 6328 |
end; |
| 6329 |
|
| 6330 |
function Create7zFile(SourceFiles: TStrings; const DestinationFile: TFileName; VolumeSize: Int64; Password: String; |
| 6331 |
OnArchiveProgress: TJclCompressionProgressEvent; OnArchiveRatio: TJclCompressionRatioEvent): Boolean; |
| 6332 |
var |
| 6333 |
ArchiveFileName: string; |
| 6334 |
SourceFile : String; |
| 6335 |
AFormat: TJclUpdateArchiveClass; |
| 6336 |
Archive : TJclCompressionArchive; |
| 6337 |
i: Integer; |
| 6338 |
InnerList : tStringList; |
| 6339 |
j: Integer; |
| 6340 |
begin |
| 6341 |
Result := False; |
| 6342 |
ArchiveFileName := DestinationFile; |
| 6343 |
|
| 6344 |
AFormat := GetArchiveFormats.FindUpdateFormat(ArchiveFileName); |
| 6345 |
|
| 6346 |
if AFormat <> nil then |
| 6347 |
begin |
| 6348 |
|
| 6349 |
if VolumeSize <> 0 then |
| 6350 |
ArchiveFileName := ArchiveFileName + '.%.3d'; |
| 6351 |
|
| 6352 |
Archive := AFormat.Create(ArchiveFileName, VolumeSize, VolumeSize <> 0); |
| 6353 |
try |
| 6354 |
Archive.Password := Password; |
| 6355 |
Archive.OnProgress := OnArchiveProgress; |
| 6356 |
Archive.OnRatio := OnArchiveRatio; |
| 6357 |
|
| 6358 |
InnerList := tStringList.Create; |
| 6359 |
try |
| 6360 |
for i := 0 to SourceFiles.Count - 1 do |
| 6361 |
begin |
| 6362 |
InnerList.Clear; |
| 6363 |
BuildFileList(SourceFiles[i], faAnyFile, InnerList, True); |
| 6364 |
for j := 0 to InnerList.Count - 1 do |
| 6365 |
begin |
| 6366 |
SourceFile:=InnerList[j]; |
| 6367 |
(Archive as TJclCompressArchive).AddFile(ExtractFileName(SourceFile), SourceFile); |
| 6368 |
Result := True; |
| 6369 |
end; |
| 6370 |
end; |
| 6371 |
finally |
| 6372 |
InnerList.Free; |
| 6373 |
end; |
| 6374 |
(Archive as TJclCompressArchive).Compress; |
| 6375 |
finally |
| 6376 |
Archive.Free; |
| 6377 |
end; |
| 6378 |
end; |
| 6379 |
end; |
| 6380 |
|
| 6381 |
function Create7zFile(const SourceFile, DestinationFile: TFileName; VolumeSize: Int64; Password: String; |
| 6382 |
OnArchiveProgress: TJclCompressionProgressEvent; OnArchiveRatio: TJclCompressionRatioEvent): Boolean; |
| 6383 |
var |
| 6384 |
SourceFiles : TStringList; |
| 6385 |
begin |
| 6386 |
SourceFiles := TStringList.Create; |
| 6387 |
try |
| 6388 |
SourceFiles.Add(SourceFile); |
| 6389 |
Result := Create7zFile(SourceFiles, DestinationFile, VolumeSize, Password, OnArchiveProgress, OnArchiveRatio); |
| 6390 |
finally |
| 6391 |
SourceFiles.Free; |
| 6392 |
end; |
| 6393 |
end; |
| 6394 |
|
| 6395 |
function Get7zArchiveSignature(const ClassID: TGUID): TDynByteArray; |
| 6396 |
var |
| 6397 |
I, NumberOfFormats: Cardinal; |
| 6398 |
J: Integer; |
| 6399 |
PropValue: TPropVariant; |
| 6400 |
Found: Boolean; |
| 6401 |
Data: PAnsiChar; |
| 6402 |
begin |
| 6403 |
Found := False; |
| 6404 |
SetLength(Result, 0); |
| 6405 |
SevenzipCheck(Sevenzip.GetNumberOfFormats(@NumberOfFormats)); |
| 6406 |
for I := 0 to NumberOfFormats - 1 do |
| 6407 |
begin |
| 6408 |
SevenzipCheck(Sevenzip.GetHandlerProperty2(I, kClassID, PropValue)); |
| 6409 |
if PropValue.vt = VT_BSTR then |
| 6410 |
begin |
| 6411 |
try |
| 6412 |
if SysStringByteLen(PropValue.bstrVal) = SizeOf(TGUID) then |
| 6413 |
Found := GUIDEquals(PGUID(PropValue.bstrVal)^, ClassID) |
| 6414 |
else |
| 6415 |
raise EJclCompressionError.CreateRes(@RsCompressionDataError); |
| 6416 |
finally |
| 6417 |
SysFreeString(PropValue.bstrVal); |
| 6418 |
end; |
| 6419 |
end |
| 6420 |
else |
| 6421 |
raise EJclCompressionError.CreateResFmt(@RsCompression7zUnknownValueType, [PropValue.vt, kClassID]); |
| 6422 |
|
| 6423 |
if Found then |
| 6424 |
begin |
| 6425 |
SevenzipCheck(Sevenzip.GetHandlerProperty2(I, kStartSignature, PropValue)); |
| 6426 |
if PropValue.vt = VT_BSTR then |
| 6427 |
begin |
| 6428 |
try |
| 6429 |
SetLength(Result, SysStringByteLen(PropValue.bstrVal)); |
| 6430 |
Data := PAnsiChar(PropValue.bstrVal); |
| 6431 |
for J := Low(Result) to High(Result) do |
| 6432 |
Result[J] := Ord(Data[J]); |
| 6433 |
finally |
| 6434 |
SysFreeString(PropValue.bstrVal); |
| 6435 |
end; |
| 6436 |
end |
| 6437 |
else |
| 6438 |
if PropValue.vt <> VT_EMPTY then |
| 6439 |
raise EJclCompressionError.CreateResFmt(@RsCompression7zUnknownValueType, [PropValue.vt, kClassID]); |
| 6440 |
Break; |
| 6441 |
end; |
| 6442 |
end; |
| 6443 |
end; |
| 6444 |
|
| 6445 |
//=== { TJclSevenzipOutputCallback } ========================================= |
| 6446 |
|
| 6447 |
constructor TJclSevenzipUpdateCallback.Create( |
| 6448 |
AArchive: TJclCompressionArchive); |
| 6449 |
begin |
| 6450 |
inherited Create; |
| 6451 |
FArchive := AArchive; |
| 6452 |
end; |
| 6453 |
|
| 6454 |
function TJclSevenzipUpdateCallback.CryptoGetTextPassword2( |
| 6455 |
PasswordIsDefined: PInteger; Password: PBStr): HRESULT; |
| 6456 |
begin |
| 6457 |
if Assigned(PasswordIsDefined) then |
| 6458 |
begin |
| 6459 |
if FArchive.Password <> '' then |
| 6460 |
PasswordIsDefined^ := Integer($FFFFFFFF) |
| 6461 |
else |
| 6462 |
PasswordIsDefined^ := 0; |
| 6463 |
end; |
| 6464 |
if Assigned(Password) then |
| 6465 |
Password^ := SysAllocString(PWideChar(FArchive.Password)); |
| 6466 |
Result := S_OK; |
| 6467 |
end; |
| 6468 |
|
| 6469 |
function TJclSevenzipUpdateCallback.GetProperty(Index, PropID: Cardinal; |
| 6470 |
out Value: tagPROPVARIANT): HRESULT; |
| 6471 |
var |
| 6472 |
AItem: TJclCompressionItem; |
| 6473 |
begin |
| 6474 |
Result := S_OK; |
| 6475 |
AItem := FArchive.Items[Index]; |
| 6476 |
case PropID of |
| 6477 |
kpidNoProperty: |
| 6478 |
Value.vt := VT_NULL; |
| 6479 |
// kpidMainSubfile: ; |
| 6480 |
// kpidHandlerItemIndex: ; |
| 6481 |
kpidPath: |
| 6482 |
begin |
| 6483 |
Value.vt := VT_BSTR; |
| 6484 |
Value.bstrVal := SysAllocString(PWideChar(AItem.PackedName)); |
| 6485 |
end; |
| 6486 |
//kpidName: (read only) |
| 6487 |
{ kpidExtension: |
| 6488 |
begin |
| 6489 |
Value.vt := VT_BSTR; |
| 6490 |
Value.bstrVal := SysAllocString(PWideChar(WideString(ExtractFileExt(FCompressionStream.FileNames[Index])))); |
| 6491 |
end;} |
| 6492 |
kpidIsDir: |
| 6493 |
begin |
| 6494 |
Value.vt := VT_BOOL; |
| 6495 |
Value.bool := AItem.Kind = ikDirectory; |
| 6496 |
end; |
| 6497 |
kpidSize: |
| 6498 |
begin |
| 6499 |
Value.vt := VT_UI8; |
| 6500 |
Value.uhVal.QuadPart := AItem.FileSize; |
| 6501 |
end; |
| 6502 |
// kpidPackSize: ; |
| 6503 |
kpidAttrib: |
| 6504 |
begin |
| 6505 |
Value.vt := VT_UI4; |
| 6506 |
Value.ulVal := AItem.Attributes; |
| 6507 |
end; |
| 6508 |
kpidCTime: |
| 6509 |
begin |
| 6510 |
Value.vt := VT_FILETIME; |
| 6511 |
Value.filetime := AItem.CreationTime; |
| 6512 |
end; |
| 6513 |
kpidATime: |
| 6514 |
begin |
| 6515 |
Value.vt := VT_FILETIME; |
| 6516 |
Value.filetime := AItem.LastAccessTime; |
| 6517 |
end; |
| 6518 |
kpidMTime: |
| 6519 |
begin |
| 6520 |
Value.vt := VT_FILETIME; |
| 6521 |
Value.filetime := AItem.LastWriteTime; |
| 6522 |
end; |
| 6523 |
kpidSolid: |
| 6524 |
begin |
| 6525 |
Value.vt := VT_BOOL; |
| 6526 |
Value.bool := True; |
| 6527 |
end; |
| 6528 |
// kpidCommented: ; |
| 6529 |
// kpidEncrypted: ; |
| 6530 |
// kpidSplitBefore: ; |
| 6531 |
// kpidSplitAfter: ; |
| 6532 |
// kpidDictionarySize: ; |
| 6533 |
// kpidCRC: ; |
| 6534 |
// kpidType: ; |
| 6535 |
kpidIsAnti: |
| 6536 |
begin |
| 6537 |
Value.vt := VT_BOOL; |
| 6538 |
Value.bool := False; |
| 6539 |
end; |
| 6540 |
// kpidMethod: ; |
| 6541 |
// kpidHostOS: ; |
| 6542 |
// kpidFileSystem: ; |
| 6543 |
kpidUser: |
| 6544 |
begin |
| 6545 |
Value.vt := VT_BSTR; |
| 6546 |
Value.bstrVal := SysAllocString(PWideChar(AItem.User)); |
| 6547 |
end; |
| 6548 |
kpidGroup: |
| 6549 |
begin |
| 6550 |
Value.vt := VT_BSTR; |
| 6551 |
Value.bstrVal := SysAllocString(PWideChar(AItem.Group)); |
| 6552 |
end; |
| 6553 |
// kpidBlock: ; |
| 6554 |
kpidComment: |
| 6555 |
begin |
| 6556 |
Value.vt := VT_EMPTY; |
| 6557 |
end; |
| 6558 |
// kpidPosition: ; |
| 6559 |
// kpidPrefix: ; |
| 6560 |
// kpidNumSubDirs: ; |
| 6561 |
// kpidNumSubFiles: ; |
| 6562 |
// kpidUnpackVer: ; |
| 6563 |
// kpidVolume: ; |
| 6564 |
// kpidIsVolume: ; |
| 6565 |
// kpidOffset: ; |
| 6566 |
// kpidLinks: ; |
| 6567 |
// kpidNumBlocks: ; |
| 6568 |
// kpidNumVolumes: ; |
| 6569 |
kpidTimeType: |
| 6570 |
begin |
| 6571 |
Value.vt := VT_UI4; |
| 6572 |
Value.ulVal := kWindows; |
| 6573 |
end; |
| 6574 |
// kpidBit64: ; |
| 6575 |
// kpidBigEndian: ; |
| 6576 |
// kpidCpu: ; |
| 6577 |
// kpidPhySize: ; |
| 6578 |
// kpidHeadersSize: ; |
| 6579 |
// kpidChecksum: ; |
| 6580 |
// kpidCharacts: ; |
| 6581 |
// kpidVa: ; |
| 6582 |
// kpidId: ; |
| 6583 |
kpidShortName: |
| 6584 |
begin |
| 6585 |
Value.vt := VT_EMPTY; |
| 6586 |
end; |
| 6587 |
// kpidCreatorApp: ; |
| 6588 |
// kpidSectorSize: ; |
| 6589 |
kpidPosixAttrib: |
| 6590 |
begin |
| 6591 |
Value.vt := VT_EMPTY; |
| 6592 |
end; |
| 6593 |
// kpidLink: ; |
| 6594 |
// kpidTotalSize: ; |
| 6595 |
// kpidFreeSpace: ; |
| 6596 |
// kpidClusterSize: ; |
| 6597 |
// kpidVolumeName: ; |
| 6598 |
// kpidLocalName: ; |
| 6599 |
// kpidProvider: ; |
| 6600 |
// kpidUserDefined: ; |
| 6601 |
kpidIsAltStream: |
| 6602 |
begin |
| 6603 |
Value.vt := VT_BOOL; |
| 6604 |
Value.bool := False; |
| 6605 |
end; |
| 6606 |
else |
| 6607 |
Value.vt := VT_EMPTY; |
| 6608 |
Result := S_FALSE; |
| 6609 |
end; |
| 6610 |
end; |
| 6611 |
|
| 6612 |
function TJclSevenzipUpdateCallback.GetStream(Index: Cardinal; |
| 6613 |
out InStream: ISequentialInStream): HRESULT; |
| 6614 |
begin |
| 6615 |
Result := E_FAIL; |
| 6616 |
FLastStream := Index; |
| 6617 |
repeat |
| 6618 |
try |
| 6619 |
InStream := TJclSevenzipInStream.Create(FArchive, Index); |
| 6620 |
Result := S_OK; |
| 6621 |
except |
| 6622 |
on E: Exception do |
| 6623 |
begin |
| 6624 |
case MessageBoxW(0, PWideChar(UTF8Decode(E.Message)), nil, MB_ABORTRETRYIGNORE or MB_ICONERROR) of |
| 6625 |
IDABORT: Exit(E_ABORT); |
| 6626 |
IDIGNORE: |
| 6627 |
begin |
| 6628 |
FArchive.Items[Index].OperationSuccess := osNoOperation; |
| 6629 |
FLastStream := MAXDWORD; |
| 6630 |
Exit(S_FALSE); |
| 6631 |
end; |
| 6632 |
end; |
| 6633 |
end; |
| 6634 |
end; |
| 6635 |
until Result = S_OK; |
| 6636 |
end; |
| 6637 |
|
| 6638 |
function TJclSevenzipUpdateCallback.GetUpdateItemInfo(Index: Cardinal; NewData, |
| 6639 |
NewProperties: PInteger; IndexInArchive: PCardinal): HRESULT; |
| 6640 |
var |
| 6641 |
CompressionItem: TJclCompressionItem; |
| 6642 |
begin |
| 6643 |
CompressionItem := FArchive.Items[Index]; |
| 6644 |
|
| 6645 |
if Assigned(NewData) then |
| 6646 |
begin |
| 6647 |
if ([ipFileName, ipStream] * CompressionItem.ModifiedProperties) <> [] then |
| 6648 |
NewData^ := 1 |
| 6649 |
else |
| 6650 |
NewData^ := 0; |
| 6651 |
end; |
| 6652 |
|
| 6653 |
if Assigned(NewProperties) then |
| 6654 |
begin |
| 6655 |
if (CompressionItem.ModifiedProperties - [ipFileName, ipStream]) <> [] then |
| 6656 |
NewProperties^ := 1 |
| 6657 |
else |
| 6658 |
NewProperties^ := 0; |
| 6659 |
end; |
| 6660 |
|
| 6661 |
// TODO |
| 6662 |
if Assigned(IndexInArchive) then |
| 6663 |
IndexInArchive^ := CompressionItem.PackedIndex; |
| 6664 |
Result := S_OK; |
| 6665 |
end; |
| 6666 |
|
| 6667 |
function TJclSevenzipUpdateCallback.GetVolumeSize(Index: Cardinal; |
| 6668 |
Size: PInt64): HRESULT; |
| 6669 |
begin |
| 6670 |
// the JCL has its own spliting engine |
| 6671 |
if Assigned(Size) then |
| 6672 |
Size^ := 0; |
| 6673 |
Result := S_FALSE; |
| 6674 |
end; |
| 6675 |
|
| 6676 |
function TJclSevenzipUpdateCallback.GetVolumeStream(Index: Cardinal; |
| 6677 |
out VolumeStream: ISequentialOutStream): HRESULT; |
| 6678 |
begin |
| 6679 |
VolumeStream := nil; |
| 6680 |
Result := S_FALSE; |
| 6681 |
end; |
| 6682 |
|
| 6683 |
function TJclSevenzipUpdateCallback.SetCompleted( |
| 6684 |
CompleteValue: PInt64): HRESULT; |
| 6685 |
begin |
| 6686 |
Result := S_OK; |
| 6687 |
if Assigned(CompleteValue) and not FArchive.DoProgress(CompleteValue^, FArchive.FProgressMax) then |
| 6688 |
Result := E_ABORT; |
| 6689 |
end; |
| 6690 |
|
| 6691 |
function TJclSevenzipUpdateCallback.SetOperationResult( |
| 6692 |
OperationResult: Integer): HRESULT; |
| 6693 |
begin |
| 6694 |
if FLastStream < MAXDWORD then |
| 6695 |
begin |
| 6696 |
case OperationResult of |
| 6697 |
kOK: |
| 6698 |
FArchive.Items[FLastStream].OperationSuccess := osOK; |
| 6699 |
kUnSupportedMethod: |
| 6700 |
FArchive.Items[FLastStream].OperationSuccess := osUnsupportedMethod; |
| 6701 |
kDataError: |
| 6702 |
FArchive.Items[FLastStream].OperationSuccess := osDataError; |
| 6703 |
kCRCError: |
| 6704 |
FArchive.Items[FLastStream].OperationSuccess := osCRCError; |
| 6705 |
else |
| 6706 |
FArchive.Items[FLastStream].OperationSuccess := osUnknownError; |
| 6707 |
end; |
| 6708 |
end; |
| 6709 |
|
| 6710 |
Result := S_OK; |
| 6711 |
end; |
| 6712 |
|
| 6713 |
function TJclSevenzipUpdateCallback.SetRatioInfo(InSize, |
| 6714 |
OutSize: PInt64): HRESULT; |
| 6715 |
var |
| 6716 |
AInSize, AOutSize: Int64; |
| 6717 |
begin |
| 6718 |
if Assigned(InSize) then |
| 6719 |
AInSize := InSize^ |
| 6720 |
else |
| 6721 |
AInSize := -1; |
| 6722 |
if Assigned(OutSize) then |
| 6723 |
AOutSize := OutSize^ |
| 6724 |
else |
| 6725 |
AOutSize := -1; |
| 6726 |
if FArchive.DoRatio(AInSize, AOutSize) then |
| 6727 |
Result := S_OK |
| 6728 |
else |
| 6729 |
Result := E_ABORT; |
| 6730 |
end; |
| 6731 |
|
| 6732 |
function TJclSevenzipUpdateCallback.SetTotal(Total: Int64): HRESULT; |
| 6733 |
begin |
| 6734 |
FArchive.FProgressMax := Total; |
| 6735 |
if FArchive.CancelCurrentOperation then |
| 6736 |
Result := E_ABORT |
| 6737 |
else |
| 6738 |
Result := S_OK; |
| 6739 |
end; |
| 6740 |
|
| 6741 |
//=== { TJclSevenzipCompressArchive } ======================================== |
| 6742 |
|
| 6743 |
class function TJclSevenzipCompressArchive.ArchiveCLSID: TGUID; |
| 6744 |
begin |
| 6745 |
Result := GUID_NULL; |
| 6746 |
end; |
| 6747 |
|
| 6748 |
class function TJclSevenzipCompressArchive.ArchiveSignature: TDynByteArray; |
| 6749 |
begin |
| 6750 |
Result := Get7zArchiveSignature(ArchiveCLSID); |
| 6751 |
end; |
| 6752 |
|
| 6753 |
destructor TJclSevenzipCompressArchive.Destroy; |
| 6754 |
begin |
| 6755 |
FOutArchive := nil; |
| 6756 |
inherited Destroy; |
| 6757 |
end; |
| 6758 |
|
| 6759 |
function TJclSevenzipCompressArchive.GetItemClass: TJclCompressionItemClass; |
| 6760 |
begin |
| 6761 |
Result := TJclCompressItem; |
| 6762 |
end; |
| 6763 |
|
| 6764 |
function TJclSevenzipCompressArchive.GetOutArchive: IOutArchive; |
| 6765 |
var |
| 6766 |
SevenzipCLSID, InterfaceID: TGUID; |
| 6767 |
begin |
| 6768 |
if not Assigned(FOutArchive) then |
| 6769 |
begin |
| 6770 |
SevenzipCLSID := ArchiveCLSID; |
| 6771 |
InterfaceID := Sevenzip.IOutArchive; |
| 6772 |
if (not Is7ZipLoaded) and (not Load7Zip) then |
| 6773 |
raise EJclCompressionError.CreateRes(@RsCompression7zLoadError); |
| 6774 |
if (Sevenzip.CreateObject(@SevenzipCLSID, @InterfaceID, FOutArchive) <> ERROR_SUCCESS) |
| 6775 |
or not Assigned(FOutArchive) then |
| 6776 |
raise EJclCompressionError.CreateResFmt(@RsCompression7zOutArchiveError, [GUIDToString(SevenzipCLSID)]); |
| 6777 |
end; |
| 6778 |
Result := FOutArchive; |
| 6779 |
end; |
| 6780 |
|
| 6781 |
procedure TJclSevenzipCompressArchive.Compress; |
| 6782 |
var |
| 6783 |
Value: HRESULT; |
| 6784 |
Index: Integer; |
| 6785 |
OutStream: IOutStream; |
| 6786 |
AVolume: TJclCompressionVolume; |
| 6787 |
UpdateCallback: IArchiveUpdateCallback; |
| 6788 |
SplitStream: TJclDynamicSplitStream; |
| 6789 |
begin |
| 6790 |
CheckNotCompressing; |
| 6791 |
|
| 6792 |
FCompressing := True; |
| 6793 |
try |
| 6794 |
SplitStream := TJclDynamicSplitStream.Create(False); |
| 6795 |
SplitStream.OnVolume := NeedStream; |
| 6796 |
SplitStream.OnVolumeMaxSize := NeedStreamMaxSize; |
| 6797 |
if Length(FSfxModule) > 0 then |
| 6798 |
OutStream := TSfxSevenzipOutStream.Create(SplitStream, FSfxModule) |
| 6799 |
else begin |
| 6800 |
OutStream := TJclSevenzipOutStream.Create(SplitStream, True, False); |
| 6801 |
end; |
| 6802 |
UpdateCallback := TJclSevenzipUpdateCallback.Create(Self); |
| 6803 |
|
| 6804 |
SetSevenzipArchiveCompressionProperties(Self, OutArchive); |
| 6805 |
|
| 6806 |
Value:= OutArchive.UpdateItems(OutStream, ItemCount, UpdateCallback); |
| 6807 |
|
| 6808 |
if Value <> S_OK then |
| 6809 |
begin |
| 6810 |
// Remove partial archives |
| 6811 |
for Index := 0 to FVolumes.Count - 1 do |
| 6812 |
begin |
| 6813 |
AVolume := TJclCompressionVolume(FVolumes.Items[Index]); |
| 6814 |
if AVolume.OwnsStream then |
| 6815 |
begin |
| 6816 |
FreeAndNil(AVolume.FStream); |
| 6817 |
FileDelete(AVolume.FileName); |
| 6818 |
end; |
| 6819 |
end; |
| 6820 |
end; |
| 6821 |
|
| 6822 |
SevenzipCheck(Value); |
| 6823 |
finally |
| 6824 |
FCompressing := False; |
| 6825 |
// release volumes and other finalizations |
| 6826 |
inherited Compress; |
| 6827 |
end; |
| 6828 |
end; |
| 6829 |
|
| 6830 |
//=== { TJcl7zCompressArchive } ============================================== |
| 6831 |
|
| 6832 |
class function TJcl7zCompressArchive.ArchiveExtensions: string; |
| 6833 |
begin |
| 6834 |
Result := LoadResString(@RsCompression7zExtensions); |
| 6835 |
end; |
| 6836 |
|
| 6837 |
class function TJcl7zCompressArchive.ArchiveName: string; |
| 6838 |
begin |
| 6839 |
Result := LoadResString(@RsCompression7zName); |
| 6840 |
end; |
| 6841 |
|
| 6842 |
class function TJcl7zCompressArchive.ArchiveCLSID: TGUID; |
| 6843 |
begin |
| 6844 |
Result := CLSID_CFormat7z; |
| 6845 |
end; |
| 6846 |
|
| 6847 |
function TJcl7zCompressArchive.GetCompressHeader: Boolean; |
| 6848 |
begin |
| 6849 |
Result := FCompressHeader; |
| 6850 |
end; |
| 6851 |
|
| 6852 |
function TJcl7zCompressArchive.GetCompressHeaderFull: Boolean; |
| 6853 |
begin |
| 6854 |
Result := FCompressHeaderFull; |
| 6855 |
end; |
| 6856 |
|
| 6857 |
function TJcl7zCompressArchive.GetCompressionLevel: Cardinal; |
| 6858 |
begin |
| 6859 |
Result := FCompressionLevel; |
| 6860 |
end; |
| 6861 |
|
| 6862 |
function TJcl7zCompressArchive.GetCompressionLevelMax: Cardinal; |
| 6863 |
begin |
| 6864 |
Result := 9; |
| 6865 |
end; |
| 6866 |
|
| 6867 |
function TJcl7zCompressArchive.GetCompressionLevelMin: Cardinal; |
| 6868 |
begin |
| 6869 |
Result := 0; |
| 6870 |
end; |
| 6871 |
|
| 6872 |
function TJcl7zCompressArchive.GetDictionarySize: Cardinal; |
| 6873 |
begin |
| 6874 |
Result := FDictionarySize; |
| 6875 |
end; |
| 6876 |
|
| 6877 |
function TJcl7zCompressArchive.GetEncryptHeader: Boolean; |
| 6878 |
begin |
| 6879 |
Result := FEncryptHeader; |
| 6880 |
end; |
| 6881 |
|
| 6882 |
function TJcl7zCompressArchive.GetNumberOfThreads: Cardinal; |
| 6883 |
begin |
| 6884 |
Result := FNumberOfThreads; |
| 6885 |
end; |
| 6886 |
|
| 6887 |
function TJcl7zCompressArchive.GetRemoveSfxBlock: Boolean; |
| 6888 |
begin |
| 6889 |
Result := FRemoveSfxBlock; |
| 6890 |
end; |
| 6891 |
|
| 6892 |
function TJcl7zCompressArchive.GetSaveCreationDateTime: Boolean; |
| 6893 |
begin |
| 6894 |
Result := FSaveCreationDateTime; |
| 6895 |
end; |
| 6896 |
|
| 6897 |
function TJcl7zCompressArchive.GetSaveLastAccessDateTime: Boolean; |
| 6898 |
begin |
| 6899 |
Result := FSaveLastAccessDateTime; |
| 6900 |
end; |
| 6901 |
|
| 6902 |
function TJcl7zCompressArchive.GetSaveLastWriteDateTime: Boolean; |
| 6903 |
begin |
| 6904 |
Result := FSaveLastWriteDateTime; |
| 6905 |
end; |
| 6906 |
|
| 6907 |
function TJcl7zCompressArchive.GetSolidBlockSize: Int64; |
| 6908 |
begin |
| 6909 |
Result := FSolidBlockSize; |
| 6910 |
end; |
| 6911 |
|
| 6912 |
function TJcl7zCompressArchive.GetSolidExtension: Boolean; |
| 6913 |
begin |
| 6914 |
Result := FSolidExtension; |
| 6915 |
end; |
| 6916 |
|
| 6917 |
procedure TJcl7zCompressArchive.InitializeArchiveProperties; |
| 6918 |
begin |
| 6919 |
inherited InitializeArchiveProperties; |
| 6920 |
FNumberOfThreads := 1; |
| 6921 |
FEncryptHeader := False; |
| 6922 |
FRemoveSfxBlock := False; |
| 6923 |
FDictionarySize := kLzmaDicSizeX5; |
| 6924 |
FCompressionLevel := 6; |
| 6925 |
FCompressHeader := False; |
| 6926 |
FCompressHeaderFull := False; |
| 6927 |
FSaveLastAccessDateTime := True; |
| 6928 |
FSaveCreationDateTime := True; |
| 6929 |
FSaveLastWriteDateTime := True; |
| 6930 |
FSolidBlockSize := High(Cardinal); |
| 6931 |
FSolidExtension := False; |
| 6932 |
end; |
| 6933 |
|
| 6934 |
class function TJcl7zCompressArchive.MultipleItemContainer: Boolean; |
| 6935 |
begin |
| 6936 |
Result := True; |
| 6937 |
end; |
| 6938 |
|
| 6939 |
procedure TJcl7zCompressArchive.SetCompressHeader(Value: Boolean); |
| 6940 |
begin |
| 6941 |
CheckNotCompressing; |
| 6942 |
FCompressHeader := Value; |
| 6943 |
end; |
| 6944 |
|
| 6945 |
procedure TJcl7zCompressArchive.SetCompressHeaderFull(Value: Boolean); |
| 6946 |
begin |
| 6947 |
CheckNotCompressing; |
| 6948 |
FCompressHeaderFull := Value; |
| 6949 |
end; |
| 6950 |
|
| 6951 |
procedure TJcl7zCompressArchive.SetCompressionLevel(Value: Cardinal); |
| 6952 |
begin |
| 6953 |
CheckNotCompressing; |
| 6954 |
if Value <= 9 then |
| 6955 |
begin |
| 6956 |
FCompressionLevel := Value; |
| 6957 |
if Value >= 9 then |
| 6958 |
FDictionarySize := kLzmaDicSizeX9 |
| 6959 |
else |
| 6960 |
if Value >= 7 then |
| 6961 |
FDictionarySize := kLzmaDicSizeX7 |
| 6962 |
else |
| 6963 |
if Value >= 5 then |
| 6964 |
FDictionarySize := kLzmaDicSizeX5 |
| 6965 |
else |
| 6966 |
if Value >= 3 then |
| 6967 |
FDictionarySize := kLzmaDicSizeX3 |
| 6968 |
else |
| 6969 |
FDictionarySize := kLzmaDicSizeX1; |
| 6970 |
end |
| 6971 |
else |
| 6972 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty); |
| 6973 |
end; |
| 6974 |
|
| 6975 |
procedure TJcl7zCompressArchive.SetDictionarySize(Value: Cardinal); |
| 6976 |
begin |
| 6977 |
CheckNotCompressing; |
| 6978 |
FDictionarySize := Value; |
| 6979 |
end; |
| 6980 |
|
| 6981 |
procedure TJcl7zCompressArchive.SetEncryptHeader(Value: Boolean); |
| 6982 |
begin |
| 6983 |
CheckNotCompressing; |
| 6984 |
FEncryptHeader := Value; |
| 6985 |
end; |
| 6986 |
|
| 6987 |
procedure TJcl7zCompressArchive.SetNumberOfThreads(Value: Cardinal); |
| 6988 |
begin |
| 6989 |
CheckNotCompressing; |
| 6990 |
FNumberOfThreads := Value; |
| 6991 |
end; |
| 6992 |
|
| 6993 |
procedure TJcl7zCompressArchive.SetRemoveSfxBlock(Value: Boolean); |
| 6994 |
begin |
| 6995 |
CheckNotCompressing; |
| 6996 |
FRemoveSfxBlock := Value; |
| 6997 |
end; |
| 6998 |
|
| 6999 |
procedure TJcl7zCompressArchive.SetSaveCreationDateTime(Value: Boolean); |
| 7000 |
begin |
| 7001 |
CheckNotCompressing; |
| 7002 |
FSaveCreationDateTime := Value; |
| 7003 |
end; |
| 7004 |
|
| 7005 |
procedure TJcl7zCompressArchive.SetSaveLastAccessDateTime(Value: Boolean); |
| 7006 |
begin |
| 7007 |
CheckNotCompressing; |
| 7008 |
FSaveLastAccessDateTime := Value; |
| 7009 |
end; |
| 7010 |
|
| 7011 |
procedure TJcl7zCompressArchive.SetSaveLastWriteDateTime(Value: Boolean); |
| 7012 |
begin |
| 7013 |
CheckNotCompressing; |
| 7014 |
FSaveLastWriteDateTime := Value; |
| 7015 |
end; |
| 7016 |
|
| 7017 |
procedure TJcl7zCompressArchive.SetSolidBlockSize(const Value: Int64); |
| 7018 |
begin |
| 7019 |
CheckNotCompressing; |
| 7020 |
FSolidBlockSize := Value; |
| 7021 |
end; |
| 7022 |
|
| 7023 |
procedure TJcl7zCompressArchive.SetSolidExtension(Value: Boolean); |
| 7024 |
begin |
| 7025 |
CheckNotCompressing; |
| 7026 |
FSolidExtension := Value; |
| 7027 |
end; |
| 7028 |
|
| 7029 |
//=== { TJclZipCompressArchive } ============================================= |
| 7030 |
|
| 7031 |
class function TJclZipCompressArchive.ArchiveExtensions: string; |
| 7032 |
begin |
| 7033 |
Result := LoadResString(@RsCompressionZipExtensions); |
| 7034 |
end; |
| 7035 |
|
| 7036 |
class function TJclZipCompressArchive.ArchiveName: string; |
| 7037 |
begin |
| 7038 |
Result := LoadResString(@RsCompressionZipName); |
| 7039 |
end; |
| 7040 |
|
| 7041 |
class function TJclZipCompressArchive.ArchiveCLSID: TGUID; |
| 7042 |
begin |
| 7043 |
Result := CLSID_CFormatZip; |
| 7044 |
end; |
| 7045 |
|
| 7046 |
function TJclZipCompressArchive.GetAlgorithm: Cardinal; |
| 7047 |
begin |
| 7048 |
Result := FAlgorithm; |
| 7049 |
end; |
| 7050 |
|
| 7051 |
function TJclZipCompressArchive.GetCompressionLevel: Cardinal; |
| 7052 |
begin |
| 7053 |
Result := FCompressionLevel; |
| 7054 |
end; |
| 7055 |
|
| 7056 |
function TJclZipCompressArchive.GetCompressionLevelMax: Cardinal; |
| 7057 |
begin |
| 7058 |
Result := 9; |
| 7059 |
end; |
| 7060 |
|
| 7061 |
function TJclZipCompressArchive.GetCompressionLevelMin: Cardinal; |
| 7062 |
begin |
| 7063 |
Result := 0; |
| 7064 |
end; |
| 7065 |
|
| 7066 |
function TJclZipCompressArchive.GetCompressionMethod: TJclCompressionMethod; |
| 7067 |
begin |
| 7068 |
Result := FCompressionMethod; |
| 7069 |
end; |
| 7070 |
|
| 7071 |
function TJclZipCompressArchive.GetDictionarySize: Cardinal; |
| 7072 |
begin |
| 7073 |
Result := FDictionarySize; |
| 7074 |
end; |
| 7075 |
|
| 7076 |
function TJclZipCompressArchive.GetEncryptionMethod: TJclEncryptionMethod; |
| 7077 |
begin |
| 7078 |
Result := FEncryptionMethod; |
| 7079 |
end; |
| 7080 |
|
| 7081 |
function TJclZipCompressArchive.GetNumberOfPasses: Cardinal; |
| 7082 |
begin |
| 7083 |
Result := FNumberOfPasses; |
| 7084 |
end; |
| 7085 |
|
| 7086 |
function TJclZipCompressArchive.GetNumberOfThreads: Cardinal; |
| 7087 |
begin |
| 7088 |
Result := FNumberOfThreads; |
| 7089 |
end; |
| 7090 |
|
| 7091 |
function TJclZipCompressArchive.GetSupportedAlgorithms: TDynCardinalArray; |
| 7092 |
begin |
| 7093 |
SetLength(Result, 2); |
| 7094 |
Result[0] := 0; |
| 7095 |
Result[1] := 1; |
| 7096 |
end; |
| 7097 |
|
| 7098 |
function TJclZipCompressArchive.GetSupportedCompressionMethods: TJclCompressionMethods; |
| 7099 |
begin |
| 7100 |
Result := [cmCopy,cmDeflate,cmDeflate64,cmBZip2,cmLZMA,cmPPMd]; |
| 7101 |
end; |
| 7102 |
|
| 7103 |
function TJclZipCompressArchive.GetSupportedEncryptionMethods: TJclEncryptionMethods; |
| 7104 |
begin |
| 7105 |
Result := [emNone,emAES128,emAES192,emAES256,emZipCrypto]; |
| 7106 |
end; |
| 7107 |
|
| 7108 |
procedure TJclZipCompressArchive.InitializeArchiveProperties; |
| 7109 |
begin |
| 7110 |
inherited InitializeArchiveProperties; |
| 7111 |
FNumberOfThreads := 1; |
| 7112 |
FEncryptionMethod := emZipCrypto; |
| 7113 |
FDictionarySize := kBZip2DicSizeX5; |
| 7114 |
FCompressionLevel := 7; |
| 7115 |
FCompressionMethod := cmDeflate; |
| 7116 |
FNumberOfPasses := kDeflateNumPassesX7; |
| 7117 |
FAlgorithm := kLzAlgoX5; |
| 7118 |
end; |
| 7119 |
|
| 7120 |
class function TJclZipCompressArchive.MultipleItemContainer: Boolean; |
| 7121 |
begin |
| 7122 |
Result := True; |
| 7123 |
end; |
| 7124 |
|
| 7125 |
procedure TJclZipCompressArchive.SetAlgorithm(Value: Cardinal); |
| 7126 |
begin |
| 7127 |
CheckNotCompressing; |
| 7128 |
if (Value = 0) or (Value = 1) then |
| 7129 |
FAlgorithm := Value |
| 7130 |
else |
| 7131 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty); |
| 7132 |
end; |
| 7133 |
|
| 7134 |
procedure TJclZipCompressArchive.SetCompressionLevel(Value: Cardinal); |
| 7135 |
begin |
| 7136 |
CheckNotCompressing; |
| 7137 |
if Value <= 9 then |
| 7138 |
begin |
| 7139 |
FCompressionLevel := Value; |
| 7140 |
case FCompressionMethod of |
| 7141 |
cmDeflate, cmDeflate64: |
| 7142 |
begin |
| 7143 |
if Value >= 9 then |
| 7144 |
FNumberOfPasses := kDeflateNumPassesX9 |
| 7145 |
else |
| 7146 |
if Value >= 7 then |
| 7147 |
FNumberOfPasses := kDeflateNumPassesX7 |
| 7148 |
else |
| 7149 |
FNumberOfPasses := kDeflateNumPassesX1; |
| 7150 |
if Value >= 5 then |
| 7151 |
FAlgorithm := kLzAlgoX5 |
| 7152 |
else |
| 7153 |
FAlgorithm := kLzAlgoX1; |
| 7154 |
end; |
| 7155 |
cmBZip2: |
| 7156 |
begin |
| 7157 |
if Value >= 9 then |
| 7158 |
FNumberOfPasses := kBZip2NumPassesX9 |
| 7159 |
else |
| 7160 |
if Value >= 7 then |
| 7161 |
FNumberOfPasses := kBZip2NumPassesX7 |
| 7162 |
else |
| 7163 |
FNumberOfPasses := kBZip2NumPassesX1; |
| 7164 |
if Value >= 5 then |
| 7165 |
FDictionarySize := kBZip2DicSizeX5 |
| 7166 |
else |
| 7167 |
if Value >= 3 then |
| 7168 |
FDictionarySize := kBZip2DicSizeX3 |
| 7169 |
else |
| 7170 |
FDictionarySize := kBZip2DicSizeX1; |
| 7171 |
end; |
| 7172 |
cmLZMA: |
| 7173 |
begin |
| 7174 |
if Value >= 9 then |
| 7175 |
FDictionarySize := kLzmaDicSizeX9 |
| 7176 |
else |
| 7177 |
if Value >= 7 then |
| 7178 |
FDictionarySize := kLzmaDicSizeX7 |
| 7179 |
else |
| 7180 |
if Value >= 5 then |
| 7181 |
FDictionarySize := kLzmaDicSizeX5 |
| 7182 |
else |
| 7183 |
if Value >= 3 then |
| 7184 |
FDictionarySize := kLzmaDicSizeX3 |
| 7185 |
else |
| 7186 |
FDictionarySize := kLzmaDicSizeX1; |
| 7187 |
if Value >= 5 then |
| 7188 |
FAlgorithm := kLzAlgoX5 |
| 7189 |
else |
| 7190 |
FAlgorithm := kLzAlgoX1; |
| 7191 |
end; |
| 7192 |
end; |
| 7193 |
end |
| 7194 |
else |
| 7195 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty); |
| 7196 |
end; |
| 7197 |
|
| 7198 |
procedure TJclZipCompressArchive.SetCompressionMethod(Value: TJclCompressionMethod); |
| 7199 |
begin |
| 7200 |
CheckNotCompressing; |
| 7201 |
if Value in GetSupportedCompressionMethods then |
| 7202 |
FCompressionMethod := Value |
| 7203 |
else |
| 7204 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty); |
| 7205 |
end; |
| 7206 |
|
| 7207 |
procedure TJclZipCompressArchive.SetDictionarySize(Value: Cardinal); |
| 7208 |
begin |
| 7209 |
CheckNotCompressing; |
| 7210 |
FDictionarySize := Value; |
| 7211 |
end; |
| 7212 |
|
| 7213 |
procedure TJclZipCompressArchive.SetEncryptionMethod(Value: TJclEncryptionMethod); |
| 7214 |
begin |
| 7215 |
CheckNotCompressing; |
| 7216 |
if Value in GetSupportedEncryptionMethods then |
| 7217 |
FEncryptionMethod := Value |
| 7218 |
else |
| 7219 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty); |
| 7220 |
end; |
| 7221 |
|
| 7222 |
procedure TJclZipCompressArchive.SetNumberOfPasses(Value: Cardinal); |
| 7223 |
begin |
| 7224 |
CheckNotCompressing; |
| 7225 |
FNumberOfPasses := Value; |
| 7226 |
end; |
| 7227 |
|
| 7228 |
procedure TJclZipCompressArchive.SetNumberOfThreads(Value: Cardinal); |
| 7229 |
begin |
| 7230 |
CheckNotCompressing; |
| 7231 |
FNumberOfThreads := Value; |
| 7232 |
end; |
| 7233 |
|
| 7234 |
//=== { TJclBZ2CompressArchive } ============================================= |
| 7235 |
|
| 7236 |
class function TJclBZ2CompressArchive.ArchiveExtensions: string; |
| 7237 |
begin |
| 7238 |
Result := LoadResString(@RsCompressionBZip2Extensions); |
| 7239 |
end; |
| 7240 |
|
| 7241 |
class function TJclBZ2CompressArchive.ArchiveName: string; |
| 7242 |
begin |
| 7243 |
Result := LoadResString(@RsCompressionBZip2Name); |
| 7244 |
end; |
| 7245 |
|
| 7246 |
class function TJclBZ2CompressArchive.ArchiveSubExtensions: string; |
| 7247 |
begin |
| 7248 |
Result := LoadResString(@RsCompressionBZip2SubExtensions); |
| 7249 |
end; |
| 7250 |
|
| 7251 |
class function TJclBZ2CompressArchive.ArchiveCLSID: TGUID; |
| 7252 |
begin |
| 7253 |
Result := CLSID_CFormatBZ2; |
| 7254 |
end; |
| 7255 |
|
| 7256 |
function TJclBZ2CompressArchive.GetCompressionLevel: Cardinal; |
| 7257 |
begin |
| 7258 |
Result := FCompressionLevel; |
| 7259 |
end; |
| 7260 |
|
| 7261 |
function TJclBZ2CompressArchive.GetCompressionLevelMax: Cardinal; |
| 7262 |
begin |
| 7263 |
Result := 9; |
| 7264 |
end; |
| 7265 |
|
| 7266 |
function TJclBZ2CompressArchive.GetCompressionLevelMin: Cardinal; |
| 7267 |
begin |
| 7268 |
Result := 0; |
| 7269 |
end; |
| 7270 |
|
| 7271 |
function TJclBZ2CompressArchive.GetDictionarySize: Cardinal; |
| 7272 |
begin |
| 7273 |
Result := FDictionarySize; |
| 7274 |
end; |
| 7275 |
|
| 7276 |
function TJclBZ2CompressArchive.GetNumberOfPasses: Cardinal; |
| 7277 |
begin |
| 7278 |
Result := FNumberOfPasses; |
| 7279 |
end; |
| 7280 |
|
| 7281 |
function TJclBZ2CompressArchive.GetNumberOfThreads: Cardinal; |
| 7282 |
begin |
| 7283 |
Result := FNumberOfThreads; |
| 7284 |
end; |
| 7285 |
|
| 7286 |
procedure TJclBZ2CompressArchive.InitializeArchiveProperties; |
| 7287 |
begin |
| 7288 |
inherited InitializeArchiveProperties; |
| 7289 |
FNumberOfThreads := 1; |
| 7290 |
FDictionarySize := kBZip2DicSizeX5; |
| 7291 |
FCompressionLevel := 7; |
| 7292 |
FNumberOfPasses := kBZip2NumPassesX7; |
| 7293 |
end; |
| 7294 |
|
| 7295 |
procedure TJclBZ2CompressArchive.SetCompressionLevel(Value: Cardinal); |
| 7296 |
begin |
| 7297 |
CheckNotCompressing; |
| 7298 |
if Value <= 9 then |
| 7299 |
begin |
| 7300 |
FCompressionLevel := Value; |
| 7301 |
if Value >= 9 then |
| 7302 |
FNumberOfPasses := kBZip2NumPassesX9 |
| 7303 |
else |
| 7304 |
if Value >= 7 then |
| 7305 |
FNumberOfPasses := kBZip2NumPassesX7 |
| 7306 |
else |
| 7307 |
FNumberOfPasses := kBZip2NumPassesX1; |
| 7308 |
if Value >= 5 then |
| 7309 |
FDictionarySize := kBZip2DicSizeX5 |
| 7310 |
else |
| 7311 |
if Value >= 3 then |
| 7312 |
FDictionarySize := kBZip2DicSizeX3 |
| 7313 |
else |
| 7314 |
FDictionarySize := kBZip2DicSizeX1; |
| 7315 |
end |
| 7316 |
else |
| 7317 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty); |
| 7318 |
end; |
| 7319 |
|
| 7320 |
procedure TJclBZ2CompressArchive.SetDictionarySize(Value: Cardinal); |
| 7321 |
begin |
| 7322 |
CheckNotCompressing; |
| 7323 |
FDictionarySize := Value; |
| 7324 |
end; |
| 7325 |
|
| 7326 |
procedure TJclBZ2CompressArchive.SetNumberOfPasses(Value: Cardinal); |
| 7327 |
begin |
| 7328 |
CheckNotCompressing; |
| 7329 |
FNumberOfPasses := Value; |
| 7330 |
end; |
| 7331 |
|
| 7332 |
procedure TJclBZ2CompressArchive.SetNumberOfThreads(Value: Cardinal); |
| 7333 |
begin |
| 7334 |
CheckNotCompressing; |
| 7335 |
FNumberOfThreads := Value; |
| 7336 |
end; |
| 7337 |
|
| 7338 |
//=== { TJclTarCompressArchive } ============================================= |
| 7339 |
|
| 7340 |
class function TJclTarCompressArchive.ArchiveExtensions: string; |
| 7341 |
begin |
| 7342 |
Result := LoadResString(@RsCompressionTarExtensions); |
| 7343 |
end; |
| 7344 |
|
| 7345 |
class function TJclTarCompressArchive.ArchiveName: string; |
| 7346 |
begin |
| 7347 |
Result := LoadResString(@RsCompressionTarName); |
| 7348 |
end; |
| 7349 |
|
| 7350 |
class function TJclTarCompressArchive.ArchiveCLSID: TGUID; |
| 7351 |
begin |
| 7352 |
Result := CLSID_CFormatTar; |
| 7353 |
end; |
| 7354 |
|
| 7355 |
class function TJclTarCompressArchive.MultipleItemContainer: Boolean; |
| 7356 |
begin |
| 7357 |
Result := True; |
| 7358 |
end; |
| 7359 |
|
| 7360 |
//=== { TJclGZipCompressArchive } ============================================ |
| 7361 |
|
| 7362 |
class function TJclGZipCompressArchive.ArchiveExtensions: string; |
| 7363 |
begin |
| 7364 |
Result := LoadResString(@RsCompressionGZipExtensions); |
| 7365 |
end; |
| 7366 |
|
| 7367 |
class function TJclGZipCompressArchive.ArchiveName: string; |
| 7368 |
begin |
| 7369 |
Result := LoadResString(@RsCompressionGZipName); |
| 7370 |
end; |
| 7371 |
|
| 7372 |
class function TJclGZipCompressArchive.ArchiveSubExtensions: string; |
| 7373 |
begin |
| 7374 |
Result := LoadResString(@RsCompressionGZipSubExtensions); |
| 7375 |
end; |
| 7376 |
|
| 7377 |
class function TJclGZipCompressArchive.ArchiveCLSID: TGUID; |
| 7378 |
begin |
| 7379 |
Result := CLSID_CFormatGZip; |
| 7380 |
end; |
| 7381 |
|
| 7382 |
function TJclGZipCompressArchive.GetAlgorithm: Cardinal; |
| 7383 |
begin |
| 7384 |
Result := FAlgorithm; |
| 7385 |
end; |
| 7386 |
|
| 7387 |
function TJclGZipCompressArchive.GetCompressionLevel: Cardinal; |
| 7388 |
begin |
| 7389 |
Result := FCompressionLevel; |
| 7390 |
end; |
| 7391 |
|
| 7392 |
function TJclGZipCompressArchive.GetCompressionLevelMax: Cardinal; |
| 7393 |
begin |
| 7394 |
Result := 9; |
| 7395 |
end; |
| 7396 |
|
| 7397 |
function TJclGZipCompressArchive.GetCompressionLevelMin: Cardinal; |
| 7398 |
begin |
| 7399 |
Result := 0; |
| 7400 |
end; |
| 7401 |
|
| 7402 |
function TJclGZipCompressArchive.GetNumberOfPasses: Cardinal; |
| 7403 |
begin |
| 7404 |
Result := FNumberOfPasses; |
| 7405 |
end; |
| 7406 |
|
| 7407 |
function TJclGZipCompressArchive.GetSupportedAlgorithms: TDynCardinalArray; |
| 7408 |
begin |
| 7409 |
SetLength(Result,2); |
| 7410 |
Result[0] := 0; |
| 7411 |
Result[1] := 1; |
| 7412 |
end; |
| 7413 |
|
| 7414 |
procedure TJclGZipCompressArchive.InitializeArchiveProperties; |
| 7415 |
begin |
| 7416 |
inherited InitializeArchiveProperties; |
| 7417 |
FCompressionLevel := 7; |
| 7418 |
FNumberOfPasses := kDeflateNumPassesX7; |
| 7419 |
FAlgorithm := kLzAlgoX5; |
| 7420 |
end; |
| 7421 |
|
| 7422 |
procedure TJclGZipCompressArchive.SetAlgorithm(Value: Cardinal); |
| 7423 |
begin |
| 7424 |
CheckNotCompressing; |
| 7425 |
FAlgorithm := Value; |
| 7426 |
end; |
| 7427 |
|
| 7428 |
procedure TJclGZipCompressArchive.SetCompressionLevel(Value: Cardinal); |
| 7429 |
begin |
| 7430 |
CheckNotCompressing; |
| 7431 |
if Value <= 9 then |
| 7432 |
begin |
| 7433 |
if Value >= 9 then |
| 7434 |
FNumberOfPasses := kDeflateNumPassesX9 |
| 7435 |
else |
| 7436 |
if Value >= 7 then |
| 7437 |
FNumberOfPasses := kDeflateNumPassesX7 |
| 7438 |
else |
| 7439 |
FNumberOfPasses := kDeflateNumPassesX1; |
| 7440 |
if Value >= 5 then |
| 7441 |
FAlgorithm := kLzAlgoX5 |
| 7442 |
else |
| 7443 |
FAlgorithm := kLzAlgoX1; |
| 7444 |
end |
| 7445 |
else |
| 7446 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty); |
| 7447 |
end; |
| 7448 |
|
| 7449 |
procedure TJclGZipCompressArchive.SetNumberOfPasses(Value: Cardinal); |
| 7450 |
begin |
| 7451 |
CheckNotCompressing; |
| 7452 |
FNumberOfPasses := Value; |
| 7453 |
end; |
| 7454 |
|
| 7455 |
//=== { TJclXzCompressArchive } ============================================== |
| 7456 |
|
| 7457 |
class function TJclXzCompressArchive.ArchiveExtensions: string; |
| 7458 |
begin |
| 7459 |
Result := LoadResString(@RsCompressionXzExtensions); |
| 7460 |
end; |
| 7461 |
|
| 7462 |
class function TJclXzCompressArchive.ArchiveName: string; |
| 7463 |
begin |
| 7464 |
Result := LoadResString(@RsCompressionXzName); |
| 7465 |
end; |
| 7466 |
|
| 7467 |
class function TJclXzCompressArchive.ArchiveSubExtensions: string; |
| 7468 |
begin |
| 7469 |
Result := LoadResString(@RsCompressionXzSubExtensions); |
| 7470 |
end; |
| 7471 |
|
| 7472 |
class function TJclXzCompressArchive.ArchiveCLSID: TGUID; |
| 7473 |
begin |
| 7474 |
Result := CLSID_CFormatXz; |
| 7475 |
end; |
| 7476 |
|
| 7477 |
function TJclXzCompressArchive.GetCompressionMethod: TJclCompressionMethod; |
| 7478 |
begin |
| 7479 |
Result := FCompressionMethod; |
| 7480 |
end; |
| 7481 |
|
| 7482 |
function TJclXzCompressArchive.GetSupportedCompressionMethods: TJclCompressionMethods; |
| 7483 |
begin |
| 7484 |
Result := [cmLZMA2]; |
| 7485 |
end; |
| 7486 |
|
| 7487 |
procedure TJclXzCompressArchive.InitializeArchiveProperties; |
| 7488 |
begin |
| 7489 |
inherited InitializeArchiveProperties; |
| 7490 |
FCompressionMethod := cmLZMA2; |
| 7491 |
end; |
| 7492 |
|
| 7493 |
procedure TJclXzCompressArchive.SetCompressionMethod( |
| 7494 |
Value: TJclCompressionMethod); |
| 7495 |
begin |
| 7496 |
CheckNotCompressing; |
| 7497 |
FCompressionMethod := Value; |
| 7498 |
end; |
| 7499 |
|
| 7500 |
//=== { TJclSwfcCompressArchive } ============================================ |
| 7501 |
|
| 7502 |
class function TJclSwfcCompressArchive.ArchiveExtensions: string; |
| 7503 |
begin |
| 7504 |
Result := LoadResString(@RsCompressionSwfcExtensions); |
| 7505 |
end; |
| 7506 |
|
| 7507 |
class function TJclSwfcCompressArchive.ArchiveName: string; |
| 7508 |
begin |
| 7509 |
Result := LoadResString(@RsCompressionSwfcName); |
| 7510 |
end; |
| 7511 |
|
| 7512 |
class function TJclSwfcCompressArchive.ArchiveCLSID: TGUID; |
| 7513 |
begin |
| 7514 |
Result := CLSID_CFormatSwfc; |
| 7515 |
end; |
| 7516 |
|
| 7517 |
//=== { TJclWimCompressArchive } ============================================= |
| 7518 |
|
| 7519 |
class function TJclWimCompressArchive.ArchiveCLSID: TGUID; |
| 7520 |
begin |
| 7521 |
Result := CLSID_CFormatWim; |
| 7522 |
end; |
| 7523 |
|
| 7524 |
class function TJclWimCompressArchive.ArchiveExtensions: string; |
| 7525 |
begin |
| 7526 |
Result := LoadResString(@RsCompressionWimExtensions); |
| 7527 |
end; |
| 7528 |
|
| 7529 |
class function TJclWimCompressArchive.ArchiveName: string; |
| 7530 |
begin |
| 7531 |
Result := LoadResString(@RsCompressionWimName); |
| 7532 |
end; |
| 7533 |
|
| 7534 |
//=== { TJclSevenzipOpenCallback } =========================================== |
| 7535 |
|
| 7536 |
constructor TJclSevenzipOpenCallback.Create( |
| 7537 |
AArchive: TJclCompressionArchive); |
| 7538 |
begin |
| 7539 |
inherited Create; |
| 7540 |
FArchive := AArchive; |
| 7541 |
end; |
| 7542 |
|
| 7543 |
function TJclSevenzipOpenCallback.CryptoGetTextPassword( |
| 7544 |
password: PBStr): HRESULT; |
| 7545 |
begin |
| 7546 |
if Assigned(password) then |
| 7547 |
begin |
| 7548 |
if Length(FArchive.FPassword) = 0 then |
| 7549 |
begin |
| 7550 |
if Assigned(FArchive.OnPassword) then |
| 7551 |
FArchive.OnPassword(FArchive, FArchive.FPassword); |
| 7552 |
end; |
| 7553 |
password^ := SysAllocString(PWideChar(FArchive.Password)); |
| 7554 |
end; |
| 7555 |
Result := S_OK; |
| 7556 |
end; |
| 7557 |
|
| 7558 |
function TJclSevenzipOpenCallback.SetCompleted(Files, Bytes: PInt64): HRESULT; |
| 7559 |
begin |
| 7560 |
Result := S_OK; |
| 7561 |
if Assigned(Files) and not FArchive.DoProgress(Files^, FArchive.FProgressMax) then |
| 7562 |
Result := E_ABORT; |
| 7563 |
end; |
| 7564 |
|
| 7565 |
function TJclSevenzipOpenCallback.SetTotal(Files, Bytes: PInt64): HRESULT; |
| 7566 |
begin |
| 7567 |
if Assigned(Files) then |
| 7568 |
FArchive.FProgressMax := Files^; |
| 7569 |
if FArchive.CancelCurrentOperation then |
| 7570 |
Result := E_ABORT |
| 7571 |
else |
| 7572 |
Result := S_OK; |
| 7573 |
end; |
| 7574 |
|
| 7575 |
//=== { TJclSevenzipExtractCallback } ======================================== |
| 7576 |
|
| 7577 |
constructor TJclSevenzipExtractCallback.Create( |
| 7578 |
AArchive: TJclCompressionArchive); |
| 7579 |
begin |
| 7580 |
inherited Create; |
| 7581 |
FArchive := AArchive; |
| 7582 |
end; |
| 7583 |
|
| 7584 |
function TJclSevenzipExtractCallback.CryptoGetTextPassword( |
| 7585 |
password: PBStr): HRESULT; |
| 7586 |
begin |
| 7587 |
if Assigned(password) then |
| 7588 |
begin |
| 7589 |
if Length(FArchive.FPassword) = 0 then |
| 7590 |
begin |
| 7591 |
if Assigned(FArchive.OnPassword) then |
| 7592 |
FArchive.OnPassword(FArchive, FArchive.FPassword); |
| 7593 |
end; |
| 7594 |
password^ := SysAllocString(PWideChar(FArchive.Password)); |
| 7595 |
end; |
| 7596 |
Result := S_OK; |
| 7597 |
end; |
| 7598 |
|
| 7599 |
function TJclSevenzipExtractCallback.GetStream(Index: Cardinal; |
| 7600 |
out OutStream: ISequentialOutStream; askExtractMode: Cardinal): HRESULT; |
| 7601 |
begin |
| 7602 |
FLastStream := Index; |
| 7603 |
|
| 7604 |
Assert(askExtractMode in [kExtract, kTest, kSkip]); |
| 7605 |
|
| 7606 |
if askExtractMode in [kTest, kSkip] then |
| 7607 |
begin |
| 7608 |
OutStream := nil; |
| 7609 |
Result := S_OK; |
| 7610 |
end |
| 7611 |
else |
| 7612 |
if FArchive.Items[Index].ValidateExtraction(Index) then |
| 7613 |
begin |
| 7614 |
OutStream := TJclSevenzipOutStream.Create(FArchive, Index); |
| 7615 |
Result := S_OK; |
| 7616 |
end |
| 7617 |
else |
| 7618 |
begin |
| 7619 |
OutStream := nil; |
| 7620 |
Result := S_FALSE; |
| 7621 |
end; |
| 7622 |
end; |
| 7623 |
|
| 7624 |
function TJclSevenzipExtractCallback.PrepareOperation( |
| 7625 |
askExtractMode: Cardinal): HRESULT; |
| 7626 |
begin |
| 7627 |
Result := S_OK; |
| 7628 |
end; |
| 7629 |
|
| 7630 |
function TJclSevenzipExtractCallback.SetCompleted( |
| 7631 |
CompleteValue: PInt64): HRESULT; |
| 7632 |
begin |
| 7633 |
Result := S_OK; |
| 7634 |
if Assigned(CompleteValue) and not FArchive.DoProgress(CompleteValue^, FArchive.FProgressMax) then |
| 7635 |
Result := E_ABORT; |
| 7636 |
end; |
| 7637 |
|
| 7638 |
function TJclSevenzipExtractCallback.SetOperationResult( |
| 7639 |
resultEOperationResult: Integer): HRESULT; |
| 7640 |
var |
| 7641 |
LastItem: TJclCompressionItem; |
| 7642 |
begin |
| 7643 |
LastItem := FArchive.Items[FLastStream]; |
| 7644 |
case resultEOperationResult of |
| 7645 |
kOK: |
| 7646 |
begin |
| 7647 |
LastItem.OperationSuccess := osOK; |
| 7648 |
LastItem.UpdateFileTimes; |
| 7649 |
end; |
| 7650 |
kUnSupportedMethod: |
| 7651 |
begin |
| 7652 |
LastItem.OperationSuccess := osUnsupportedMethod; |
| 7653 |
LastItem.DeleteOutputFile; |
| 7654 |
end; |
| 7655 |
kDataError: |
| 7656 |
begin |
| 7657 |
LastItem.OperationSuccess := osDataError; |
| 7658 |
LastItem.DeleteOutputFile; |
| 7659 |
end; |
| 7660 |
kCRCError: |
| 7661 |
begin |
| 7662 |
LastItem.OperationSuccess := osCRCError; |
| 7663 |
LastItem.DeleteOutputFile; |
| 7664 |
end |
| 7665 |
else |
| 7666 |
LastItem.OperationSuccess := osUnknownError; |
| 7667 |
LastItem.DeleteOutputFile; |
| 7668 |
end; |
| 7669 |
|
| 7670 |
Result := S_OK; |
| 7671 |
end; |
| 7672 |
|
| 7673 |
function TJclSevenzipExtractCallback.SetRatioInfo(InSize, |
| 7674 |
OutSize: PInt64): HRESULT; |
| 7675 |
var |
| 7676 |
AInSize, AOutSize: Int64; |
| 7677 |
begin |
| 7678 |
if Assigned(InSize) then |
| 7679 |
AInSize := InSize^ |
| 7680 |
else |
| 7681 |
AInSize := -1; |
| 7682 |
if Assigned(OutSize) then |
| 7683 |
AOutSize := OutSize^ |
| 7684 |
else |
| 7685 |
AOutSize := -1; |
| 7686 |
if FArchive.DoRatio(AInSize, AOutSize) then |
| 7687 |
Result := S_OK |
| 7688 |
else |
| 7689 |
Result := E_ABORT; |
| 7690 |
end; |
| 7691 |
|
| 7692 |
function TJclSevenzipExtractCallback.SetTotal(Total: Int64): HRESULT; |
| 7693 |
begin |
| 7694 |
FArchive.FProgressMax := Total; |
| 7695 |
if FArchive.CancelCurrentOperation then |
| 7696 |
Result := E_ABORT |
| 7697 |
else |
| 7698 |
Result := S_OK; |
| 7699 |
end; |
| 7700 |
|
| 7701 |
//=== { TJclSevenzipDecompressItem } ========================================= |
| 7702 |
|
| 7703 |
function TJclSevenzipDecompressItem.GetNestedArchiveStream: TStream; |
| 7704 |
var |
| 7705 |
SequentialInStream: ISequentialInStream; |
| 7706 |
InStream: IInStream; |
| 7707 |
InterfaceID: TGUID; |
| 7708 |
begin |
| 7709 |
if Archive.SupportsNestedArchive and (Archive is TJclSevenzipDecompressArchive) then |
| 7710 |
begin |
| 7711 |
SevenzipCheck(TJclSevenzipDecompressArchive(Archive).InArchiveGetStream.GetStream(PackedIndex, SequentialInStream)); |
| 7712 |
InterfaceID := IInStream; |
| 7713 |
SevenzipCheck(SequentialInStream.QueryInterface(InterfaceID, InStream)); |
| 7714 |
Result := TJclSevenzipNestedInStream.Create(InStream); |
| 7715 |
end |
| 7716 |
else |
| 7717 |
Result := inherited GetNestedArchiveStream; |
| 7718 |
end; |
| 7719 |
|
| 7720 |
//=== { TJclSevenzipDecompressArchive } ====================================== |
| 7721 |
|
| 7722 |
class function TJclSevenzipDecompressArchive.ArchiveCLSID: TGUID; |
| 7723 |
begin |
| 7724 |
Result := GUID_NULL; |
| 7725 |
end; |
| 7726 |
|
| 7727 |
class function TJclSevenzipDecompressArchive.ArchiveSignature: TDynByteArray; |
| 7728 |
begin |
| 7729 |
Result := Get7zArchiveSignature(ArchiveCLSID); |
| 7730 |
end; |
| 7731 |
|
| 7732 |
destructor TJclSevenzipDecompressArchive.Destroy; |
| 7733 |
begin |
| 7734 |
FInArchive := nil; |
| 7735 |
FInArchiveGetStream := nil; |
| 7736 |
inherited Destroy; |
| 7737 |
end; |
| 7738 |
|
| 7739 |
procedure TJclSevenzipDecompressArchive.ExtractAll(const ADestinationDir: string; |
| 7740 |
AAutoCreateSubDir: Boolean); |
| 7741 |
var |
| 7742 |
AExtractCallback: IArchiveExtractCallback; |
| 7743 |
Indices: array of Cardinal; |
| 7744 |
NbIndices: Cardinal; |
| 7745 |
Index: Integer; |
| 7746 |
begin |
| 7747 |
CheckNotDecompressing; |
| 7748 |
|
| 7749 |
FDestinationDir := ADestinationDir; |
| 7750 |
FAutoCreateSubDir := AAutoCreateSubDir; |
| 7751 |
|
| 7752 |
if FDestinationDir <> '' then |
| 7753 |
FDestinationDir := PathAddSeparator(FDestinationDir); |
| 7754 |
|
| 7755 |
FDecompressing := True; |
| 7756 |
FExtractingAllIndex := 0; |
| 7757 |
AExtractCallback := TJclSevenzipExtractCallback.Create(Self); |
| 7758 |
try |
| 7759 |
OpenArchive; |
| 7760 |
|
| 7761 |
// seems buggy: first param "indices" is dereferenced without |
| 7762 |
// liveness checks inside Sevenzip code |
| 7763 |
//SevenzipCheck(InArchive.Extract(nil, $FFFFFFFF, 0, AExtractCallback)); |
| 7764 |
|
| 7765 |
NbIndices := ItemCount; |
| 7766 |
SetLength(Indices, NbIndices); |
| 7767 |
for Index := 0 to NbIndices - 1 do |
| 7768 |
begin |
| 7769 |
Items[Index].Selected := True; |
| 7770 |
Indices[Index] := Index; |
| 7771 |
end; |
| 7772 |
SevenzipCheck(InArchive.Extract(@Indices[0], NbIndices, 0, AExtractCallback)); |
| 7773 |
|
| 7774 |
CheckOperationSuccess; |
| 7775 |
finally |
| 7776 |
FDestinationDir := ''; |
| 7777 |
FDecompressing := False; |
| 7778 |
FExtractingAllIndex := -1; |
| 7779 |
FCurrentItemIndex := -1; |
| 7780 |
AExtractCallback := nil; |
| 7781 |
// release volumes and other finalizations |
| 7782 |
inherited ExtractAll(ADestinationDir, AAutoCreateSubDir); |
| 7783 |
end; |
| 7784 |
end; |
| 7785 |
|
| 7786 |
procedure TJclSevenzipDecompressArchive.ExtractSelected(const ADestinationDir: string; |
| 7787 |
AAutoCreateSubDir: Boolean); |
| 7788 |
var |
| 7789 |
AExtractCallback: IArchiveExtractCallback; |
| 7790 |
Indices: array of Cardinal; |
| 7791 |
NbIndices: Cardinal; |
| 7792 |
Index: Integer; |
| 7793 |
begin |
| 7794 |
CheckNotDecompressing; |
| 7795 |
|
| 7796 |
FDestinationDir := ADestinationDir; |
| 7797 |
FAutoCreateSubDir := AAutoCreateSubDir; |
| 7798 |
|
| 7799 |
if FDestinationDir <> '' then |
| 7800 |
FDestinationDir := PathAddSeparator(FDestinationDir); |
| 7801 |
|
| 7802 |
FDecompressing := True; |
| 7803 |
AExtractCallback := TJclSevenzipExtractCallback.Create(Self); |
| 7804 |
try |
| 7805 |
OpenArchive; |
| 7806 |
|
| 7807 |
NbIndices := 0; |
| 7808 |
for Index := 0 to ItemCount - 1 do |
| 7809 |
if Items[Index].Selected then |
| 7810 |
Inc(NbIndices); |
| 7811 |
|
| 7812 |
SetLength(Indices, NbIndices); |
| 7813 |
NbIndices := 0; |
| 7814 |
for Index := 0 to ItemCount - 1 do |
| 7815 |
if Items[Index].Selected then |
| 7816 |
begin |
| 7817 |
Indices[NbIndices] := Index; |
| 7818 |
Inc(NbIndices); |
| 7819 |
end; |
| 7820 |
|
| 7821 |
SevenzipCheck(InArchive.Extract(@Indices[0], Length(Indices), 0, AExtractCallback)); |
| 7822 |
CheckOperationSuccess; |
| 7823 |
finally |
| 7824 |
FDestinationDir := ''; |
| 7825 |
FDecompressing := False; |
| 7826 |
AExtractCallback := nil; |
| 7827 |
FCurrentItemIndex := -1; |
| 7828 |
// release volumes and other finalizations |
| 7829 |
inherited ExtractSelected(ADestinationDir, AAutoCreateSubDir); |
| 7830 |
end; |
| 7831 |
end; |
| 7832 |
|
| 7833 |
function TJclSevenzipDecompressArchive.GetInArchive: IInArchive; |
| 7834 |
var |
| 7835 |
SevenzipCLSID, InterfaceID: TGUID; |
| 7836 |
begin |
| 7837 |
if not Assigned(FInArchive) then |
| 7838 |
begin |
| 7839 |
SevenzipCLSID := ArchiveCLSID; |
| 7840 |
InterfaceID := Sevenzip.IInArchive; |
| 7841 |
if (not Is7ZipLoaded) and (not Load7Zip) then |
| 7842 |
raise EJclCompressionError.CreateRes(@RsCompression7zLoadError); |
| 7843 |
if (Sevenzip.CreateObject(@SevenzipCLSID, @InterfaceID, FInArchive) <> ERROR_SUCCESS) |
| 7844 |
or not Assigned(FInArchive) then |
| 7845 |
raise EJclCompressionError.CreateResFmt(@RsCompression7zInArchiveError, [GUIDToString(SevenzipCLSID)]); |
| 7846 |
FExtractingAllIndex := -1; |
| 7847 |
end; |
| 7848 |
Result := FInArchive; |
| 7849 |
end; |
| 7850 |
|
| 7851 |
function TJclSevenzipDecompressArchive.GetInArchiveGetStream: IInArchiveGetStream; |
| 7852 |
var |
| 7853 |
InterfaceID: TGUID; |
| 7854 |
begin |
| 7855 |
if not Assigned(FInArchiveGetStream) then |
| 7856 |
begin |
| 7857 |
InterfaceID := Sevenzip.IInArchiveGetStream; |
| 7858 |
SevenzipCheck(InArchive.QueryInterface(InterfaceID, FInArchiveGetStream)); |
| 7859 |
end; |
| 7860 |
Result := FInArchiveGetStream; |
| 7861 |
end; |
| 7862 |
|
| 7863 |
function TJclSevenzipDecompressArchive.GetItemClass: TJclCompressionItemClass; |
| 7864 |
begin |
| 7865 |
Result := TJclSevenzipDecompressItem; |
| 7866 |
end; |
| 7867 |
|
| 7868 |
function TJclSevenzipDecompressArchive.GetSupportsNestedArchive: Boolean; |
| 7869 |
var |
| 7870 |
InterfaceID: TGUID; |
| 7871 |
begin |
| 7872 |
Result := Assigned(FInArchiveGetStream); |
| 7873 |
if not Result then |
| 7874 |
begin |
| 7875 |
InterfaceID := Sevenzip.IInArchiveGetStream; |
| 7876 |
Result := InArchive.QueryInterface(InterfaceID, FInArchiveGetStream) = ERROR_SUCCESS; |
| 7877 |
end; |
| 7878 |
end; |
| 7879 |
|
| 7880 |
procedure TJclSevenzipDecompressArchive.ListFiles; |
| 7881 |
var |
| 7882 |
NumberOfItems: Cardinal; |
| 7883 |
Index: Integer; |
| 7884 |
AItem: TJclCompressionItem; |
| 7885 |
begin |
| 7886 |
CheckNotDecompressing; |
| 7887 |
|
| 7888 |
FListing := True; |
| 7889 |
try |
| 7890 |
ClearItems; |
| 7891 |
OpenArchive; |
| 7892 |
|
| 7893 |
SevenzipCheck(InArchive.GetNumberOfItems(@NumberOfItems)); |
| 7894 |
if NumberOfItems > 0 then |
| 7895 |
begin |
| 7896 |
for Index := 0 to NumberOfItems - 1 do |
| 7897 |
begin |
| 7898 |
AItem := GetItemClass.Create(Self); |
| 7899 |
Load7zFileAttribute(InArchive, Index, AItem); |
| 7900 |
FItems.Add(AItem); |
| 7901 |
end; |
| 7902 |
end; |
| 7903 |
finally |
| 7904 |
FListing := False; |
| 7905 |
end; |
| 7906 |
end; |
| 7907 |
|
| 7908 |
procedure TJclSevenzipDecompressArchive.OpenArchive; |
| 7909 |
var |
| 7910 |
SplitStream: TJclDynamicSplitStream; |
| 7911 |
OpenCallback: IArchiveOpenCallback; |
| 7912 |
MaxCheckStartPosition: Int64; |
| 7913 |
AInStream: IInStream; |
| 7914 |
begin |
| 7915 |
if not FOpened then |
| 7916 |
begin |
| 7917 |
if (VolumeFileNameMask <> '') or (VolumeMaxSize <> 0) or (FVolumes.Count <> 0) then |
| 7918 |
begin |
| 7919 |
SplitStream := TJclDynamicSplitStream.Create(False); |
| 7920 |
SplitStream.OnVolume := NeedStream; |
| 7921 |
SplitStream.OnVolumeMaxSize := NeedStreamMaxSize; |
| 7922 |
AInStream := TJclSevenzipInStream.Create(SplitStream, True); |
| 7923 |
end |
| 7924 |
else |
| 7925 |
AInStream := TJclSevenzipInStream.Create(NeedStream(0), False); |
| 7926 |
OpenCallback := TJclSevenzipOpenCallback.Create(Self); |
| 7927 |
|
| 7928 |
SetSevenzipArchiveCompressionProperties(Self, InArchive); |
| 7929 |
|
| 7930 |
MaxCheckStartPosition := 1 shl 22; |
| 7931 |
SevenzipCheck(InArchive.Open(AInStream, @MaxCheckStartPosition, OpenCallback)); |
| 7932 |
|
| 7933 |
GetSevenzipArchiveCompressionProperties(Self, InArchive); |
| 7934 |
|
| 7935 |
FOpened := True; |
| 7936 |
end; |
| 7937 |
end; |
| 7938 |
|
| 7939 |
//=== { TJclZipDecompressArchive } =========================================== |
| 7940 |
|
| 7941 |
class function TJclZipDecompressArchive.ArchiveExtensions: string; |
| 7942 |
begin |
| 7943 |
Result := LoadResString(@RsCompressionZipExtensions); |
| 7944 |
end; |
| 7945 |
|
| 7946 |
class function TJclZipDecompressArchive.ArchiveName: string; |
| 7947 |
begin |
| 7948 |
Result := LoadResString(@RsCompressionZipName); |
| 7949 |
end; |
| 7950 |
|
| 7951 |
class function TJclZipDecompressArchive.ArchiveCLSID: TGUID; |
| 7952 |
begin |
| 7953 |
Result := CLSID_CFormatZip; |
| 7954 |
end; |
| 7955 |
|
| 7956 |
function TJclZipDecompressArchive.GetNumberOfThreads: Cardinal; |
| 7957 |
begin |
| 7958 |
Result := FNumberOfThreads; |
| 7959 |
end; |
| 7960 |
|
| 7961 |
procedure TJclZipDecompressArchive.InitializeArchiveProperties; |
| 7962 |
begin |
| 7963 |
inherited InitializeArchiveProperties; |
| 7964 |
FNumberOfThreads := 1; |
| 7965 |
end; |
| 7966 |
|
| 7967 |
class function TJclZipDecompressArchive.MultipleItemContainer: Boolean; |
| 7968 |
begin |
| 7969 |
Result := True; |
| 7970 |
end; |
| 7971 |
|
| 7972 |
procedure TJclZipDecompressArchive.SetNumberOfThreads(Value: Cardinal); |
| 7973 |
begin |
| 7974 |
CheckNotDecompressing; |
| 7975 |
FNumberOfThreads := Value; |
| 7976 |
end; |
| 7977 |
|
| 7978 |
//=== { TJclBZ2DecompressArchive } =========================================== |
| 7979 |
|
| 7980 |
class function TJclBZ2DecompressArchive.ArchiveExtensions: string; |
| 7981 |
begin |
| 7982 |
Result := LoadResString(@RsCompressionBZip2Extensions); |
| 7983 |
end; |
| 7984 |
|
| 7985 |
class function TJclBZ2DecompressArchive.ArchiveName: string; |
| 7986 |
begin |
| 7987 |
Result := LoadResString(@RsCompressionBZip2Name); |
| 7988 |
end; |
| 7989 |
|
| 7990 |
class function TJclBZ2DecompressArchive.ArchiveSubExtensions: string; |
| 7991 |
begin |
| 7992 |
Result := LoadResString(@RsCompressionBZip2SubExtensions); |
| 7993 |
end; |
| 7994 |
|
| 7995 |
class function TJclBZ2DecompressArchive.ArchiveCLSID: TGUID; |
| 7996 |
begin |
| 7997 |
Result := CLSID_CFormatBZ2; |
| 7998 |
end; |
| 7999 |
|
| 8000 |
function TJclBZ2DecompressArchive.GetNumberOfThreads: Cardinal; |
| 8001 |
begin |
| 8002 |
Result := FNumberOfThreads; |
| 8003 |
end; |
| 8004 |
|
| 8005 |
procedure TJclBZ2DecompressArchive.InitializeArchiveProperties; |
| 8006 |
begin |
| 8007 |
inherited InitializeArchiveProperties; |
| 8008 |
FNumberOfThreads := 1; |
| 8009 |
end; |
| 8010 |
|
| 8011 |
procedure TJclBZ2DecompressArchive.SetNumberOfThreads(Value: Cardinal); |
| 8012 |
begin |
| 8013 |
CheckNotDecompressing; |
| 8014 |
FNumberOfThreads := Value; |
| 8015 |
end; |
| 8016 |
|
| 8017 |
//=== { TJclRarDecompressArchive } =========================================== |
| 8018 |
|
| 8019 |
class function TJclRarDecompressArchive.ArchiveExtensions: string; |
| 8020 |
begin |
| 8021 |
Result := LoadResString(@RsCompressionRarExtensions); |
| 8022 |
end; |
| 8023 |
|
| 8024 |
class function TJclRarDecompressArchive.ArchiveName: string; |
| 8025 |
begin |
| 8026 |
Result := LoadResString(@RsCompressionRarName); |
| 8027 |
end; |
| 8028 |
|
| 8029 |
class function TJclRarDecompressArchive.ArchiveCLSID: TGUID; |
| 8030 |
begin |
| 8031 |
Result := CLSID_CFormatRar; |
| 8032 |
end; |
| 8033 |
|
| 8034 |
class function TJclRarDecompressArchive.MultipleItemContainer: Boolean; |
| 8035 |
begin |
| 8036 |
Result := True; |
| 8037 |
end; |
| 8038 |
|
| 8039 |
//=== { TJclArjDecompressArchive } =========================================== |
| 8040 |
|
| 8041 |
class function TJclArjDecompressArchive.ArchiveExtensions: string; |
| 8042 |
begin |
| 8043 |
Result := LoadResString(@RsCompressionArjExtensions); |
| 8044 |
end; |
| 8045 |
|
| 8046 |
class function TJclArjDecompressArchive.ArchiveName: string; |
| 8047 |
begin |
| 8048 |
Result := LoadResString(@RsCompressionArjName); |
| 8049 |
end; |
| 8050 |
|
| 8051 |
class function TJclArjDecompressArchive.ArchiveCLSID: TGUID; |
| 8052 |
begin |
| 8053 |
Result := CLSID_CFormatArj; |
| 8054 |
end; |
| 8055 |
|
| 8056 |
class function TJclArjDecompressArchive.MultipleItemContainer: Boolean; |
| 8057 |
begin |
| 8058 |
Result := True; |
| 8059 |
end; |
| 8060 |
|
| 8061 |
//=== { TJclZDecompressArchive } ============================================= |
| 8062 |
|
| 8063 |
class function TJclZDecompressArchive.ArchiveExtensions: string; |
| 8064 |
begin |
| 8065 |
Result := LoadResString(@RsCompressionZExtensions); |
| 8066 |
end; |
| 8067 |
|
| 8068 |
class function TJclZDecompressArchive.ArchiveName: string; |
| 8069 |
begin |
| 8070 |
Result := LoadResString(@RsCompressionZName); |
| 8071 |
end; |
| 8072 |
|
| 8073 |
class function TJclZDecompressArchive.ArchiveSubExtensions: string; |
| 8074 |
begin |
| 8075 |
Result := LoadResString(@RsCompressionZSubExtensions); |
| 8076 |
end; |
| 8077 |
|
| 8078 |
class function TJclZDecompressArchive.ArchiveCLSID: TGUID; |
| 8079 |
begin |
| 8080 |
Result := CLSID_CFormatZ; |
| 8081 |
end; |
| 8082 |
|
| 8083 |
class function TJclZDecompressArchive.MultipleItemContainer: Boolean; |
| 8084 |
begin |
| 8085 |
Result := True; |
| 8086 |
end; |
| 8087 |
|
| 8088 |
//=== { TJclLzhDecompressArchive } =========================================== |
| 8089 |
|
| 8090 |
class function TJclLzhDecompressArchive.ArchiveExtensions: string; |
| 8091 |
begin |
| 8092 |
Result := LoadResString(@RsCompressionLzhExtensions); |
| 8093 |
end; |
| 8094 |
|
| 8095 |
class function TJclLzhDecompressArchive.ArchiveName: string; |
| 8096 |
begin |
| 8097 |
Result := LoadResString(@RsCompressionLzhName); |
| 8098 |
end; |
| 8099 |
|
| 8100 |
class function TJclLzhDecompressArchive.ArchiveCLSID: TGUID; |
| 8101 |
begin |
| 8102 |
Result := CLSID_CFormatLzh; |
| 8103 |
end; |
| 8104 |
|
| 8105 |
class function TJclLzhDecompressArchive.MultipleItemContainer: Boolean; |
| 8106 |
begin |
| 8107 |
Result := True; |
| 8108 |
end; |
| 8109 |
|
| 8110 |
//=== { TJcl7zDecompressArchive } ============================================ |
| 8111 |
|
| 8112 |
class function TJcl7zDecompressArchive.ArchiveExtensions: string; |
| 8113 |
begin |
| 8114 |
Result := LoadResString(@RsCompression7zExtensions); |
| 8115 |
end; |
| 8116 |
|
| 8117 |
class function TJcl7zDecompressArchive.ArchiveName: string; |
| 8118 |
begin |
| 8119 |
Result := LoadResString(@RsCompression7zName); |
| 8120 |
end; |
| 8121 |
|
| 8122 |
class function TJcl7zDecompressArchive.ArchiveCLSID: TGUID; |
| 8123 |
begin |
| 8124 |
Result := CLSID_CFormat7z; |
| 8125 |
end; |
| 8126 |
|
| 8127 |
function TJcl7zDecompressArchive.GetNumberOfThreads: Cardinal; |
| 8128 |
begin |
| 8129 |
Result := FNumberOfThreads; |
| 8130 |
end; |
| 8131 |
|
| 8132 |
procedure TJcl7zDecompressArchive.InitializeArchiveProperties; |
| 8133 |
begin |
| 8134 |
inherited InitializeArchiveProperties; |
| 8135 |
FNumberOfThreads := 1; |
| 8136 |
end; |
| 8137 |
|
| 8138 |
class function TJcl7zDecompressArchive.MultipleItemContainer: Boolean; |
| 8139 |
begin |
| 8140 |
Result := True; |
| 8141 |
end; |
| 8142 |
|
| 8143 |
procedure TJcl7zDecompressArchive.SetNumberOfThreads(Value: Cardinal); |
| 8144 |
begin |
| 8145 |
CheckNotDecompressing; |
| 8146 |
FNumberOfThreads := Value; |
| 8147 |
end; |
| 8148 |
|
| 8149 |
//=== { TJclCabDecompressArchive } =========================================== |
| 8150 |
|
| 8151 |
class function TJclCabDecompressArchive.ArchiveExtensions: string; |
| 8152 |
begin |
| 8153 |
Result := LoadResString(@RsCompressionCabExtensions); |
| 8154 |
end; |
| 8155 |
|
| 8156 |
class function TJclCabDecompressArchive.ArchiveName: string; |
| 8157 |
begin |
| 8158 |
Result := LoadResString(@RsCompressionCabName); |
| 8159 |
end; |
| 8160 |
|
| 8161 |
class function TJclCabDecompressArchive.ArchiveCLSID: TGUID; |
| 8162 |
begin |
| 8163 |
Result := CLSID_CFormatCab; |
| 8164 |
end; |
| 8165 |
|
| 8166 |
class function TJclCabDecompressArchive.MultipleItemContainer: Boolean; |
| 8167 |
begin |
| 8168 |
Result := True; |
| 8169 |
end; |
| 8170 |
|
| 8171 |
//=== { TJclNsisDecompressArchive } ========================================== |
| 8172 |
|
| 8173 |
class function TJclNsisDecompressArchive.ArchiveExtensions: string; |
| 8174 |
begin |
| 8175 |
Result := LoadResString(@RsCompressionNsisExtensions); |
| 8176 |
end; |
| 8177 |
|
| 8178 |
class function TJclNsisDecompressArchive.ArchiveName: string; |
| 8179 |
begin |
| 8180 |
Result := LoadResString(@RsCompressionNsisName); |
| 8181 |
end; |
| 8182 |
|
| 8183 |
class function TJclNsisDecompressArchive.ArchiveCLSID: TGUID; |
| 8184 |
begin |
| 8185 |
Result := CLSID_CFormatNsis; |
| 8186 |
end; |
| 8187 |
|
| 8188 |
class function TJclNsisDecompressArchive.MultipleItemContainer: Boolean; |
| 8189 |
begin |
| 8190 |
Result := True; |
| 8191 |
end; |
| 8192 |
|
| 8193 |
//=== { TJclLzmaDecompressArchive } ========================================== |
| 8194 |
|
| 8195 |
class function TJclLzmaDecompressArchive.ArchiveExtensions: string; |
| 8196 |
begin |
| 8197 |
Result := LoadResString(@RsCompressionLzmaExtensions); |
| 8198 |
end; |
| 8199 |
|
| 8200 |
class function TJclLzmaDecompressArchive.ArchiveName: string; |
| 8201 |
begin |
| 8202 |
Result := LoadResString(@RsCompressionLzmaName); |
| 8203 |
end; |
| 8204 |
|
| 8205 |
class function TJclLzmaDecompressArchive.ArchiveCLSID: TGUID; |
| 8206 |
begin |
| 8207 |
Result := CLSID_CFormatLzma; |
| 8208 |
end; |
| 8209 |
|
| 8210 |
class function TJclLzmaDecompressArchive.MultipleItemContainer: Boolean; |
| 8211 |
begin |
| 8212 |
Result := False; |
| 8213 |
end; |
| 8214 |
|
| 8215 |
//=== { TJclLzma86DecompressArchive } ======================================== |
| 8216 |
|
| 8217 |
class function TJclLzma86DecompressArchive.ArchiveExtensions: string; |
| 8218 |
begin |
| 8219 |
Result := LoadResString(@RsCompressionLzma86Extensions); |
| 8220 |
end; |
| 8221 |
|
| 8222 |
class function TJclLzma86DecompressArchive.ArchiveName: string; |
| 8223 |
begin |
| 8224 |
Result := LoadResString(@RsCompressionLzma86Name); |
| 8225 |
end; |
| 8226 |
|
| 8227 |
class function TJclLzma86DecompressArchive.ArchiveCLSID: TGUID; |
| 8228 |
begin |
| 8229 |
Result := CLSID_CFormatLzma86; |
| 8230 |
end; |
| 8231 |
|
| 8232 |
class function TJclLzma86DecompressArchive.MultipleItemContainer: Boolean; |
| 8233 |
begin |
| 8234 |
Result := False; |
| 8235 |
end; |
| 8236 |
|
| 8237 |
//=== { TJclPeDecompressArchive } ============================================ |
| 8238 |
|
| 8239 |
class function TJclPeDecompressArchive.ArchiveExtensions: string; |
| 8240 |
begin |
| 8241 |
Result := LoadResString(@RsCompressionPeExtensions); |
| 8242 |
end; |
| 8243 |
|
| 8244 |
class function TJclPeDecompressArchive.ArchiveName: string; |
| 8245 |
begin |
| 8246 |
Result := LoadResString(@RsCompressionPeName); |
| 8247 |
end; |
| 8248 |
|
| 8249 |
class function TJclPeDecompressArchive.ArchiveCLSID: TGUID; |
| 8250 |
begin |
| 8251 |
Result := CLSID_CFormatPe; |
| 8252 |
end; |
| 8253 |
|
| 8254 |
class function TJclPeDecompressArchive.MultipleItemContainer: Boolean; |
| 8255 |
begin |
| 8256 |
Result := True; |
| 8257 |
end; |
| 8258 |
|
| 8259 |
//=== { TJclElfDecompressArchive } =========================================== |
| 8260 |
|
| 8261 |
class function TJclElfDecompressArchive.ArchiveExtensions: string; |
| 8262 |
begin |
| 8263 |
Result := LoadResString(@RsCompressionElfExtensions); |
| 8264 |
end; |
| 8265 |
|
| 8266 |
class function TJclElfDecompressArchive.ArchiveName: string; |
| 8267 |
begin |
| 8268 |
Result := LoadResString(@RsCompressionElfName); |
| 8269 |
end; |
| 8270 |
|
| 8271 |
class function TJclElfDecompressArchive.ArchiveCLSID: TGUID; |
| 8272 |
begin |
| 8273 |
Result := CLSID_CFormatElf; |
| 8274 |
end; |
| 8275 |
|
| 8276 |
class function TJclElfDecompressArchive.MultipleItemContainer: Boolean; |
| 8277 |
begin |
| 8278 |
Result := True; |
| 8279 |
end; |
| 8280 |
|
| 8281 |
//=== { TJclMachoDecompressArchive } ========================================= |
| 8282 |
|
| 8283 |
class function TJclMachoDecompressArchive.ArchiveExtensions: string; |
| 8284 |
begin |
| 8285 |
Result := LoadResString(@RsCompressionMachoExtensions); |
| 8286 |
end; |
| 8287 |
|
| 8288 |
class function TJclMachoDecompressArchive.ArchiveName: string; |
| 8289 |
begin |
| 8290 |
Result := LoadResString(@RsCompressionMachoName); |
| 8291 |
end; |
| 8292 |
|
| 8293 |
class function TJclMachoDecompressArchive.ArchiveCLSID: TGUID; |
| 8294 |
begin |
| 8295 |
Result := CLSID_CFormatMacho; |
| 8296 |
end; |
| 8297 |
|
| 8298 |
class function TJclMachoDecompressArchive.MultipleItemContainer: Boolean; |
| 8299 |
begin |
| 8300 |
Result := True; |
| 8301 |
end; |
| 8302 |
|
| 8303 |
//=== { TJclUdfDecompressArchive } ========================================== |
| 8304 |
|
| 8305 |
class function TJclUdfDecompressArchive.ArchiveExtensions: string; |
| 8306 |
begin |
| 8307 |
Result := LoadResString(@RsCompressionUdfExtensions); |
| 8308 |
end; |
| 8309 |
|
| 8310 |
class function TJclUdfDecompressArchive.ArchiveName: string; |
| 8311 |
begin |
| 8312 |
Result := LoadResString(@RsCompressionUdfName); |
| 8313 |
end; |
| 8314 |
|
| 8315 |
class function TJclUdfDecompressArchive.ArchiveCLSID: TGUID; |
| 8316 |
begin |
| 8317 |
Result := CLSID_CFormatUdf; |
| 8318 |
end; |
| 8319 |
|
| 8320 |
class function TJclUdfDecompressArchive.MultipleItemContainer: Boolean; |
| 8321 |
begin |
| 8322 |
Result := True; |
| 8323 |
end; |
| 8324 |
|
| 8325 |
//=== { TJclXarDecompressArchive } =========================================== |
| 8326 |
|
| 8327 |
class function TJclXarDecompressArchive.ArchiveExtensions: string; |
| 8328 |
begin |
| 8329 |
Result := LoadResString(@RsCompressionXarExtensions); |
| 8330 |
end; |
| 8331 |
|
| 8332 |
class function TJclXarDecompressArchive.ArchiveName: string; |
| 8333 |
begin |
| 8334 |
Result := LoadResString(@RsCompressionXarName); |
| 8335 |
end; |
| 8336 |
|
| 8337 |
class function TJclXarDecompressArchive.ArchiveCLSID: TGUID; |
| 8338 |
begin |
| 8339 |
Result := CLSID_CFormatXar; |
| 8340 |
end; |
| 8341 |
|
| 8342 |
class function TJclXarDecompressArchive.MultipleItemContainer: Boolean; |
| 8343 |
begin |
| 8344 |
Result := True; |
| 8345 |
end; |
| 8346 |
|
| 8347 |
//=== { TJclMubDecompressArchive } =========================================== |
| 8348 |
|
| 8349 |
class function TJclMubDecompressArchive.ArchiveExtensions: string; |
| 8350 |
begin |
| 8351 |
Result := LoadResString(@RsCompressionMubExtensions); |
| 8352 |
end; |
| 8353 |
|
| 8354 |
class function TJclMubDecompressArchive.ArchiveName: string; |
| 8355 |
begin |
| 8356 |
Result := LoadResString(@RsCompressionMubName); |
| 8357 |
end; |
| 8358 |
|
| 8359 |
class function TJclMubDecompressArchive.ArchiveCLSID: TGUID; |
| 8360 |
begin |
| 8361 |
Result := CLSID_CFormatMub; |
| 8362 |
end; |
| 8363 |
|
| 8364 |
class function TJclMubDecompressArchive.MultipleItemContainer: Boolean; |
| 8365 |
begin |
| 8366 |
Result := True; |
| 8367 |
end; |
| 8368 |
|
| 8369 |
//=== { TJclHfsDecompressArchive } =========================================== |
| 8370 |
|
| 8371 |
class function TJclHfsDecompressArchive.ArchiveExtensions: string; |
| 8372 |
begin |
| 8373 |
Result := LoadResString(@RsCompressionHfsExtensions); |
| 8374 |
end; |
| 8375 |
|
| 8376 |
class function TJclHfsDecompressArchive.ArchiveName: string; |
| 8377 |
begin |
| 8378 |
Result := LoadResString(@RsCompressionHfsName); |
| 8379 |
end; |
| 8380 |
|
| 8381 |
class function TJclHfsDecompressArchive.ArchiveCLSID: TGUID; |
| 8382 |
begin |
| 8383 |
Result := CLSID_CFormatHfs; |
| 8384 |
end; |
| 8385 |
|
| 8386 |
class function TJclHfsDecompressArchive.MultipleItemContainer: Boolean; |
| 8387 |
begin |
| 8388 |
Result := True; |
| 8389 |
end; |
| 8390 |
|
| 8391 |
//=== { TJclDmgDecompressArchive } =========================================== |
| 8392 |
|
| 8393 |
class function TJclDmgDecompressArchive.ArchiveExtensions: string; |
| 8394 |
begin |
| 8395 |
Result := LoadResString(@RsCompressionDmgExtensions); |
| 8396 |
end; |
| 8397 |
|
| 8398 |
class function TJclDmgDecompressArchive.ArchiveName: string; |
| 8399 |
begin |
| 8400 |
Result := LoadResString(@RsCompressionDmgName); |
| 8401 |
end; |
| 8402 |
|
| 8403 |
class function TJclDmgDecompressArchive.ArchiveCLSID: TGUID; |
| 8404 |
begin |
| 8405 |
Result := CLSID_CFormatDmg; |
| 8406 |
end; |
| 8407 |
|
| 8408 |
class function TJclDmgDecompressArchive.MultipleItemContainer: Boolean; |
| 8409 |
begin |
| 8410 |
Result := True; |
| 8411 |
end; |
| 8412 |
|
| 8413 |
//=== { TJclCompoundDecompressArchive } ====================================== |
| 8414 |
|
| 8415 |
class function TJclCompoundDecompressArchive.ArchiveExtensions: string; |
| 8416 |
begin |
| 8417 |
Result := LoadResString(@RsCompressionCompoundExtensions); |
| 8418 |
end; |
| 8419 |
|
| 8420 |
class function TJclCompoundDecompressArchive.ArchiveName: string; |
| 8421 |
begin |
| 8422 |
Result := LoadResString(@RsCompressionCompoundName); |
| 8423 |
end; |
| 8424 |
|
| 8425 |
class function TJclCompoundDecompressArchive.ArchiveCLSID: TGUID; |
| 8426 |
begin |
| 8427 |
Result := CLSID_CFormatCompound; |
| 8428 |
end; |
| 8429 |
|
| 8430 |
class function TJclCompoundDecompressArchive.MultipleItemContainer: Boolean; |
| 8431 |
begin |
| 8432 |
Result := True; |
| 8433 |
end; |
| 8434 |
|
| 8435 |
//=== { TJclWimDecompressArchive } =========================================== |
| 8436 |
|
| 8437 |
class function TJclWimDecompressArchive.ArchiveExtensions: string; |
| 8438 |
begin |
| 8439 |
Result := LoadResString(@RsCompressionWimExtensions); |
| 8440 |
end; |
| 8441 |
|
| 8442 |
class function TJclWimDecompressArchive.ArchiveName: string; |
| 8443 |
begin |
| 8444 |
Result := LoadResString(@RsCompressionWimName); |
| 8445 |
end; |
| 8446 |
|
| 8447 |
class function TJclWimDecompressArchive.ArchiveCLSID: TGUID; |
| 8448 |
begin |
| 8449 |
Result := CLSID_CFormatWim; |
| 8450 |
end; |
| 8451 |
|
| 8452 |
class function TJclWimDecompressArchive.MultipleItemContainer: Boolean; |
| 8453 |
begin |
| 8454 |
Result := True; |
| 8455 |
end; |
| 8456 |
|
| 8457 |
//=== { TJclIsoDecompressArchive } =========================================== |
| 8458 |
|
| 8459 |
class function TJclIsoDecompressArchive.ArchiveExtensions: string; |
| 8460 |
begin |
| 8461 |
Result := LoadResString(@RsCompressionIsoExtensions); |
| 8462 |
end; |
| 8463 |
|
| 8464 |
class function TJclIsoDecompressArchive.ArchiveName: string; |
| 8465 |
begin |
| 8466 |
Result := LoadResString(@RsCompressionIsoName); |
| 8467 |
end; |
| 8468 |
|
| 8469 |
class function TJclIsoDecompressArchive.ArchiveCLSID: TGUID; |
| 8470 |
begin |
| 8471 |
Result := CLSID_CFormatIso; |
| 8472 |
end; |
| 8473 |
|
| 8474 |
class function TJclIsoDecompressArchive.MultipleItemContainer: Boolean; |
| 8475 |
begin |
| 8476 |
Result := True; |
| 8477 |
end; |
| 8478 |
|
| 8479 |
//=== { TJclChmDecompressArchive } =========================================== |
| 8480 |
|
| 8481 |
class function TJclChmDecompressArchive.ArchiveExtensions: string; |
| 8482 |
begin |
| 8483 |
Result := LoadResString(@RsCompressionChmExtensions); |
| 8484 |
end; |
| 8485 |
|
| 8486 |
class function TJclChmDecompressArchive.ArchiveName: string; |
| 8487 |
begin |
| 8488 |
Result := LoadResString(@RsCompressionChmName); |
| 8489 |
end; |
| 8490 |
|
| 8491 |
class function TJclChmDecompressArchive.ArchiveCLSID: TGUID; |
| 8492 |
begin |
| 8493 |
Result := CLSID_CFormatChm; |
| 8494 |
end; |
| 8495 |
|
| 8496 |
class function TJclChmDecompressArchive.MultipleItemContainer: Boolean; |
| 8497 |
begin |
| 8498 |
Result := True; |
| 8499 |
end; |
| 8500 |
|
| 8501 |
//=== { TJclSplitDecompressArchive } ========================================= |
| 8502 |
|
| 8503 |
class function TJclSplitDecompressArchive.ArchiveExtensions: string; |
| 8504 |
begin |
| 8505 |
Result := LoadResString(@RsCompressionSplitExtensions); |
| 8506 |
end; |
| 8507 |
|
| 8508 |
class function TJclSplitDecompressArchive.ArchiveName: string; |
| 8509 |
begin |
| 8510 |
Result := LoadResString(@RsCompressionSplitName); |
| 8511 |
end; |
| 8512 |
|
| 8513 |
class function TJclSplitDecompressArchive.ArchiveCLSID: TGUID; |
| 8514 |
begin |
| 8515 |
Result := CLSID_CFormatSplit; |
| 8516 |
end; |
| 8517 |
|
| 8518 |
//=== { TJclRpmDecompressArchive } =========================================== |
| 8519 |
|
| 8520 |
class function TJclRpmDecompressArchive.ArchiveExtensions: string; |
| 8521 |
begin |
| 8522 |
Result := LoadResString(@RsCompressionRpmExtensions); |
| 8523 |
end; |
| 8524 |
|
| 8525 |
class function TJclRpmDecompressArchive.ArchiveName: string; |
| 8526 |
begin |
| 8527 |
Result := LoadResString(@RsCompressionRpmName); |
| 8528 |
end; |
| 8529 |
|
| 8530 |
class function TJclRpmDecompressArchive.ArchiveCLSID: TGUID; |
| 8531 |
begin |
| 8532 |
Result := CLSID_CFormatRpm; |
| 8533 |
end; |
| 8534 |
|
| 8535 |
class function TJclRpmDecompressArchive.MultipleItemContainer: Boolean; |
| 8536 |
begin |
| 8537 |
Result := True; |
| 8538 |
end; |
| 8539 |
|
| 8540 |
//=== { TJclDebDecompressArchive } =========================================== |
| 8541 |
|
| 8542 |
class function TJclDebDecompressArchive.ArchiveExtensions: string; |
| 8543 |
begin |
| 8544 |
Result := LoadResString(@RsCompressionDebExtensions); |
| 8545 |
end; |
| 8546 |
|
| 8547 |
class function TJclDebDecompressArchive.ArchiveName: string; |
| 8548 |
begin |
| 8549 |
Result := LoadResString(@RsCompressionDebName); |
| 8550 |
end; |
| 8551 |
|
| 8552 |
class function TJclDebDecompressArchive.ArchiveCLSID: TGUID; |
| 8553 |
begin |
| 8554 |
Result := CLSID_CFormatDeb; |
| 8555 |
end; |
| 8556 |
|
| 8557 |
class function TJclDebDecompressArchive.MultipleItemContainer: Boolean; |
| 8558 |
begin |
| 8559 |
Result := True; |
| 8560 |
end; |
| 8561 |
|
| 8562 |
//=== { TJclCpioDecompressArchive } ========================================== |
| 8563 |
|
| 8564 |
class function TJclCpioDecompressArchive.ArchiveExtensions: string; |
| 8565 |
begin |
| 8566 |
Result := LoadResString(@RsCompressionCpioExtensions); |
| 8567 |
end; |
| 8568 |
|
| 8569 |
class function TJclCpioDecompressArchive.ArchiveName: string; |
| 8570 |
begin |
| 8571 |
Result := LoadResString(@RsCompressionCpioName); |
| 8572 |
end; |
| 8573 |
|
| 8574 |
class function TJclCpioDecompressArchive.ArchiveCLSID: TGUID; |
| 8575 |
begin |
| 8576 |
Result := CLSID_CFormatCpio; |
| 8577 |
end; |
| 8578 |
|
| 8579 |
class function TJclCpioDecompressArchive.MultipleItemContainer: Boolean; |
| 8580 |
begin |
| 8581 |
Result := True; |
| 8582 |
end; |
| 8583 |
|
| 8584 |
//=== { TJclTarDecompressArchive } =========================================== |
| 8585 |
|
| 8586 |
class function TJclTarDecompressArchive.ArchiveExtensions: string; |
| 8587 |
begin |
| 8588 |
Result := LoadResString(@RsCompressionTarExtensions); |
| 8589 |
end; |
| 8590 |
|
| 8591 |
class function TJclTarDecompressArchive.ArchiveName: string; |
| 8592 |
begin |
| 8593 |
Result := LoadResString(@RsCompressionTarName); |
| 8594 |
end; |
| 8595 |
|
| 8596 |
class function TJclTarDecompressArchive.ArchiveCLSID: TGUID; |
| 8597 |
begin |
| 8598 |
Result := CLSID_CFormatTar; |
| 8599 |
end; |
| 8600 |
|
| 8601 |
class function TJclTarDecompressArchive.MultipleItemContainer: Boolean; |
| 8602 |
begin |
| 8603 |
Result := True; |
| 8604 |
end; |
| 8605 |
|
| 8606 |
//=== { TJclGZipDecompressArchive } ========================================== |
| 8607 |
|
| 8608 |
class function TJclGZipDecompressArchive.ArchiveExtensions: string; |
| 8609 |
begin |
| 8610 |
Result := LoadResString(@RsCompressionGZipExtensions); |
| 8611 |
end; |
| 8612 |
|
| 8613 |
class function TJclGZipDecompressArchive.ArchiveName: string; |
| 8614 |
begin |
| 8615 |
Result := LoadResString(@RsCompressionGZipName); |
| 8616 |
end; |
| 8617 |
|
| 8618 |
class function TJclGZipDecompressArchive.ArchiveSubExtensions: string; |
| 8619 |
begin |
| 8620 |
Result := LoadResString(@RsCompressionGZipSubExtensions); |
| 8621 |
end; |
| 8622 |
|
| 8623 |
class function TJclGZipDecompressArchive.ArchiveCLSID: TGUID; |
| 8624 |
begin |
| 8625 |
Result := CLSID_CFormatGZip; |
| 8626 |
end; |
| 8627 |
|
| 8628 |
//=== { TJclXzDecompressArchive } ============================================ |
| 8629 |
|
| 8630 |
class function TJclXzDecompressArchive.ArchiveExtensions: string; |
| 8631 |
begin |
| 8632 |
Result := LoadResString(@RsCompressionXzExtensions); |
| 8633 |
end; |
| 8634 |
|
| 8635 |
class function TJclXzDecompressArchive.ArchiveName: string; |
| 8636 |
begin |
| 8637 |
Result := LoadResString(@RsCompressionXzName); |
| 8638 |
end; |
| 8639 |
|
| 8640 |
class function TJclXzDecompressArchive.ArchiveSubExtensions: string; |
| 8641 |
begin |
| 8642 |
Result := LoadResString(@RsCompressionXzSubExtensions); |
| 8643 |
end; |
| 8644 |
|
| 8645 |
class function TJclXzDecompressArchive.ArchiveCLSID: TGUID; |
| 8646 |
begin |
| 8647 |
Result := CLSID_CFormatXz; |
| 8648 |
end; |
| 8649 |
|
| 8650 |
//=== { TJclNtfsDecompressArchive } ========================================== |
| 8651 |
|
| 8652 |
class function TJclNtfsDecompressArchive.ArchiveExtensions: string; |
| 8653 |
begin |
| 8654 |
Result := LoadResString(@RsCompressionNtfsExtensions); |
| 8655 |
end; |
| 8656 |
|
| 8657 |
class function TJclNtfsDecompressArchive.ArchiveName: string; |
| 8658 |
begin |
| 8659 |
Result := LoadResString(@RsCompressionNtfsName); |
| 8660 |
end; |
| 8661 |
|
| 8662 |
class function TJclNtfsDecompressArchive.ArchiveCLSID: TGUID; |
| 8663 |
begin |
| 8664 |
Result := CLSID_CFormatNtfs; |
| 8665 |
end; |
| 8666 |
|
| 8667 |
class function TJclNtfsDecompressArchive.MultipleItemContainer: Boolean; |
| 8668 |
begin |
| 8669 |
Result := True; |
| 8670 |
end; |
| 8671 |
|
| 8672 |
//=== { TJclFatDecompressArchive } =========================================== |
| 8673 |
|
| 8674 |
class function TJclFatDecompressArchive.ArchiveExtensions: string; |
| 8675 |
begin |
| 8676 |
Result := LoadResString(@RsCompressionFatExtensions); |
| 8677 |
end; |
| 8678 |
|
| 8679 |
class function TJclFatDecompressArchive.ArchiveName: string; |
| 8680 |
begin |
| 8681 |
Result := LoadResString(@RsCompressionFatName); |
| 8682 |
end; |
| 8683 |
|
| 8684 |
class function TJclFatDecompressArchive.ArchiveCLSID: TGUID; |
| 8685 |
begin |
| 8686 |
Result := CLSID_CFormatFat; |
| 8687 |
end; |
| 8688 |
|
| 8689 |
class function TJclFatDecompressArchive.MultipleItemContainer: Boolean; |
| 8690 |
begin |
| 8691 |
Result := True; |
| 8692 |
end; |
| 8693 |
|
| 8694 |
//=== { TJclMbrDecompressArchive } =========================================== |
| 8695 |
|
| 8696 |
class function TJclMbrDecompressArchive.ArchiveExtensions: string; |
| 8697 |
begin |
| 8698 |
Result := LoadResString(@RsCompressionMbrExtensions); |
| 8699 |
end; |
| 8700 |
|
| 8701 |
class function TJclMbrDecompressArchive.ArchiveName: string; |
| 8702 |
begin |
| 8703 |
Result := LoadResString(@RsCompressionMbrName); |
| 8704 |
end; |
| 8705 |
|
| 8706 |
class function TJclMbrDecompressArchive.ArchiveCLSID: TGUID; |
| 8707 |
begin |
| 8708 |
Result := CLSID_CFormatMbr; |
| 8709 |
end; |
| 8710 |
|
| 8711 |
class function TJclMbrDecompressArchive.MultipleItemContainer: Boolean; |
| 8712 |
begin |
| 8713 |
Result := True; |
| 8714 |
end; |
| 8715 |
|
| 8716 |
//=== { TJclVhdDecompressArchive } =========================================== |
| 8717 |
|
| 8718 |
class function TJclVhdDecompressArchive.ArchiveExtensions: string; |
| 8719 |
begin |
| 8720 |
Result := LoadResString(@RsCompressionVhdExtensions); |
| 8721 |
end; |
| 8722 |
|
| 8723 |
class function TJclVhdDecompressArchive.ArchiveName: string; |
| 8724 |
begin |
| 8725 |
Result := LoadResString(@RsCompressionVhdName); |
| 8726 |
end; |
| 8727 |
|
| 8728 |
class function TJclVhdDecompressArchive.ArchiveSubExtensions: string; |
| 8729 |
begin |
| 8730 |
Result := LoadResString(@RsCompressionVhdSubExtensions); |
| 8731 |
end; |
| 8732 |
|
| 8733 |
class function TJclVhdDecompressArchive.ArchiveCLSID: TGUID; |
| 8734 |
begin |
| 8735 |
Result := CLSID_CFormatVhd; |
| 8736 |
end; |
| 8737 |
|
| 8738 |
//=== { TJclMslzDecompressArchive } ========================================== |
| 8739 |
|
| 8740 |
class function TJclMslzDecompressArchive.ArchiveExtensions: string; |
| 8741 |
begin |
| 8742 |
Result := LoadResString(@RsCompressionMslzExtensions); |
| 8743 |
end; |
| 8744 |
|
| 8745 |
class function TJclMslzDecompressArchive.ArchiveName: string; |
| 8746 |
begin |
| 8747 |
Result := LoadResString(@RsCompressionMslzName); |
| 8748 |
end; |
| 8749 |
|
| 8750 |
class function TJclMslzDecompressArchive.ArchiveCLSID: TGUID; |
| 8751 |
begin |
| 8752 |
Result := CLSID_CFormatMslz; |
| 8753 |
end; |
| 8754 |
|
| 8755 |
//=== { TJclFlvDecompressArchive } =========================================== |
| 8756 |
|
| 8757 |
class function TJclFlvDecompressArchive.ArchiveExtensions: string; |
| 8758 |
begin |
| 8759 |
Result := LoadResString(@RsCompressionFlvExtensions); |
| 8760 |
end; |
| 8761 |
|
| 8762 |
class function TJclFlvDecompressArchive.ArchiveName: string; |
| 8763 |
begin |
| 8764 |
Result := LoadResString(@RsCompressionFlvName); |
| 8765 |
end; |
| 8766 |
|
| 8767 |
class function TJclFlvDecompressArchive.ArchiveCLSID: TGUID; |
| 8768 |
begin |
| 8769 |
Result := CLSID_CFormatFlv; |
| 8770 |
end; |
| 8771 |
|
| 8772 |
//=== { TJclSwfDecompressArchive } =========================================== |
| 8773 |
|
| 8774 |
class function TJclSwfDecompressArchive.ArchiveExtensions: string; |
| 8775 |
begin |
| 8776 |
Result := LoadResString(@RsCompressionSwfExtensions); |
| 8777 |
end; |
| 8778 |
|
| 8779 |
class function TJclSwfDecompressArchive.ArchiveName: string; |
| 8780 |
begin |
| 8781 |
Result := LoadResString(@RsCompressionSwfName); |
| 8782 |
end; |
| 8783 |
|
| 8784 |
class function TJclSwfDecompressArchive.ArchiveCLSID: TGUID; |
| 8785 |
begin |
| 8786 |
Result := CLSID_CFormatSwf; |
| 8787 |
end; |
| 8788 |
|
| 8789 |
//=== { TJclSwfcDecompressArchive } ========================================== |
| 8790 |
|
| 8791 |
class function TJclSwfcDecompressArchive.ArchiveExtensions: string; |
| 8792 |
begin |
| 8793 |
Result := LoadResString(@RsCompressionSwfcExtensions); |
| 8794 |
end; |
| 8795 |
|
| 8796 |
class function TJclSwfcDecompressArchive.ArchiveName: string; |
| 8797 |
begin |
| 8798 |
Result := LoadResString(@RsCompressionSwfcName); |
| 8799 |
end; |
| 8800 |
|
| 8801 |
class function TJclSwfcDecompressArchive.ArchiveCLSID: TGUID; |
| 8802 |
begin |
| 8803 |
Result := CLSID_CFormatSwfc; |
| 8804 |
end; |
| 8805 |
|
| 8806 |
//=== { TJclAPMDecompressArchive } =========================================== |
| 8807 |
|
| 8808 |
class function TJclAPMDecompressArchive.ArchiveExtensions: string; |
| 8809 |
begin |
| 8810 |
Result := LoadResString(@RsCompressionApmExtensions); |
| 8811 |
end; |
| 8812 |
|
| 8813 |
class function TJclAPMDecompressArchive.ArchiveName: string; |
| 8814 |
begin |
| 8815 |
Result := LoadResString(@RsCompressionApmName); |
| 8816 |
end; |
| 8817 |
|
| 8818 |
class function TJclAPMDecompressArchive.ArchiveCLSID: TGUID; |
| 8819 |
begin |
| 8820 |
Result := CLSID_CFormatAPM; |
| 8821 |
end; |
| 8822 |
|
| 8823 |
//=== { TJclPpmdDecompressArchive } ========================================== |
| 8824 |
|
| 8825 |
class function TJclPpmdDecompressArchive.ArchiveExtensions: string; |
| 8826 |
begin |
| 8827 |
Result := LoadResString(@RsCompressionPpmdExtensions); |
| 8828 |
end; |
| 8829 |
|
| 8830 |
class function TJclPpmdDecompressArchive.ArchiveName: string; |
| 8831 |
begin |
| 8832 |
Result := LoadResString(@RsCompressionPpmdName); |
| 8833 |
end; |
| 8834 |
|
| 8835 |
class function TJclPpmdDecompressArchive.ArchiveCLSID: TGUID; |
| 8836 |
begin |
| 8837 |
Result := CLSID_CFormatPpmd; |
| 8838 |
end; |
| 8839 |
|
| 8840 |
//=== { TJclTEDecompressArchive } ============================================ |
| 8841 |
|
| 8842 |
class function TJclTEDecompressArchive.ArchiveExtensions: string; |
| 8843 |
begin |
| 8844 |
Result := LoadResString(@RsCompressionTEExtensions); |
| 8845 |
end; |
| 8846 |
|
| 8847 |
class function TJclTEDecompressArchive.ArchiveName: string; |
| 8848 |
begin |
| 8849 |
Result := LoadResString(@RsCompressionTEName); |
| 8850 |
end; |
| 8851 |
|
| 8852 |
class function TJclTEDecompressArchive.ArchiveCLSID: TGUID; |
| 8853 |
begin |
| 8854 |
Result := CLSID_CFormatTE; |
| 8855 |
end; |
| 8856 |
|
| 8857 |
//=== { TJclUEFIcDecompressArchive } ========================================= |
| 8858 |
|
| 8859 |
class function TJclUEFIcDecompressArchive.ArchiveExtensions: string; |
| 8860 |
begin |
| 8861 |
Result := LoadResString(@RsCompressionUEFIcExtensions); |
| 8862 |
end; |
| 8863 |
|
| 8864 |
class function TJclUEFIcDecompressArchive.ArchiveName: string; |
| 8865 |
begin |
| 8866 |
Result := LoadResString(@RsCompressionUEFIcName); |
| 8867 |
end; |
| 8868 |
|
| 8869 |
class function TJclUEFIcDecompressArchive.ArchiveCLSID: TGUID; |
| 8870 |
begin |
| 8871 |
Result := CLSID_CFormatUEFIc; |
| 8872 |
end; |
| 8873 |
|
| 8874 |
//=== { TJclUEFIsDecompressArchive } ========================================= |
| 8875 |
|
| 8876 |
class function TJclUEFIsDecompressArchive.ArchiveExtensions: string; |
| 8877 |
begin |
| 8878 |
Result := LoadResString(@RsCompressionUEFIsExtensions); |
| 8879 |
end; |
| 8880 |
|
| 8881 |
class function TJclUEFIsDecompressArchive.ArchiveName: string; |
| 8882 |
begin |
| 8883 |
Result := LoadResString(@RsCompressionUEFIsName); |
| 8884 |
end; |
| 8885 |
|
| 8886 |
class function TJclUEFIsDecompressArchive.ArchiveCLSID: TGUID; |
| 8887 |
begin |
| 8888 |
Result := CLSID_CFormatUEFIs; |
| 8889 |
end; |
| 8890 |
|
| 8891 |
//=== { TJclSquashFSDecompressArchive } ====================================== |
| 8892 |
|
| 8893 |
class function TJclSquashFSDecompressArchive.ArchiveExtensions: string; |
| 8894 |
begin |
| 8895 |
Result := LoadResString(@RsCompressionSquashFSExtensions); |
| 8896 |
end; |
| 8897 |
|
| 8898 |
class function TJclSquashFSDecompressArchive.ArchiveName: string; |
| 8899 |
begin |
| 8900 |
Result := LoadResString(@RsCompressionSquashFSName); |
| 8901 |
end; |
| 8902 |
|
| 8903 |
class function TJclSquashFSDecompressArchive.ArchiveCLSID: TGUID; |
| 8904 |
begin |
| 8905 |
Result := CLSID_CFormatSquashFS; |
| 8906 |
end; |
| 8907 |
|
| 8908 |
//=== { TJclCramFSDecompressArchive } ======================================== |
| 8909 |
|
| 8910 |
class function TJclCramFSDecompressArchive.ArchiveExtensions: string; |
| 8911 |
begin |
| 8912 |
Result := LoadResString(@RsCompressionCramFSExtensions); |
| 8913 |
end; |
| 8914 |
|
| 8915 |
class function TJclCramFSDecompressArchive.ArchiveName: string; |
| 8916 |
begin |
| 8917 |
Result := LoadResString(@RsCompressionCramFSName); |
| 8918 |
end; |
| 8919 |
|
| 8920 |
class function TJclCramFSDecompressArchive.ArchiveCLSID: TGUID; |
| 8921 |
begin |
| 8922 |
Result := CLSID_CFormatCramFS; |
| 8923 |
end; |
| 8924 |
|
| 8925 |
//=== { TJclSevenzipUpdateArchive } ========================================== |
| 8926 |
|
| 8927 |
class function TJclSevenzipUpdateArchive.ArchiveCLSID: TGUID; |
| 8928 |
begin |
| 8929 |
Result := GUID_NULL; |
| 8930 |
end; |
| 8931 |
|
| 8932 |
destructor TJclSevenzipUpdateArchive.Destroy; |
| 8933 |
begin |
| 8934 |
FInArchive := nil; |
| 8935 |
FOutArchive := nil; |
| 8936 |
inherited Destroy; |
| 8937 |
end; |
| 8938 |
|
| 8939 |
class function TJclSevenzipUpdateArchive.ArchiveSignature: TDynByteArray; |
| 8940 |
begin |
| 8941 |
Result := Get7zArchiveSignature(ArchiveCLSID); |
| 8942 |
end; |
| 8943 |
|
| 8944 |
procedure TJclSevenzipUpdateArchive.Compress; |
| 8945 |
var |
| 8946 |
Value: HRESULT; |
| 8947 |
OutStream: IOutStream; |
| 8948 |
UpdateCallback: IArchiveUpdateCallback; |
| 8949 |
SplitStream: TJclDynamicSplitStream; |
| 8950 |
begin |
| 8951 |
CheckNotCompressing; |
| 8952 |
CheckNotDecompressing; |
| 8953 |
|
| 8954 |
FCompressing := True; |
| 8955 |
try |
| 8956 |
SplitStream := TJclDynamicSplitStream.Create(True); |
| 8957 |
SplitStream.OnVolume := NeedTmpStream; |
| 8958 |
SplitStream.OnVolumeMaxSize := NeedStreamMaxSize; |
| 8959 |
OutStream := TJclSevenzipOutStream.Create(SplitStream, True, True); |
| 8960 |
UpdateCallback := TJclSevenzipUpdateCallback.Create(Self); |
| 8961 |
|
| 8962 |
SetSevenzipArchiveCompressionProperties(Self, OutArchive); |
| 8963 |
|
| 8964 |
Value:= OutArchive.UpdateItems(OutStream, ItemCount, UpdateCallback); |
| 8965 |
|
| 8966 |
if Value <> S_OK then |
| 8967 |
begin |
| 8968 |
FReplaceVolumes:= False; |
| 8969 |
SevenzipCheck(Value); |
| 8970 |
end; |
| 8971 |
finally |
| 8972 |
FCompressing := False; |
| 8973 |
// release reference to volume streams |
| 8974 |
OutStream := nil; |
| 8975 |
// replace streams by tmp streams |
| 8976 |
inherited Compress; |
| 8977 |
end; |
| 8978 |
end; |
| 8979 |
|
| 8980 |
procedure TJclSevenzipUpdateArchive.DeleteItem(Index: Integer); |
| 8981 |
var |
| 8982 |
I, BaseLength: Integer; |
| 8983 |
IsDirectory: Boolean; |
| 8984 |
AItem: TJclCompressionItem; |
| 8985 |
DirectoryName: WideString; |
| 8986 |
begin |
| 8987 |
AItem := Items[Index]; |
| 8988 |
IsDirectory := (AItem.Attributes and faDirectory) <> 0; |
| 8989 |
DirectoryName := AItem.PackedName + DirDelimiter; |
| 8990 |
|
| 8991 |
FItems.Delete(Index); |
| 8992 |
|
| 8993 |
if IsDirectory then |
| 8994 |
begin |
| 8995 |
BaseLength := Length(DirectoryName); |
| 8996 |
|
| 8997 |
for I := ItemCount - 1 downto 0 do |
| 8998 |
if WideSameText(DirectoryName, Copy(Items[I].PackedName, 1, BaseLength)) then |
| 8999 |
FItems.Delete(I); |
| 9000 |
end; |
| 9001 |
end; |
| 9002 |
|
| 9003 |
procedure TJclSevenzipUpdateArchive.ExtractAll(const ADestinationDir: string; |
| 9004 |
AAutoCreateSubDir: Boolean); |
| 9005 |
var |
| 9006 |
AExtractCallback: IArchiveExtractCallback; |
| 9007 |
Indices: array of Cardinal; |
| 9008 |
NbIndices: Cardinal; |
| 9009 |
Index: Integer; |
| 9010 |
begin |
| 9011 |
CheckNotDecompressing; |
| 9012 |
CheckNotCompressing; |
| 9013 |
|
| 9014 |
FDestinationDir := ADestinationDir; |
| 9015 |
FAutoCreateSubDir := AAutoCreateSubDir; |
| 9016 |
|
| 9017 |
if FDestinationDir <> '' then |
| 9018 |
FDestinationDir := PathAddSeparator(FDestinationDir); |
| 9019 |
|
| 9020 |
FDecompressing := True; |
| 9021 |
FExtractingAllIndex := 0; |
| 9022 |
AExtractCallback := TJclSevenzipExtractCallback.Create(Self); |
| 9023 |
try |
| 9024 |
OpenArchive; |
| 9025 |
|
| 9026 |
// seems buggy: first param "indices" is dereferenced without |
| 9027 |
// liveness checks inside Sevenzip code |
| 9028 |
//SevenzipCheck(InArchive.Extract(nil, $FFFFFFFF, 0, AExtractCallback)); |
| 9029 |
|
| 9030 |
NbIndices := ItemCount; |
| 9031 |
SetLength(Indices, NbIndices); |
| 9032 |
for Index := 0 to NbIndices - 1 do |
| 9033 |
begin |
| 9034 |
Items[Index].Selected := True; |
| 9035 |
Indices[Index] := Index; |
| 9036 |
end; |
| 9037 |
SevenzipCheck(InArchive.Extract(@Indices[0], NbIndices, 0, AExtractCallback)); |
| 9038 |
|
| 9039 |
CheckOperationSuccess; |
| 9040 |
finally |
| 9041 |
FDestinationDir := ''; |
| 9042 |
FDecompressing := False; |
| 9043 |
FExtractingAllIndex := -1; |
| 9044 |
FCurrentItemIndex := -1; |
| 9045 |
AExtractCallback := nil; |
| 9046 |
// release volumes and other finalizations |
| 9047 |
inherited ExtractAll(ADestinationDir, AAutoCreateSubDir); |
| 9048 |
end; |
| 9049 |
end; |
| 9050 |
|
| 9051 |
procedure TJclSevenzipUpdateArchive.ExtractSelected( |
| 9052 |
const ADestinationDir: string; AAutoCreateSubDir: Boolean); |
| 9053 |
var |
| 9054 |
AExtractCallback: IArchiveExtractCallback; |
| 9055 |
Indices: array of Cardinal; |
| 9056 |
NbIndices: Cardinal; |
| 9057 |
Index: Integer; |
| 9058 |
begin |
| 9059 |
CheckNotDecompressing; |
| 9060 |
CheckNotCompressing; |
| 9061 |
|
| 9062 |
FDestinationDir := ADestinationDir; |
| 9063 |
FAutoCreateSubDir := AAutoCreateSubDir; |
| 9064 |
|
| 9065 |
if FDestinationDir <> '' then |
| 9066 |
FDestinationDir := PathAddSeparator(FDestinationDir); |
| 9067 |
|
| 9068 |
FDecompressing := True; |
| 9069 |
AExtractCallback := TJclSevenzipExtractCallback.Create(Self); |
| 9070 |
try |
| 9071 |
OpenArchive; |
| 9072 |
|
| 9073 |
NbIndices := 0; |
| 9074 |
for Index := 0 to ItemCount - 1 do |
| 9075 |
if Items[Index].Selected then |
| 9076 |
Inc(NbIndices); |
| 9077 |
|
| 9078 |
SetLength(Indices, NbIndices); |
| 9079 |
NbIndices := 0; |
| 9080 |
for Index := 0 to ItemCount - 1 do |
| 9081 |
if Items[Index].Selected then |
| 9082 |
begin |
| 9083 |
Indices[NbIndices] := Index; |
| 9084 |
Inc(NbIndices); |
| 9085 |
end; |
| 9086 |
|
| 9087 |
SevenzipCheck(InArchive.Extract(@Indices[0], Length(Indices), 0, AExtractCallback)); |
| 9088 |
CheckOperationSuccess; |
| 9089 |
finally |
| 9090 |
FDestinationDir := ''; |
| 9091 |
FDecompressing := False; |
| 9092 |
AExtractCallback := nil; |
| 9093 |
FCurrentItemIndex := -1; |
| 9094 |
// release volumes and other finalizations |
| 9095 |
inherited ExtractSelected(ADestinationDir, AAutoCreateSubDir); |
| 9096 |
end; |
| 9097 |
end; |
| 9098 |
|
| 9099 |
function TJclSevenzipUpdateArchive.GetInArchive: IInArchive; |
| 9100 |
var |
| 9101 |
SevenzipCLSID, InterfaceID: TGUID; |
| 9102 |
begin |
| 9103 |
if not Assigned(FInArchive) then |
| 9104 |
begin |
| 9105 |
SevenzipCLSID := ArchiveCLSID; |
| 9106 |
InterfaceID := Sevenzip.IInArchive; |
| 9107 |
if (not Is7ZipLoaded) and (not Load7Zip) then |
| 9108 |
raise EJclCompressionError.CreateRes(@RsCompression7zLoadError); |
| 9109 |
if (Sevenzip.CreateObject(@SevenzipCLSID, @InterfaceID, FInArchive) <> ERROR_SUCCESS) |
| 9110 |
or not Assigned(FInArchive) then |
| 9111 |
raise EJclCompressionError.CreateResFmt(@RsCompression7zInArchiveError, [GUIDToString(SevenzipCLSID)]); |
| 9112 |
end; |
| 9113 |
Result := FInArchive; |
| 9114 |
end; |
| 9115 |
|
| 9116 |
function TJclSevenzipUpdateArchive.GetItemClass: TJclCompressionItemClass; |
| 9117 |
begin |
| 9118 |
Result := TJclUpdateItem; |
| 9119 |
end; |
| 9120 |
|
| 9121 |
function TJclSevenzipUpdateArchive.GetOutArchive: IOutArchive; |
| 9122 |
var |
| 9123 |
SevenzipCLSID, InterfaceID: TGUID; |
| 9124 |
begin |
| 9125 |
if not Assigned(FOutarchive) then |
| 9126 |
begin |
| 9127 |
SevenzipCLSID := ArchiveCLSID; |
| 9128 |
InterfaceID := Sevenzip.IOutArchive; |
| 9129 |
if not Supports(InArchive, InterfaceID, FOutArchive) |
| 9130 |
or not Assigned(FOutArchive) then |
| 9131 |
raise EJclCompressionError.CreateResFmt(@RsCompression7zOutArchiveError, [GUIDToString(SevenzipCLSID)]); |
| 9132 |
end; |
| 9133 |
Result := FOutArchive; |
| 9134 |
end; |
| 9135 |
|
| 9136 |
procedure TJclSevenzipUpdateArchive.ListFiles; |
| 9137 |
var |
| 9138 |
NumberOfItems: Cardinal; |
| 9139 |
Index: Integer; |
| 9140 |
AItem: TJclCompressionItem; |
| 9141 |
begin |
| 9142 |
CheckNotDecompressing; |
| 9143 |
CheckNotCompressing; |
| 9144 |
|
| 9145 |
FListing := True; |
| 9146 |
try |
| 9147 |
ClearItems; |
| 9148 |
OpenArchive; |
| 9149 |
|
| 9150 |
SevenzipCheck(InArchive.GetNumberOfItems(@NumberOfItems)); |
| 9151 |
if NumberOfItems > 0 then |
| 9152 |
begin |
| 9153 |
for Index := 0 to NumberOfItems - 1 do |
| 9154 |
begin |
| 9155 |
AItem := GetItemClass.Create(Self); |
| 9156 |
Load7zFileAttribute(InArchive, Index, AItem); |
| 9157 |
FItems.Add(AItem); |
| 9158 |
end; |
| 9159 |
end; |
| 9160 |
finally |
| 9161 |
FListing := False; |
| 9162 |
end; |
| 9163 |
end; |
| 9164 |
|
| 9165 |
procedure TJclSevenzipUpdateArchive.OpenArchive; |
| 9166 |
var |
| 9167 |
OpenCallback: IArchiveOpenCallback; |
| 9168 |
MaxCheckStartPosition: Int64; |
| 9169 |
AInStream: IInStream; |
| 9170 |
SplitStream: TJclDynamicSplitStream; |
| 9171 |
begin |
| 9172 |
if not FOpened then |
| 9173 |
begin |
| 9174 |
SplitStream := TJclDynamicSplitStream.Create(True); |
| 9175 |
SplitStream.OnVolume := NeedStream; |
| 9176 |
SplitStream.OnVolumeMaxSize := NeedStreamMaxSize; |
| 9177 |
|
| 9178 |
AInStream := TJclSevenzipInStream.Create(SplitStream, True); |
| 9179 |
OpenCallback := TJclSevenzipOpenCallback.Create(Self); |
| 9180 |
|
| 9181 |
SetSevenzipArchiveCompressionProperties(Self, InArchive); |
| 9182 |
|
| 9183 |
MaxCheckStartPosition := 1 shl 22; |
| 9184 |
SevenzipCheck(InArchive.Open(AInStream, @MaxCheckStartPosition, OpenCallback)); |
| 9185 |
|
| 9186 |
GetSevenzipArchiveCompressionProperties(Self, InArchive); |
| 9187 |
|
| 9188 |
FOpened := True; |
| 9189 |
end; |
| 9190 |
end; |
| 9191 |
|
| 9192 |
procedure TJclSevenzipUpdateArchive.RemoveItem(const PackedName: WideString); |
| 9193 |
var |
| 9194 |
Index, BaseLength, PackedNamesIndex: Integer; |
| 9195 |
IsDirectory: Boolean; |
| 9196 |
AItem: TJclCompressionItem; |
| 9197 |
DirectoryName: WideString; |
| 9198 |
begin |
| 9199 |
IsDirectory := False; |
| 9200 |
for Index := 0 to ItemCount - 1 do |
| 9201 |
begin |
| 9202 |
AItem := Items[Index]; |
| 9203 |
if WideSameText(AItem.PackedName, PackedName) then |
| 9204 |
begin |
| 9205 |
DirectoryName := AItem.PackedName; |
| 9206 |
if (AItem.Attributes and faDirectory) <> 0 then |
| 9207 |
IsDirectory := True; |
| 9208 |
FItems.Delete(Index); |
| 9209 |
PackedNamesIndex := -1; |
| 9210 |
if (FPackedNames <> nil) and FPackedNames.Find(PackedName, PackedNamesIndex) then |
| 9211 |
FPackedNames.Delete(PackedNamesIndex); |
| 9212 |
Break; |
| 9213 |
end; |
| 9214 |
end; |
| 9215 |
|
| 9216 |
if IsDirectory then |
| 9217 |
begin |
| 9218 |
DirectoryName := PackedName + DirDelimiter; |
| 9219 |
BaseLength := Length(DirectoryName); |
| 9220 |
|
| 9221 |
for Index := ItemCount - 1 downto 0 do |
| 9222 |
if WideSameText(DirectoryName, Copy(Items[Index].PackedName, 1, BaseLength)) then |
| 9223 |
begin |
| 9224 |
if (FPackedNames <> nil) and FPackedNames.Find(Items[Index].PackedName, PackedNamesIndex) then |
| 9225 |
FPackedNames.Delete(PackedNamesIndex); |
| 9226 |
FItems.Delete(Index); |
| 9227 |
end; |
| 9228 |
end; |
| 9229 |
end; |
| 9230 |
|
| 9231 |
//=== { TJclZipUpdateArchive } =============================================== |
| 9232 |
|
| 9233 |
class function TJclZipUpdateArchive.ArchiveExtensions: string; |
| 9234 |
begin |
| 9235 |
Result := LoadResString(@RsCompressionZipExtensions); |
| 9236 |
end; |
| 9237 |
|
| 9238 |
class function TJclZipUpdateArchive.ArchiveName: string; |
| 9239 |
begin |
| 9240 |
Result := LoadResString(@RsCompressionZipName); |
| 9241 |
end; |
| 9242 |
|
| 9243 |
class function TJclZipUpdateArchive.ArchiveCLSID: TGUID; |
| 9244 |
begin |
| 9245 |
Result := CLSID_CFormatZip; |
| 9246 |
end; |
| 9247 |
|
| 9248 |
function TJclZipUpdateArchive.GetAlgorithm: Cardinal; |
| 9249 |
begin |
| 9250 |
Result := FAlgorithm; |
| 9251 |
end; |
| 9252 |
|
| 9253 |
function TJclZipUpdateArchive.GetCompressionLevel: Cardinal; |
| 9254 |
begin |
| 9255 |
Result := FCompressionLevel; |
| 9256 |
end; |
| 9257 |
|
| 9258 |
function TJclZipUpdateArchive.GetCompressionLevelMax: Cardinal; |
| 9259 |
begin |
| 9260 |
Result := 9; |
| 9261 |
end; |
| 9262 |
|
| 9263 |
function TJclZipUpdateArchive.GetCompressionLevelMin: Cardinal; |
| 9264 |
begin |
| 9265 |
Result := 0; |
| 9266 |
end; |
| 9267 |
|
| 9268 |
function TJclZipUpdateArchive.GetCompressionMethod: TJclCompressionMethod; |
| 9269 |
begin |
| 9270 |
Result := FCompressionMethod; |
| 9271 |
end; |
| 9272 |
|
| 9273 |
function TJclZipUpdateArchive.GetDictionarySize: Cardinal; |
| 9274 |
begin |
| 9275 |
Result := FDictionarySize; |
| 9276 |
end; |
| 9277 |
|
| 9278 |
function TJclZipUpdateArchive.GetEncryptionMethod: TJclEncryptionMethod; |
| 9279 |
begin |
| 9280 |
Result := FEncryptionMethod; |
| 9281 |
end; |
| 9282 |
|
| 9283 |
function TJclZipUpdateArchive.GetNumberOfPasses: Cardinal; |
| 9284 |
begin |
| 9285 |
Result := FNumberOfPasses; |
| 9286 |
end; |
| 9287 |
|
| 9288 |
function TJclZipUpdateArchive.GetNumberOfThreads: Cardinal; |
| 9289 |
begin |
| 9290 |
Result := FNumberOfThreads; |
| 9291 |
end; |
| 9292 |
|
| 9293 |
function TJclZipUpdateArchive.GetSupportedAlgorithms: TDynCardinalArray; |
| 9294 |
begin |
| 9295 |
SetLength(Result,2); |
| 9296 |
Result[0] := 0; |
| 9297 |
Result[1] := 1; |
| 9298 |
end; |
| 9299 |
|
| 9300 |
function TJclZipUpdateArchive.GetSupportedCompressionMethods: TJclCompressionMethods; |
| 9301 |
begin |
| 9302 |
Result := [cmCopy,cmDeflate,cmDeflate64,cmBZip2,cmLZMA]; |
| 9303 |
end; |
| 9304 |
|
| 9305 |
function TJclZipUpdateArchive.GetSupportedEncryptionMethods: TJclEncryptionMethods; |
| 9306 |
begin |
| 9307 |
Result := [emNone,emAES128,emAES192,emAES256,emZipCrypto]; |
| 9308 |
end; |
| 9309 |
|
| 9310 |
procedure TJclZipUpdateArchive.InitializeArchiveProperties; |
| 9311 |
begin |
| 9312 |
inherited InitializeArchiveProperties; |
| 9313 |
FNumberOfThreads := 1; |
| 9314 |
FEncryptionMethod := emZipCrypto; |
| 9315 |
FDictionarySize := kBZip2DicSizeX5; |
| 9316 |
FCompressionLevel := 7; |
| 9317 |
FCompressionMethod := cmDeflate; |
| 9318 |
FNumberOfPasses := kDeflateNumPassesX7; |
| 9319 |
FAlgorithm := kLzAlgoX5; |
| 9320 |
end; |
| 9321 |
|
| 9322 |
class function TJclZipUpdateArchive.MultipleItemContainer: Boolean; |
| 9323 |
begin |
| 9324 |
Result := True; |
| 9325 |
end; |
| 9326 |
|
| 9327 |
procedure TJclZipUpdateArchive.SetAlgorithm(Value: Cardinal); |
| 9328 |
begin |
| 9329 |
CheckNotCompressing; |
| 9330 |
CheckNotDecompressing; |
| 9331 |
if (Value = 0) or (Value = 1) then |
| 9332 |
FAlgorithm := Value |
| 9333 |
else |
| 9334 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty); |
| 9335 |
end; |
| 9336 |
|
| 9337 |
procedure TJclZipUpdateArchive.SetCompressionLevel(Value: Cardinal); |
| 9338 |
begin |
| 9339 |
CheckNotCompressing; |
| 9340 |
CheckNotDecompressing; |
| 9341 |
if Value <= 9 then |
| 9342 |
begin |
| 9343 |
FCompressionLevel := Value; |
| 9344 |
case FCompressionMethod of |
| 9345 |
cmDeflate, cmDeflate64: |
| 9346 |
begin |
| 9347 |
if Value >= 9 then |
| 9348 |
FNumberOfPasses := kDeflateNumPassesX9 |
| 9349 |
else |
| 9350 |
if Value >= 7 then |
| 9351 |
FNumberOfPasses := kDeflateNumPassesX7 |
| 9352 |
else |
| 9353 |
FNumberOfPasses := kDeflateNumPassesX1; |
| 9354 |
if Value >= 5 then |
| 9355 |
FAlgorithm := kLzAlgoX5 |
| 9356 |
else |
| 9357 |
FAlgorithm := kLzAlgoX1; |
| 9358 |
end; |
| 9359 |
cmBZip2: |
| 9360 |
begin |
| 9361 |
if Value >= 9 then |
| 9362 |
FNumberOfPasses := kBZip2NumPassesX9 |
| 9363 |
else |
| 9364 |
if Value >= 7 then |
| 9365 |
FNumberOfPasses := kBZip2NumPassesX7 |
| 9366 |
else |
| 9367 |
FNumberOfPasses := kBZip2NumPassesX1; |
| 9368 |
if Value >= 5 then |
| 9369 |
FDictionarySize := kBZip2DicSizeX5 |
| 9370 |
else |
| 9371 |
if Value >= 3 then |
| 9372 |
FDictionarySize := kBZip2DicSizeX3 |
| 9373 |
else |
| 9374 |
FDictionarySize := kBZip2DicSizeX1; |
| 9375 |
end; |
| 9376 |
cmLZMA: |
| 9377 |
begin |
| 9378 |
if Value >= 9 then |
| 9379 |
FDictionarySize := kLzmaDicSizeX9 |
| 9380 |
else |
| 9381 |
if Value >= 7 then |
| 9382 |
FDictionarySize := kLzmaDicSizeX7 |
| 9383 |
else |
| 9384 |
if Value >= 5 then |
| 9385 |
FDictionarySize := kLzmaDicSizeX5 |
| 9386 |
else |
| 9387 |
if Value >= 3 then |
| 9388 |
FDictionarySize := kLzmaDicSizeX3 |
| 9389 |
else |
| 9390 |
FDictionarySize := kLzmaDicSizeX1; |
| 9391 |
if Value >= 5 then |
| 9392 |
FAlgorithm := kLzAlgoX5 |
| 9393 |
else |
| 9394 |
FAlgorithm := kLzAlgoX1; |
| 9395 |
end; |
| 9396 |
end; |
| 9397 |
end |
| 9398 |
else |
| 9399 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty); |
| 9400 |
end; |
| 9401 |
|
| 9402 |
procedure TJclZipUpdateArchive.SetCompressionMethod(Value: TJclCompressionMethod); |
| 9403 |
begin |
| 9404 |
CheckNotCompressing; |
| 9405 |
CheckNotDecompressing; |
| 9406 |
if Value in GetSupportedCompressionMethods then |
| 9407 |
FCompressionMethod := Value |
| 9408 |
else |
| 9409 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty); |
| 9410 |
end; |
| 9411 |
|
| 9412 |
procedure TJclZipUpdateArchive.SetDictionarySize(Value: Cardinal); |
| 9413 |
begin |
| 9414 |
CheckNotCompressing; |
| 9415 |
CheckNotDecompressing; |
| 9416 |
FDictionarySize := Value; |
| 9417 |
end; |
| 9418 |
|
| 9419 |
procedure TJclZipUpdateArchive.SetEncryptionMethod(Value: TJclEncryptionMethod); |
| 9420 |
begin |
| 9421 |
CheckNotCompressing; |
| 9422 |
CheckNotDecompressing; |
| 9423 |
if Value in GetSupportedEncryptionMethods then |
| 9424 |
FEncryptionMethod := Value |
| 9425 |
else |
| 9426 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty); |
| 9427 |
end; |
| 9428 |
|
| 9429 |
procedure TJclZipUpdateArchive.SetNumberOfPasses(Value: Cardinal); |
| 9430 |
begin |
| 9431 |
CheckNotCompressing; |
| 9432 |
CheckNotDecompressing; |
| 9433 |
FNumberOfPasses := Value; |
| 9434 |
end; |
| 9435 |
|
| 9436 |
procedure TJclZipUpdateArchive.SetNumberOfThreads(Value: Cardinal); |
| 9437 |
begin |
| 9438 |
CheckNotCompressing; |
| 9439 |
CheckNotDecompressing; |
| 9440 |
FNumberOfThreads := Value; |
| 9441 |
end; |
| 9442 |
|
| 9443 |
//=== { TJclBZ2UpdateArchive } =============================================== |
| 9444 |
|
| 9445 |
class function TJclBZ2UpdateArchive.ArchiveExtensions: string; |
| 9446 |
begin |
| 9447 |
Result := LoadResString(@RsCompressionBZip2Extensions); |
| 9448 |
end; |
| 9449 |
|
| 9450 |
class function TJclBZ2UpdateArchive.ArchiveName: string; |
| 9451 |
begin |
| 9452 |
Result := LoadResString(@RsCompressionBZip2Name); |
| 9453 |
end; |
| 9454 |
|
| 9455 |
class function TJclBZ2UpdateArchive.ArchiveSubExtensions: string; |
| 9456 |
begin |
| 9457 |
Result := LoadResString(@RsCompressionBZip2SubExtensions); |
| 9458 |
end; |
| 9459 |
|
| 9460 |
class function TJclBZ2UpdateArchive.ArchiveCLSID: TGUID; |
| 9461 |
begin |
| 9462 |
Result := CLSID_CFormatBZ2; |
| 9463 |
end; |
| 9464 |
|
| 9465 |
function TJclBZ2UpdateArchive.GetCompressionLevel: Cardinal; |
| 9466 |
begin |
| 9467 |
Result := FCompressionLevel; |
| 9468 |
end; |
| 9469 |
|
| 9470 |
function TJclBZ2UpdateArchive.GetCompressionLevelMax: Cardinal; |
| 9471 |
begin |
| 9472 |
Result := 9; |
| 9473 |
end; |
| 9474 |
|
| 9475 |
function TJclBZ2UpdateArchive.GetCompressionLevelMin: Cardinal; |
| 9476 |
begin |
| 9477 |
Result := 0; |
| 9478 |
end; |
| 9479 |
|
| 9480 |
function TJclBZ2UpdateArchive.GetDictionarySize: Cardinal; |
| 9481 |
begin |
| 9482 |
Result := FDictionarySize; |
| 9483 |
end; |
| 9484 |
|
| 9485 |
function TJclBZ2UpdateArchive.GetNumberOfPasses: Cardinal; |
| 9486 |
begin |
| 9487 |
Result := FNumberOfPasses; |
| 9488 |
end; |
| 9489 |
|
| 9490 |
function TJclBZ2UpdateArchive.GetNumberOfThreads: Cardinal; |
| 9491 |
begin |
| 9492 |
Result := FNumberOfThreads; |
| 9493 |
end; |
| 9494 |
|
| 9495 |
procedure TJclBZ2UpdateArchive.InitializeArchiveProperties; |
| 9496 |
begin |
| 9497 |
inherited InitializeArchiveProperties; |
| 9498 |
FNumberOfThreads := 1; |
| 9499 |
FDictionarySize := kBZip2DicSizeX5; |
| 9500 |
FCompressionLevel := 7; |
| 9501 |
FNumberOfPasses := kBZip2NumPassesX7; |
| 9502 |
end; |
| 9503 |
|
| 9504 |
procedure TJclBZ2UpdateArchive.SetCompressionLevel(Value: Cardinal); |
| 9505 |
begin |
| 9506 |
CheckNotCompressing; |
| 9507 |
CheckNotDecompressing; |
| 9508 |
if Value <= 9 then |
| 9509 |
begin |
| 9510 |
FCompressionLevel := Value; |
| 9511 |
if Value >= 9 then |
| 9512 |
FNumberOfPasses := kBZip2NumPassesX9 |
| 9513 |
else |
| 9514 |
if Value >= 7 then |
| 9515 |
FNumberOfPasses := kBZip2NumPassesX7 |
| 9516 |
else |
| 9517 |
FNumberOfPasses := kBZip2NumPassesX1; |
| 9518 |
if Value >= 5 then |
| 9519 |
FDictionarySize := kBZip2DicSizeX5 |
| 9520 |
else |
| 9521 |
if Value >= 3 then |
| 9522 |
FDictionarySize := kBZip2DicSizeX3 |
| 9523 |
else |
| 9524 |
FDictionarySize := kBZip2DicSizeX1; |
| 9525 |
end |
| 9526 |
else |
| 9527 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty); |
| 9528 |
end; |
| 9529 |
|
| 9530 |
procedure TJclBZ2UpdateArchive.SetDictionarySize(Value: Cardinal); |
| 9531 |
begin |
| 9532 |
CheckNotCompressing; |
| 9533 |
CheckNotDecompressing; |
| 9534 |
FDictionarySize := Value; |
| 9535 |
end; |
| 9536 |
|
| 9537 |
procedure TJclBZ2UpdateArchive.SetNumberOfPasses(Value: Cardinal); |
| 9538 |
begin |
| 9539 |
CheckNotCompressing; |
| 9540 |
CheckNotDecompressing; |
| 9541 |
FNumberOfPasses := Value; |
| 9542 |
end; |
| 9543 |
|
| 9544 |
procedure TJclBZ2UpdateArchive.SetNumberOfThreads(Value: Cardinal); |
| 9545 |
begin |
| 9546 |
CheckNotCompressing; |
| 9547 |
CheckNotDecompressing; |
| 9548 |
FNumberOfThreads := Value; |
| 9549 |
end; |
| 9550 |
|
| 9551 |
//=== { TJcl7zUpdateArchive } ================================================ |
| 9552 |
|
| 9553 |
class function TJcl7zUpdateArchive.ArchiveExtensions: string; |
| 9554 |
begin |
| 9555 |
Result := LoadResString(@RsCompression7zExtensions); |
| 9556 |
end; |
| 9557 |
|
| 9558 |
class function TJcl7zUpdateArchive.ArchiveName: string; |
| 9559 |
begin |
| 9560 |
Result := LoadResString(@RsCompression7zName); |
| 9561 |
end; |
| 9562 |
|
| 9563 |
class function TJcl7zUpdateArchive.ArchiveCLSID: TGUID; |
| 9564 |
begin |
| 9565 |
Result := CLSID_CFormat7z; |
| 9566 |
end; |
| 9567 |
|
| 9568 |
function TJcl7zUpdateArchive.GetCompressHeader: Boolean; |
| 9569 |
begin |
| 9570 |
Result := FCompressHeader; |
| 9571 |
end; |
| 9572 |
|
| 9573 |
function TJcl7zUpdateArchive.GetCompressHeaderFull: Boolean; |
| 9574 |
begin |
| 9575 |
Result := FCompressHeaderFull; |
| 9576 |
end; |
| 9577 |
|
| 9578 |
function TJcl7zUpdateArchive.GetCompressionLevel: Cardinal; |
| 9579 |
begin |
| 9580 |
Result := FCompressionLevel; |
| 9581 |
end; |
| 9582 |
|
| 9583 |
function TJcl7zUpdateArchive.GetCompressionLevelMax: Cardinal; |
| 9584 |
begin |
| 9585 |
Result := 9; |
| 9586 |
end; |
| 9587 |
|
| 9588 |
function TJcl7zUpdateArchive.GetCompressionLevelMin: Cardinal; |
| 9589 |
begin |
| 9590 |
Result := 0; |
| 9591 |
end; |
| 9592 |
|
| 9593 |
function TJcl7zUpdateArchive.GetDictionarySize: Cardinal; |
| 9594 |
begin |
| 9595 |
Result := FDictionarySize; |
| 9596 |
end; |
| 9597 |
|
| 9598 |
function TJcl7zUpdateArchive.GetEncryptHeader: Boolean; |
| 9599 |
begin |
| 9600 |
Result := FEncryptHeader; |
| 9601 |
end; |
| 9602 |
|
| 9603 |
function TJcl7zUpdateArchive.GetNumberOfThreads: Cardinal; |
| 9604 |
begin |
| 9605 |
Result := FNumberOfThreads; |
| 9606 |
end; |
| 9607 |
|
| 9608 |
function TJcl7zUpdateArchive.GetRemoveSfxBlock: Boolean; |
| 9609 |
begin |
| 9610 |
Result := FRemoveSfxBlock; |
| 9611 |
end; |
| 9612 |
|
| 9613 |
function TJcl7zUpdateArchive.GetSaveCreationDateTime: Boolean; |
| 9614 |
begin |
| 9615 |
Result := FSaveCreationDateTime; |
| 9616 |
end; |
| 9617 |
|
| 9618 |
function TJcl7zUpdateArchive.GetSaveLastAccessDateTime: Boolean; |
| 9619 |
begin |
| 9620 |
Result := FSaveLastAccessDateTime; |
| 9621 |
end; |
| 9622 |
|
| 9623 |
function TJcl7zUpdateArchive.GetSaveLastWriteDateTime: Boolean; |
| 9624 |
begin |
| 9625 |
Result := FSaveLastWriteDateTime; |
| 9626 |
end; |
| 9627 |
|
| 9628 |
procedure TJcl7zUpdateArchive.InitializeArchiveProperties; |
| 9629 |
begin |
| 9630 |
inherited InitializeArchiveProperties; |
| 9631 |
FNumberOfThreads := 1; |
| 9632 |
FEncryptHeader := False; |
| 9633 |
FRemoveSfxBlock := False; |
| 9634 |
FDictionarySize := kLzmaDicSizeX5; |
| 9635 |
FCompressionLevel := 6; |
| 9636 |
FCompressHeader := False; |
| 9637 |
FCompressHeaderFull := False; |
| 9638 |
FSaveLastAccessDateTime := True; |
| 9639 |
FSaveCreationDateTime := True; |
| 9640 |
FSaveLastWriteDateTime := True; |
| 9641 |
end; |
| 9642 |
|
| 9643 |
class function TJcl7zUpdateArchive.MultipleItemContainer: Boolean; |
| 9644 |
begin |
| 9645 |
Result := True; |
| 9646 |
end; |
| 9647 |
|
| 9648 |
procedure TJcl7zUpdateArchive.SetCompressHeader(Value: Boolean); |
| 9649 |
begin |
| 9650 |
CheckNotCompressing; |
| 9651 |
CheckNotDecompressing; |
| 9652 |
FCompressHeader := Value; |
| 9653 |
end; |
| 9654 |
|
| 9655 |
procedure TJcl7zUpdateArchive.SetCompressHeaderFull(Value: Boolean); |
| 9656 |
begin |
| 9657 |
CheckNotCompressing; |
| 9658 |
CheckNotDecompressing; |
| 9659 |
FCompressHeaderFull := Value; |
| 9660 |
end; |
| 9661 |
|
| 9662 |
procedure TJcl7zUpdateArchive.SetCompressionLevel(Value: Cardinal); |
| 9663 |
begin |
| 9664 |
CheckNotCompressing; |
| 9665 |
CheckNotDecompressing; |
| 9666 |
if Value <= 9 then |
| 9667 |
begin |
| 9668 |
FCompressionLevel := Value; |
| 9669 |
if Value >= 9 then |
| 9670 |
FDictionarySize := kLzmaDicSizeX9 |
| 9671 |
else |
| 9672 |
if Value >= 7 then |
| 9673 |
FDictionarySize := kLzmaDicSizeX7 |
| 9674 |
else |
| 9675 |
if Value >= 5 then |
| 9676 |
FDictionarySize := kLzmaDicSizeX5 |
| 9677 |
else |
| 9678 |
if Value >= 3 then |
| 9679 |
FDictionarySize := kLzmaDicSizeX3 |
| 9680 |
else |
| 9681 |
FDictionarySize := kLzmaDicSizeX1; |
| 9682 |
end |
| 9683 |
else |
| 9684 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty); |
| 9685 |
end; |
| 9686 |
|
| 9687 |
procedure TJcl7zUpdateArchive.SetDictionarySize(Value: Cardinal); |
| 9688 |
begin |
| 9689 |
CheckNotCompressing; |
| 9690 |
CheckNotDecompressing; |
| 9691 |
FDictionarySize := Value; |
| 9692 |
end; |
| 9693 |
|
| 9694 |
procedure TJcl7zUpdateArchive.SetEncryptHeader(Value: Boolean); |
| 9695 |
begin |
| 9696 |
CheckNotCompressing; |
| 9697 |
CheckNotDecompressing; |
| 9698 |
FEncryptHeader := Value; |
| 9699 |
end; |
| 9700 |
|
| 9701 |
procedure TJcl7zUpdateArchive.SetNumberOfThreads(Value: Cardinal); |
| 9702 |
begin |
| 9703 |
CheckNotCompressing; |
| 9704 |
CheckNotDecompressing; |
| 9705 |
FNumberOfThreads := Value; |
| 9706 |
end; |
| 9707 |
|
| 9708 |
procedure TJcl7zUpdateArchive.SetRemoveSfxBlock(Value: Boolean); |
| 9709 |
begin |
| 9710 |
CheckNotCompressing; |
| 9711 |
CheckNotDecompressing; |
| 9712 |
FRemoveSfxBlock := Value; |
| 9713 |
end; |
| 9714 |
|
| 9715 |
procedure TJcl7zUpdateArchive.SetSaveCreationDateTime(Value: Boolean); |
| 9716 |
begin |
| 9717 |
CheckNotCompressing; |
| 9718 |
CheckNotDecompressing; |
| 9719 |
FSaveCreationDateTime := Value; |
| 9720 |
end; |
| 9721 |
|
| 9722 |
procedure TJcl7zUpdateArchive.SetSaveLastAccessDateTime(Value: Boolean); |
| 9723 |
begin |
| 9724 |
CheckNotCompressing; |
| 9725 |
CheckNotDecompressing; |
| 9726 |
FSaveLastAccessDateTime := Value; |
| 9727 |
end; |
| 9728 |
|
| 9729 |
procedure TJcl7zUpdateArchive.SetSaveLastWriteDateTime(Value: Boolean); |
| 9730 |
begin |
| 9731 |
CheckNotCompressing; |
| 9732 |
CheckNotDecompressing; |
| 9733 |
FSaveLastWriteDateTime := Value; |
| 9734 |
end; |
| 9735 |
|
| 9736 |
//=== { TJclTarUpdateArchive } =============================================== |
| 9737 |
|
| 9738 |
class function TJclTarUpdateArchive.ArchiveExtensions: string; |
| 9739 |
begin |
| 9740 |
Result := LoadResString(@RsCompressionTarExtensions); |
| 9741 |
end; |
| 9742 |
|
| 9743 |
class function TJclTarUpdateArchive.ArchiveName: string; |
| 9744 |
begin |
| 9745 |
Result := LoadResString(@RsCompressionTarName); |
| 9746 |
end; |
| 9747 |
|
| 9748 |
class function TJclTarUpdateArchive.ArchiveCLSID: TGUID; |
| 9749 |
begin |
| 9750 |
Result := CLSID_CFormatTar; |
| 9751 |
end; |
| 9752 |
|
| 9753 |
class function TJclTarUpdateArchive.MultipleItemContainer: Boolean; |
| 9754 |
begin |
| 9755 |
Result := True; |
| 9756 |
end; |
| 9757 |
|
| 9758 |
//=== { TJclGZipUpdateArchive } ============================================== |
| 9759 |
|
| 9760 |
class function TJclGZipUpdateArchive.ArchiveExtensions: string; |
| 9761 |
begin |
| 9762 |
Result := LoadResString(@RsCompressionGZipExtensions); |
| 9763 |
end; |
| 9764 |
|
| 9765 |
class function TJclGZipUpdateArchive.ArchiveName: string; |
| 9766 |
begin |
| 9767 |
Result := LoadResString(@RsCompressionGZipName); |
| 9768 |
end; |
| 9769 |
|
| 9770 |
class function TJclGZipUpdateArchive.ArchiveSubExtensions: string; |
| 9771 |
begin |
| 9772 |
Result := LoadResString(@RsCompressionGZipSubExtensions); |
| 9773 |
end; |
| 9774 |
|
| 9775 |
class function TJclGZipUpdateArchive.ArchiveCLSID: TGUID; |
| 9776 |
begin |
| 9777 |
Result := CLSID_CFormatGZip; |
| 9778 |
end; |
| 9779 |
|
| 9780 |
function TJclGZipUpdateArchive.GetAlgorithm: Cardinal; |
| 9781 |
begin |
| 9782 |
Result := FAlgorithm; |
| 9783 |
end; |
| 9784 |
|
| 9785 |
function TJclGZipUpdateArchive.GetCompressionLevel: Cardinal; |
| 9786 |
begin |
| 9787 |
Result := FCompressionLevel; |
| 9788 |
end; |
| 9789 |
|
| 9790 |
function TJclGZipUpdateArchive.GetCompressionLevelMax: Cardinal; |
| 9791 |
begin |
| 9792 |
Result := 9; |
| 9793 |
end; |
| 9794 |
|
| 9795 |
function TJclGZipUpdateArchive.GetCompressionLevelMin: Cardinal; |
| 9796 |
begin |
| 9797 |
Result := 0; |
| 9798 |
end; |
| 9799 |
|
| 9800 |
function TJclGZipUpdateArchive.GetNumberOfPasses: Cardinal; |
| 9801 |
begin |
| 9802 |
Result := FNumberOfPasses; |
| 9803 |
end; |
| 9804 |
|
| 9805 |
function TJclGZipUpdateArchive.GetSupportedAlgorithms: TDynCardinalArray; |
| 9806 |
begin |
| 9807 |
SetLength(Result,2); |
| 9808 |
Result[0] := 0; |
| 9809 |
Result[1] := 1; |
| 9810 |
end; |
| 9811 |
|
| 9812 |
procedure TJclGZipUpdateArchive.InitializeArchiveProperties; |
| 9813 |
begin |
| 9814 |
inherited InitializeArchiveProperties; |
| 9815 |
FCompressionLevel := 7; |
| 9816 |
FNumberOfPasses := kDeflateNumPassesX7; |
| 9817 |
FAlgorithm := kLzAlgoX5; |
| 9818 |
end; |
| 9819 |
|
| 9820 |
procedure TJclGZipUpdateArchive.SetAlgorithm(Value: Cardinal); |
| 9821 |
begin |
| 9822 |
CheckNotCompressing; |
| 9823 |
CheckNotDecompressing; |
| 9824 |
FAlgorithm := Value; |
| 9825 |
end; |
| 9826 |
|
| 9827 |
procedure TJclGZipUpdateArchive.SetCompressionLevel(Value: Cardinal); |
| 9828 |
begin |
| 9829 |
CheckNotCompressing; |
| 9830 |
CheckNotDecompressing; |
| 9831 |
if Value <= 9 then |
| 9832 |
begin |
| 9833 |
if Value >= 9 then |
| 9834 |
FNumberOfPasses := kDeflateNumPassesX9 |
| 9835 |
else |
| 9836 |
if Value >= 7 then |
| 9837 |
FNumberOfPasses := kDeflateNumPassesX7 |
| 9838 |
else |
| 9839 |
FNumberOfPasses := kDeflateNumPassesX1; |
| 9840 |
if Value >= 5 then |
| 9841 |
FAlgorithm := kLzAlgoX5 |
| 9842 |
else |
| 9843 |
FAlgorithm := kLzAlgoX1; |
| 9844 |
end |
| 9845 |
else |
| 9846 |
raise EJclCompressionError.CreateRes(@RsCompressionUnavailableProperty); |
| 9847 |
end; |
| 9848 |
|
| 9849 |
procedure TJclGZipUpdateArchive.SetNumberOfPasses(Value: Cardinal); |
| 9850 |
begin |
| 9851 |
CheckNotCompressing; |
| 9852 |
CheckNotDecompressing; |
| 9853 |
FNumberOfPasses := Value; |
| 9854 |
end; |
| 9855 |
|
| 9856 |
//=== { TJclXzUpdateArchive } ================================================ |
| 9857 |
|
| 9858 |
class function TJclXzUpdateArchive.ArchiveExtensions: string; |
| 9859 |
begin |
| 9860 |
Result := LoadResString(@RsCompressionXzExtensions); |
| 9861 |
end; |
| 9862 |
|
| 9863 |
class function TJclXzUpdateArchive.ArchiveName: string; |
| 9864 |
begin |
| 9865 |
Result := LoadResString(@RsCompressionXzExtensions); |
| 9866 |
end; |
| 9867 |
|
| 9868 |
class function TJclXzUpdateArchive.ArchiveSubExtensions: string; |
| 9869 |
begin |
| 9870 |
Result := LoadResString(@RsCompressionXzSubExtensions); |
| 9871 |
end; |
| 9872 |
|
| 9873 |
class function TJclXzUpdateArchive.ArchiveCLSID: TGUID; |
| 9874 |
begin |
| 9875 |
Result := CLSID_CFormatXz; |
| 9876 |
end; |
| 9877 |
|
| 9878 |
function TJclXzUpdateArchive.GetCompressionMethod: TJclCompressionMethod; |
| 9879 |
begin |
| 9880 |
Result := FCompressionMethod; |
| 9881 |
end; |
| 9882 |
|
| 9883 |
function TJclXzUpdateArchive.GetSupportedCompressionMethods: TJclCompressionMethods; |
| 9884 |
begin |
| 9885 |
Result := [cmLZMA2]; |
| 9886 |
end; |
| 9887 |
|
| 9888 |
procedure TJclXzUpdateArchive.InitializeArchiveProperties; |
| 9889 |
begin |
| 9890 |
inherited InitializeArchiveProperties; |
| 9891 |
FCompressionMethod := cmLZMA2 |
| 9892 |
end; |
| 9893 |
|
| 9894 |
procedure TJclXzUpdateArchive.SetCompressionMethod( |
| 9895 |
Value: TJclCompressionMethod); |
| 9896 |
begin |
| 9897 |
CheckNotDecompressing; |
| 9898 |
CheckNotCompressing; |
| 9899 |
FCompressionMethod := Value; |
| 9900 |
end; |
| 9901 |
|
| 9902 |
//=== { TJclSwfcUpdateArchive } ============================================== |
| 9903 |
|
| 9904 |
class function TJclSwfcUpdateArchive.ArchiveExtensions: string; |
| 9905 |
begin |
| 9906 |
Result := LoadResString(@RsCompressionSwfcExtensions); |
| 9907 |
end; |
| 9908 |
|
| 9909 |
class function TJclSwfcUpdateArchive.ArchiveName: string; |
| 9910 |
begin |
| 9911 |
Result := LoadResString(@RsCompressionSwfcName); |
| 9912 |
end; |
| 9913 |
|
| 9914 |
class function TJclSwfcUpdateArchive.ArchiveCLSID: TGUID; |
| 9915 |
begin |
| 9916 |
Result := CLSID_CFormatSwfc; |
| 9917 |
end; |
| 9918 |
|
| 9919 |
{$ENDIF MSWINDOWS} |
| 9920 |
|
| 9921 |
initialization |
| 9922 |
{$IFDEF UNITVERSIONING} |
| 9923 |
RegisterUnitVersion(HInstance, UnitVersioning); |
| 9924 |
{$ENDIF UNITVERSIONING} |
| 9925 |
|
| 9926 |
finalization |
| 9927 |
{$IFDEF UNITVERSIONING} |
| 9928 |
UnregisterUnitVersion(HInstance); |
| 9929 |
{$ENDIF UNITVERSIONING} |
| 9930 |
|
| 9931 |
FreeAndNil(GlobalStreamFormats); |
| 9932 |
FreeAndNil(GlobalArchiveFormats); |
| 9933 |
|
| 9934 |
end. |
| 9935 |
|