Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | daniel-mar | 1 | unit ZipMstr19; |
2 | |||
3 | (* |
||
4 | ZipMstr19.pas - main component |
||
5 | TZipMaster19 VCL by Chris Vleghert and Eric W. Engler |
||
6 | v1.9 |
||
7 | Copyright (C) 2009, 2010 Russell Peters |
||
8 | |||
9 | |||
10 | This library is free software; you can redistribute it and/or |
||
11 | modify it under the terms of the GNU Lesser General Public |
||
12 | License as published by the Free Software Foundation; either |
||
13 | version 2.1 of the License, or (at your option) any later version. |
||
14 | |||
15 | This library is distributed in the hope that it will be useful, |
||
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||
18 | Lesser General Public License (licence.txt) for more details. |
||
19 | |||
20 | You should have received a copy of the GNU Lesser General Public License |
||
21 | along with this library; if not, write to the Free Software Foundation, Inc., |
||
22 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
||
23 | |||
24 | contact: problems AT delphizip DOT org |
||
25 | updates: http://www.delphizip.org |
||
26 | |||
27 | modified 2010-08-06 |
||
28 | ---------------------------------------------------------------------------*) |
||
29 | {$I '.\ZipVers19.inc'} |
||
30 | {$I '.\ZMConfig19.inc'} |
||
31 | |||
32 | interface |
||
33 | |||
34 | uses |
||
35 | Classes, SysUtils, Graphics, Dialogs, Windows, Controls, |
||
36 | ZMXcpt19, ZMStructs19; |
||
37 | |||
38 | const |
||
39 | ZIPMASTERBUILD: String = '1.9.0.0102'; |
||
40 | ZIPMASTERDATE: String = '11/09/2010'; |
||
41 | ZIPMASTERPRIV: Integer = 1900102; |
||
42 | DELZIPVERSION = 190; |
||
43 | |||
44 | const |
||
45 | ZMReentry_Error: Integer = $4000000; |
||
46 | |||
47 | const |
||
48 | ZMPWLEN = 80; |
||
49 | |||
50 | type |
||
51 | {$IFDEF UNICODE} |
||
52 | TZMString = String; // unicode |
||
53 | TZMWideString = String; |
||
54 | TZMRawBytes = RawByteString; |
||
55 | {$ELSE} |
||
56 | {$IFNDEF VERD6up} |
||
57 | UTF8String = type String; |
||
58 | {$ENDIF} |
||
59 | TZMString = AnsiString; // Ansi/UTF8 depending upon UseUTF8 |
||
60 | TZMWideString = WideString; |
||
61 | TZMRawBytes = AnsiString; |
||
62 | {$ENDIF} |
||
63 | |||
64 | type |
||
65 | TZMStates = (zsDisabled, zsIdle, zsBusy); |
||
66 | |||
67 | // options when editing a zip |
||
68 | TZMAddOptsEnum = (AddDirNames, AddRecurseDirs, AddMove, AddFreshen, AddUpdate, |
||
69 | AddHiddenFiles, AddArchiveOnly, AddResetArchive, AddEncrypt, AddEmptyDirs, |
||
70 | // AddNoSeparateDirs, renamed and inverted - was AddSeparateDirs |
||
71 | AddVolume, AddFromDate, AddSafe, AddVersion, AddNTFS); |
||
72 | TZMAddOpts = set of TZMAddOptsEnum; |
||
73 | |||
74 | //the EncodeAs values (writing) - |
||
75 | // zeoUPATH - convert to Ansi but have UTF8 proper name in data |
||
76 | // zeoUTF - convert to UTF8 |
||
77 | // zeoOEM - convert to OEM |
||
78 | // zeoNone - store 'as is' (Ansi on Windows) |
||
79 | // 'default' (zeoAuto) - [in order of preference] |
||
80 | // is Ansi - use zeoNone |
||
81 | // can be converted to Ansi - use zeoUPath (unless comment also extended) |
||
82 | // use zeoUTF8 |
||
83 | |||
84 | //Encoded (reading) |
||
85 | // zeoUPATH- use UPATH if available |
||
86 | // zeoUTF - assume name is UTF8 - convert to Ansi/Unicode |
||
87 | // zeoOEM - assume name is OEM - convert to Ansi/Unicode |
||
88 | // zeoNone - assume name is Ansi - convert to Ansi/Unicode |
||
89 | // zeoAuto - unless flags/versions say otherwise, or it has UTF8 name in data, |
||
90 | // treat it as OEM (FAT) / Ansi (NTFS) |
||
91 | TZMEncodingOpts = (zeoAuto, zeoNone, zeoOEM, zeoUTF8, zeoUPath); |
||
92 | |||
93 | // When changing this enum also change the pointer array in the function AddSuffix, |
||
94 | // and the initialisation of ZipMaster. |
||
95 | TZMAddStoreSuffixEnum = (assGIF, assPNG, assZ, assZIP, assZOO, assARC, |
||
96 | assLZH, assARJ, assTAZ, assTGZ, assLHA, assRAR, |
||
97 | assACE, assCAB, assGZ, assGZIP, assJAR, assEXE, assEXT, |
||
98 | assJPG, assJPEG, ass7Zp, assMP3, assWMV, assWMA, assDVR, assAVI); |
||
99 | |||
100 | TZMAddStoreExts = set of TZMAddStoreSuffixEnum; |
||
101 | |||
102 | TZMSpanOptsEnum = (spNoVolumeName, spCompatName, spWipeFiles, |
||
103 | spTryFormat, spAnyTime, spExactName); |
||
104 | TZMSpanOpts = set of TZMSpanOptsEnum; |
||
105 | |||
106 | // options for when reading a zip file |
||
107 | TZMExtrOptsEnum = (ExtrDirNames, ExtrOverWrite, ExtrFreshen, ExtrUpdate, |
||
108 | ExtrTest, ExtrForceDirs, ExtrNTFS); |
||
109 | TZMExtrOpts = set of TZMExtrOptsEnum; |
||
110 | |||
111 | // options for when writing a zip file |
||
112 | TZMWriteOptsEnum = (zwoDiskSpan, zwoZipTime, zwoForceDest); |
||
113 | TZMWriteOpts = set of TZMWriteOptsEnum; |
||
114 | |||
115 | // other options |
||
116 | TZMMergeOpts = (zmoConfirm, zmoAlways, zmoNewer, zmoOlder, zmoNever); |
||
117 | TZMOvrOpts = (ovrAlways, ovrNever, ovrConfirm); |
||
118 | |||
119 | TZMReplaceOpts = (rplConfirm, rplAlways, rplNewer, rplNever); |
||
120 | |||
121 | TZMDeleteOpts = (htdFinal, htdAllowUndo); |
||
122 | |||
123 | TZMRenameOpts = (htrDefault, htrOnce, htrFull); |
||
124 | |||
125 | TZMSkipTypes = (stOnFreshen, stNoOverwrite, stFileExists, stBadPassword, |
||
126 | stBadName, stCompressionUnknown, stUnknownZipHost, stZipFileFormatWrong, |
||
127 | stGeneralExtractError, stUser, stCannotDo, stNotFound, |
||
128 | // opening files (Zip) |
||
129 | stNoShare, stNoAccess, stNoOpen, stDupName, stReadError, stSizeChange |
||
130 | ); |
||
131 | TZMSkipAborts = set of TZMSkipTypes; |
||
132 | |||
133 | TZMZipDiskStatusEnum = (zdsEmpty, zdsHasFiles, zdsPreviousDisk, zdsSameFileName, |
||
134 | zdsNotEnoughSpace); |
||
135 | TZMZipDiskStatus = set of TZMZipDiskStatusEnum; |
||
136 | TZMDiskAction = (zdaYesToAll, zdaOk, zdaErase, zdaReject, zdaCancel); |
||
137 | |||
138 | TZMDeflates = (zmStore, zmStoreEncrypt, zmDeflate, zmDeflateEncrypt); |
||
139 | |||
140 | type |
||
141 | TZMSFXOpt = ( |
||
142 | soAskCmdLine, // allow user to prevent execution of the command line |
||
143 | soAskFiles, // allow user to prevent certain files from extraction |
||
144 | soHideOverWriteBox, // do not allow user to choose the overwrite mode |
||
145 | soAutoRun, // start extraction + evtl. command line automatically |
||
146 | // only if sfx filename starts with "!" or is "setup.exe" |
||
147 | soNoSuccessMsg, // don't show success message after extraction |
||
148 | soExpandVariables, // expand environment variables in path/cmd line... |
||
149 | soInitiallyHideFiles, // dont show file listview on startup |
||
150 | soForceHideFiles, // do not allow user to show files list |
||
151 | // (no effect if shfInitiallyShowFiles is set) |
||
152 | soCheckAutoRunFileName, // can only autorun if !... or setup.exe |
||
153 | soCanBeCancelled, // extraction can be cancelled |
||
154 | soCreateEmptyDirs, // recreate empty directories |
||
155 | soSuccessAlways // always give success message even if soAutoRun or soNoSuccessMsg |
||
156 | ); |
||
157 | |||
158 | // set of TSFXOption |
||
159 | TZMSFXOpts = set of TZMSFXOpt; |
||
160 | |||
161 | type |
||
162 | TZMProgressType = (NewFile, ProgressUpdate, EndOfBatch, TotalFiles2Process, |
||
163 | TotalSize2Process, NewExtra, ExtraUpdate); |
||
164 | |||
165 | type |
||
166 | TZMProgressDetails = class(TObject) |
||
167 | protected |
||
168 | function GetBytesWritten: Int64; virtual; abstract; |
||
169 | function GetDelta: Int64; virtual; abstract; |
||
170 | function GetItemName: TZMString; virtual; abstract; |
||
171 | function GetItemNumber: Integer; virtual; abstract; |
||
172 | function GetItemPerCent: Integer; |
||
173 | function GetItemPosition: Int64; virtual; abstract; |
||
174 | function GetItemSize: Int64; virtual; abstract; |
||
175 | function GetOrder: TZMProgressType; virtual; abstract; |
||
176 | function GetTotalCount: Int64; virtual; abstract; |
||
177 | function GetTotalPerCent: Integer; |
||
178 | function GetTotalPosition: Int64; virtual; abstract; |
||
179 | function GetTotalSize: Int64; virtual; abstract; |
||
180 | public |
||
181 | property BytesWritten: Int64 read GetBytesWritten; |
||
182 | property Delta: Int64 read GetDelta; |
||
183 | property ItemName: TZMString read GetItemName; |
||
184 | property ItemNumber: Integer read GetItemNumber; |
||
185 | property ItemPerCent: Integer Read GetItemPerCent; |
||
186 | property ItemPosition: Int64 read GetItemPosition; |
||
187 | property ItemSize: Int64 read GetItemSize; |
||
188 | property Order: TZMProgressType read GetOrder; |
||
189 | property TotalCount: Int64 read GetTotalCount; |
||
190 | property TotalPerCent: Integer Read GetTotalPerCent; |
||
191 | property TotalPosition: Int64 read GetTotalPosition; |
||
192 | property TotalSize: Int64 read GetTotalSize; |
||
193 | end; |
||
194 | |||
195 | // ZipDirEntry status bit constants |
||
196 | const |
||
197 | zsbDirty = $1; |
||
198 | zsbSelected = $2; |
||
199 | zsbSkipped = $4; |
||
200 | zsbIgnore = $8; |
||
201 | zsbDirOnly = $10; |
||
202 | zsbInvalid = $20; |
||
203 | zsbError = $40; // processing error |
||
204 | |||
205 | const |
||
206 | DefNoSkips{: TZMSkipAborts} = [stDupName, stReadError]; |
||
207 | ZMInitialCRC = $FFFFFFFF; |
||
208 | |||
209 | type |
||
210 | // abstract class representing a zip central record |
||
211 | TZMDirEntry = class |
||
212 | private |
||
213 | function GetIsDirOnly: boolean; |
||
214 | protected |
||
215 | function GetCompressedSize: Int64; virtual; abstract; |
||
216 | function GetCompressionMethod: Word; virtual; abstract; |
||
217 | function GetCRC32: Cardinal; virtual; abstract; |
||
218 | function GetDateStamp: TDateTime; |
||
219 | function GetDateTime: Cardinal; virtual; abstract; |
||
220 | function GetEncoded: TZMEncodingOpts; virtual; abstract; |
||
221 | function GetEncrypted: Boolean; virtual; abstract; |
||
222 | function GetExtFileAttrib: Longword; virtual; abstract; |
||
223 | function GetExtraData(Tag: Word): TZMRawBytes; virtual; |
||
224 | function GetExtraField: TZMRawBytes; virtual; abstract; |
||
225 | function GetExtraFieldLength: Word; virtual; abstract; |
||
226 | function GetFileComment: TZMString; virtual; abstract; |
||
227 | function GetFileCommentLen: Word; virtual; abstract; |
||
228 | function GetFileName: TZMString; virtual; abstract; |
||
229 | function GetFileNameLength: Word; virtual; abstract; |
||
230 | function GetFlag: Word; virtual; abstract; |
||
231 | function GetHeaderName: TZMRawBytes; virtual; abstract; |
||
232 | function GetIntFileAttrib: Word; virtual; abstract; |
||
233 | function GetRelOffLocalHdr: Int64; virtual; abstract; |
||
234 | function GetStartOnDisk: Word; virtual; abstract; |
||
235 | function GetStatusBits: Cardinal; virtual; abstract; |
||
236 | function GetUncompressedSize: Int64; virtual; abstract; |
||
237 | function GetVersionMadeBy: Word; virtual; abstract; |
||
238 | function GetVersionNeeded: Word; virtual; abstract; |
||
239 | function XData(const x: TZMRawBytes; Tag: Word; var idx, size: Integer): |
||
240 | Boolean; |
||
241 | public |
||
242 | property CompressedSize: Int64 Read GetCompressedSize; |
||
243 | property CompressionMethod: Word Read GetCompressionMethod; |
||
244 | property CRC32: Cardinal Read GetCRC32; |
||
245 | property DateStamp: TDateTime Read GetDateStamp; |
||
246 | property DateTime: Cardinal Read GetDateTime; |
||
247 | property Encoded: TZMEncodingOpts Read GetEncoded; |
||
248 | property Encrypted: Boolean Read GetEncrypted; |
||
249 | property ExtFileAttrib: Longword Read GetExtFileAttrib; |
||
250 | property ExtraData[Tag: Word]: TZMRawBytes read GetExtraData; |
||
251 | property ExtraField: TZMRawBytes read GetExtraField; |
||
252 | property ExtraFieldLength: Word Read GetExtraFieldLength; |
||
253 | property FileComment: TZMString Read GetFileComment; |
||
254 | property FileCommentLen: Word Read GetFileCommentLen; |
||
255 | property FileName: TZMString Read GetFileName; |
||
256 | property FileNameLength: Word Read GetFileNameLength; |
||
257 | property Flag: Word Read GetFlag; |
||
258 | property HeaderName: TZMRawBytes Read GetHeaderName; |
||
259 | property IntFileAttrib: Word Read GetIntFileAttrib; |
||
260 | property IsDirOnly: boolean read GetIsDirOnly; |
||
261 | property RelOffLocalHdr: Int64 Read GetRelOffLocalHdr; |
||
262 | property StartOnDisk: Word Read GetStartOnDisk; |
||
263 | property StatusBits: Cardinal Read GetStatusBits; |
||
264 | property UncompressedSize: Int64 Read GetUncompressedSize; |
||
265 | property VersionMadeBy: Word read GetVersionMadeBy; |
||
266 | property VersionNeeded: Word Read GetVersionNeeded; |
||
267 | end; |
||
268 | |||
269 | TZMDirRec = class(TZMDirEntry) |
||
270 | public |
||
271 | function ChangeAttrs(nAttr: Cardinal): Integer; virtual; abstract; |
||
272 | function ChangeComment(const ncomment: TZMString): Integer; virtual; abstract; |
||
273 | function ChangeData(ndata: TZMRawBytes): Integer; virtual; abstract; |
||
274 | function ChangeDate(ndosdate: Cardinal): Integer; virtual; abstract; |
||
275 | function ChangeEncoding: Integer; virtual; abstract; |
||
276 | function ChangeName(const nname: TZMString): Integer; virtual; abstract; |
||
277 | function ChangeStamp(ndate: TDateTime): Integer; |
||
278 | end; |
||
279 | |||
280 | type |
||
281 | TZMForEachFunction = function(rec: TZMDirEntry; var Data): Integer; |
||
282 | TZMChangeFunction = function(rec: TZMDirRec; var Data): Integer; |
||
283 | |||
284 | type |
||
285 | TZMRenameRec = record |
||
286 | Source: String; |
||
287 | Dest: String; |
||
288 | Comment: String; |
||
289 | DateTime: Integer; |
||
290 | end; |
||
291 | PZMRenameRec = ^TZMRenameRec; |
||
292 | |||
293 | // structure used to 'identify' streams |
||
294 | type |
||
295 | TZMSStats = packed record |
||
296 | Size: Int64; |
||
297 | Date: Cardinal; |
||
298 | Attrs: Cardinal; |
||
299 | end; |
||
300 | PZMSStats = ^TZMSStats; |
||
301 | |||
302 | type |
||
303 | TZMStreamOp = (zsoIdentify, zsoOpen, zsoClose); |
||
304 | |||
305 | type |
||
306 | TZMCheckTerminateEvent = procedure(Sender: TObject; var abort: Boolean) of object; |
||
307 | TZMCopyZippedOverwriteEvent = procedure(Sender: TObject; |
||
308 | src, dst: TZMDirEntry; var DoOverwrite: Boolean) of object; |
||
309 | TZMCRC32ErrorEvent = procedure(Sender: TObject; const ForFile: TZMString; |
||
310 | FoundCRC, ExpectedCRC: Longword; var DoExtract: Boolean) of object; |
||
311 | TZMExtractOverwriteEvent = procedure(Sender: TObject; const ForFile: TZMString; |
||
312 | IsOlder: Boolean; var DoOverwrite: Boolean; DirIndex: Integer) of object; |
||
313 | TZMSkippedEvent = procedure(Sender: TObject; const ForFile: TZMString; |
||
314 | SkipType: TZMSkipTypes; var ExtError: Integer) of object; |
||
315 | TZMFileCommentEvent = procedure(Sender: TObject; const ForFile: TZMString; |
||
316 | var FileComment: TZMString; var IsChanged: Boolean) of object; |
||
317 | TZMFileExtraEvent = procedure(Sender: TObject; const ForFile: TZMString; |
||
318 | var Data: TZMRawBytes; var IsChanged: Boolean) of object; |
||
319 | TZMGetNextDiskEvent = procedure(Sender: TObject; DiskSeqNo, DiskTotal: Integer; |
||
320 | Drive: String; var AbortAction: Boolean) of object; |
||
321 | TZMLoadStrEvent = procedure(Ident: Integer; var DefStr: String) of object; |
||
322 | TZMMessageEvent = procedure(Sender: TObject; ErrCode: Integer; |
||
323 | const ErrMsg: TZMString) of object; |
||
324 | // new signiture |
||
325 | TZMNewNameEvent = procedure(Sender: TObject; SeqNo: Integer) of object; |
||
326 | TZMPasswordErrorEvent = procedure(Sender: TObject; IsZipAction: Boolean; |
||
327 | var NewPassword: String; const ForFile: TZMString; var RepeatCount: Longword; |
||
328 | var Action: TMsgDlgBtn) of object; |
||
329 | TZMProgressEvent = procedure(Sender: TObject; details: TZMProgressDetails) of object; |
||
330 | TZMSetAddNameEvent = procedure(Sender: TObject; var FileName: TZMString; |
||
331 | const ExtName: TZMString; var IsChanged: Boolean) of object; |
||
332 | TZMSetExtNameEvent = procedure(Sender: TObject; var FileName: TZMString; |
||
333 | const BaseDir: TZMString; var IsChanged: Boolean) of object; |
||
334 | TZMStatusDiskEvent = procedure(Sender: TObject; PreviousDisk: Integer; |
||
335 | PreviousFile: String; Status: TZMZipDiskStatus; |
||
336 | var Action: TZMDiskAction) of object; |
||
337 | TZMTickEvent = procedure(Sender: TObject) of object; |
||
338 | TZMDialogEvent = procedure(Sender: TObject; const title: String; |
||
339 | var msg: String; var Result: Integer; btns: TMsgDlgButtons) of object; |
||
340 | TZMSetCompLevel = procedure(Sender: TObject; const ForFile: TZMString; |
||
341 | var level: Integer; var IsChanged: Boolean) of object; |
||
342 | TZMStreamEvent = procedure(Sender: TObject; opr: TZMStreamOp; snumber: integer; |
||
343 | var strm: TStream; var stat: TZMSStats; var done: Boolean) of object; |
||
344 | TZMStateChange = procedure(Sender: TObject; state: TZMStates; |
||
345 | var NoCursor: boolean) of object; |
||
346 | |||
347 | type |
||
348 | TZMPipe = class |
||
349 | protected |
||
350 | function GetAttributes: Cardinal; virtual; abstract; |
||
351 | function GetDOSDate: Cardinal; virtual; abstract; |
||
352 | function GetFileName: string; virtual; abstract; |
||
353 | function GetOwnsStream: boolean; virtual; abstract; |
||
354 | function GetSize: Integer; virtual; abstract; |
||
355 | function GetStream: TStream; virtual; abstract; |
||
356 | procedure SetAttributes(const Value: Cardinal); virtual; abstract; |
||
357 | procedure SetDOSDate(const Value: Cardinal); virtual; abstract; |
||
358 | procedure SetFileName(const Value: string); virtual; abstract; |
||
359 | procedure SetOwnsStream(const Value: boolean); virtual; abstract; |
||
360 | procedure SetSize(const Value: Integer); virtual; abstract; |
||
361 | procedure SetStream(const Value: TStream); virtual; abstract; |
||
362 | public |
||
363 | property Attributes: Cardinal read GetAttributes write SetAttributes; |
||
364 | property DOSDate: Cardinal read GetDOSDate write SetDOSDate; |
||
365 | property FileName: string read GetFileName write SetFileName; |
||
366 | property OwnsStream: boolean read GetOwnsStream write SetOwnsStream; |
||
367 | property Size: Integer read GetSize write SetSize; |
||
368 | property Stream: TStream read GetStream write SetStream; |
||
369 | end; |
||
370 | |||
371 | TZMPipeList = class |
||
372 | protected |
||
373 | function GetCount: Integer; virtual; abstract; |
||
374 | function GetPipe(Index: Integer): TZMPipe; virtual; abstract; |
||
375 | procedure SetCount(const Value: Integer); virtual; abstract; |
||
376 | procedure SetPipe(Index: Integer; const Value: TZMPipe); virtual; abstract; |
||
377 | public |
||
378 | function Add(aStream: TStream; const FileName: string; Own: boolean): integer; |
||
379 | virtual; abstract; |
||
380 | procedure Clear; virtual; abstract; |
||
381 | property Count: Integer read GetCount write SetCount; |
||
382 | property Pipe[Index: Integer]: TZMPipe read GetPipe write SetPipe; default; |
||
383 | end; |
||
384 | |||
385 | type |
||
386 | {$IFDEF VERD2005up} |
||
387 | TCustomZipMaster19 = class; |
||
388 | TZipMasterEnumerator = class |
||
389 | private |
||
390 | FIndex: Integer; |
||
391 | FOwner: TCustomZipMaster19; |
||
392 | public |
||
393 | constructor Create(AMaster: TCustomZipMaster19); |
||
394 | function GetCurrent: TZMDirEntry; |
||
395 | function MoveNext: Boolean; |
||
396 | property Current: TZMDirEntry read GetCurrent; |
||
397 | end; |
||
398 | {$ENDIF} |
||
399 | |||
400 | // the main component |
||
401 | TCustomZipMaster19 = class(TComponent) |
||
402 | private |
||
403 | { Private versions of property variables } |
||
404 | BusyFlag: Integer; |
||
405 | fActive: Integer; |
||
406 | fAddCompLevel: Integer; |
||
407 | fAddStoreSuffixes: TZMAddStoreExts; |
||
408 | fConfirmErase: Boolean; |
||
409 | FCurWaitCount: Integer; |
||
410 | fDelaying: Integer; |
||
411 | fDLLDirectory: String; |
||
412 | fDLLLoad: Boolean; |
||
413 | FEncodeAs: TZMEncodingOpts; |
||
414 | fEncoding: TZMEncodingOpts; |
||
415 | fEncoding_CP: Cardinal; |
||
416 | fEncrypt: Boolean; |
||
417 | fExtAddStoreSuffixes: String; |
||
418 | fExtrBaseDir: String; |
||
419 | fExtrOptions: TZMExtrOpts; |
||
420 | fFreeOnAllDisks: Cardinal; |
||
421 | fFreeOnDisk1: Cardinal; |
||
422 | fFromDate: TDateTime; |
||
423 | FFSpecArgs: TStrings; |
||
424 | fFSpecArgsExcl: TStrings; |
||
425 | fHandle: HWND; |
||
426 | fHowToDelete: TZMDeleteOpts; |
||
427 | FLanguage: String; |
||
428 | fMaxVolumeSize: Integer; |
||
429 | FMaxVolumeSizeKb: Integer; |
||
430 | fMinFreeVolSize: Integer; |
||
431 | FNoReadAux: Boolean; |
||
432 | FNoSkipping: TZMSkipAborts; |
||
433 | fNotMainThread: Boolean; |
||
434 | fOnCheckTerminate: TZMCheckTerminateEvent; |
||
435 | fOnCopyZippedOverwrite: TZMCopyZippedOverwriteEvent; |
||
436 | fOnCRC32Error: TZMCRC32ErrorEvent; |
||
437 | fOnDirUpdate: TNotifyEvent; |
||
438 | fOnExtractOverwrite: TZMExtractOverwriteEvent; |
||
439 | FOnSkipped: TZMSkippedEvent; |
||
440 | fOnFileComment: TZMFileCommentEvent; |
||
441 | fOnFileExtra: TZMFileExtraEvent; |
||
442 | fOnGetNextDisk: TZMGetNextDiskEvent; |
||
443 | fOnMessage: TZMMessageEvent; |
||
444 | fOnNewName: TZMNewNameEvent; |
||
445 | fOnPasswordError: TZMPasswordErrorEvent; |
||
446 | fOnProgress: TZMProgressEvent; |
||
447 | fOnSetAddName: TZMSetAddNameEvent; |
||
448 | fOnSetCompLevel: TZMSetCompLevel; |
||
449 | fOnSetExtName: TZMSetExtNameEvent; |
||
450 | fOnStateChange: TZMStateChange; |
||
451 | fOnStatusDisk: TZMStatusDiskEvent; |
||
452 | fOnStream: TZMStreamEvent; |
||
453 | fOnTick: TZMTickEvent; |
||
454 | fOnZipDialog: TZMDialogEvent; |
||
455 | FPassword: String; |
||
456 | fPasswordReqCount: Longword; |
||
457 | FPipes: TZMPipeList; |
||
458 | fReentry: Boolean; |
||
459 | FSFXRegFailPath: String; |
||
460 | fRootDir: String; |
||
461 | FSaveCursor: TCursor; |
||
462 | FSFXCaption: TZMString; |
||
463 | FSFXCommandLine: TZMString; |
||
464 | FSFXDefaultDir: String; |
||
465 | FSFXMessage: TZMString; |
||
466 | FSFXOptions: TZMSFXOpts; |
||
467 | FSFXOverwriteMode: TZMOvrOpts; |
||
468 | FSFXPath: String; |
||
469 | FSpanOptions: TZMSpanOpts; |
||
470 | fTempDir: String; |
||
471 | fTrace: Boolean; |
||
472 | fUnattended: Boolean; |
||
473 | fUseDelphiBin: Boolean; |
||
474 | FUseDirOnlyEntries: Boolean; |
||
475 | {$IFNDEF UNICODE} |
||
476 | FUseUTF8: Boolean; |
||
477 | {$ENDIF} |
||
478 | fVerbose: Boolean; |
||
479 | FWriteOptions: TZMWriteOpts; |
||
480 | // fWorker: TObject; |
||
481 | FZipComment: AnsiString; |
||
482 | fZipFileName: String; |
||
483 | procedure AuxWasChanged; |
||
484 | function GetActive: Boolean; |
||
485 | function GetBuild: Integer; |
||
486 | { Property get/set functions } |
||
487 | function GetBusy: Boolean; |
||
488 | function GetCancel: Boolean; |
||
489 | function GetCount: Integer; |
||
490 | function GetDirEntry(idx: Integer): TZMDirEntry; |
||
491 | function GetDirOnlyCnt: Integer; |
||
492 | function GetDLL_Build: Integer; |
||
493 | function GetDLL_Load: Boolean; |
||
494 | function GetDLL_Path: String; |
||
495 | function GetDLL_Version: String; |
||
496 | function GetDLL_Version1(load: boolean): String; |
||
497 | function GetErrCode: Integer; |
||
498 | function GetErrMessage: TZMString; |
||
499 | function GetDllErrCode: Integer; |
||
500 | function GetIsSpanned: Boolean; |
||
501 | function GetLanguage: string; |
||
502 | class function GetLanguageInfo(Idx: Integer; info: Cardinal): String; |
||
503 | function GetNoReadAux: Boolean; |
||
504 | function GetOnLoadStr: TZMLoadStrEvent; |
||
505 | function GetSFXOffset: Integer; |
||
506 | function GetSuccessCnt: Integer; |
||
507 | function GetTotalSizeToProcess: Int64; |
||
508 | function GetVersion: String; |
||
509 | function GetZipComment: String; |
||
510 | function GetZipEOC: Int64; |
||
511 | function GetZipFileSize: Int64; |
||
512 | function GetZipSOC: Int64; |
||
513 | function GetZipStream: TMemoryStream; |
||
514 | procedure SetActive(Value: Boolean); |
||
515 | procedure SetCancel(Value: Boolean); |
||
516 | procedure SetDLL_Load(const Value: Boolean); |
||
517 | procedure SetEncodeAs(const Value: TZMEncodingOpts); |
||
518 | procedure SetEncoding(const Value: TZMEncodingOpts); |
||
519 | procedure SetEncoding_CP(Value: Cardinal); |
||
520 | procedure SetErrCode(Value: Integer); |
||
521 | procedure SetFSpecArgs(const Value: TStrings); |
||
522 | procedure SetFSpecArgsExcl(const Value: TStrings); |
||
523 | procedure SetLanguage(const Value: string); |
||
524 | procedure SetNoReadAux(const Value: Boolean); |
||
525 | procedure SetOnLoadStr(const Value: TZMLoadStrEvent); |
||
526 | procedure SetPassword(const Value: String); |
||
527 | procedure SetPasswordReqCount(Value: Longword); |
||
528 | procedure SetPipes(const Value: TZMPipeList); |
||
529 | procedure SetSFXCaption(const Value: TZMString); |
||
530 | procedure SetSFXCommandLine(const Value: TZMString); |
||
531 | procedure SetSFXDefaultDir(const Value: String); |
||
532 | procedure SetSFXIcon(Value: TIcon); |
||
533 | procedure SetSFXMessage(const Value: TZMString); |
||
534 | procedure SetSFXOptions(const Value: TZMSFXOpts); |
||
535 | procedure SetSFXOverwriteMode(const Value: TZMOvrOpts); |
||
536 | procedure SetSFXRegFailPath(const Value: String); |
||
537 | procedure SetSpanOptions(const Value: TZMSpanOpts); |
||
538 | procedure SetUseDirOnlyEntries(const Value: Boolean); |
||
539 | {$IFNDEF UNICODE} |
||
540 | procedure SetUseUTF8(const Value: Boolean); |
||
541 | {$ENDIF} |
||
542 | procedure SetVersion(const Value: String); |
||
543 | procedure SetWriteOptions(const Value: TZMWriteOpts); |
||
544 | procedure SetZipComment(const Value: String); |
||
545 | procedure SetZipFileName(const Value: String); |
||
546 | protected |
||
547 | FAddOptions: TZMAddOpts; |
||
548 | FAuxChanged: Boolean; |
||
549 | fSFXIcon: TIcon; |
||
550 | fWorker: TObject; |
||
551 | function CanStart: Boolean; |
||
552 | procedure DoDelays; |
||
553 | procedure Done(Good: Boolean = True); |
||
554 | procedure DoneBad(E: Exception); |
||
555 | function IsActive: boolean; |
||
556 | procedure Loaded; override; |
||
557 | function Permitted: Boolean; |
||
558 | procedure ReEntered; |
||
559 | procedure Start; |
||
560 | procedure StartNoDll; |
||
561 | procedure StartWaitCursor; |
||
562 | procedure StateChanged(newState: TZMStates); |
||
563 | function Stopped: Boolean; |
||
564 | procedure StopWaitCursor; |
||
565 | public |
||
566 | procedure AbortDLL; |
||
567 | function Add: Integer; |
||
568 | function AddStreamToFile(const FileName: String; |
||
569 | FileDate, FileAttr: Dword): Integer; |
||
570 | function AddStreamToStream(InStream: TMemoryStream): TMemoryStream; |
||
571 | function AddZippedFiles(SrcZipMaster: TCustomZipMaster19; |
||
572 | merge: TZMMergeOpts): Integer; |
||
573 | procedure AfterConstruction; override; |
||
574 | function AppendSlash(const sDir: String): String; |
||
575 | procedure BeforeDestruction; override; |
||
576 | function ChangeFileDetails(func: TZMChangeFunction; var Data): Integer; |
||
577 | procedure Clear; |
||
578 | function ConvertToSFX: Integer; |
||
579 | function ConvertToSpanSFX(const OutFile: String): Integer; |
||
580 | function ConvertToZIP: Integer; |
||
581 | function CopyZippedFiles(DestZipMaster: TCustomZipMaster19; DeleteFromSource: |
||
582 | Boolean; OverwriteDest: TZMMergeOpts): Integer; overload; |
||
583 | function Copy_File(const InFileName, OutFileName: String): Integer; |
||
584 | function Deflate(OutStream, InStream: TStream; Length: Int64; var Method: |
||
585 | TZMDeflates; var CRC: Cardinal): Integer; |
||
586 | function Delete: Integer; |
||
587 | function EraseFile(const FName: String; How: TZMDeleteOpts): Integer; |
||
588 | function Extract: Integer; |
||
589 | function ExtractFileToStream(const FileName: String): TMemoryStream; |
||
590 | function ExtractStreamToStream(InStream: TMemoryStream; OutSize: Longword): |
||
591 | TMemoryStream; |
||
592 | function Find(const fspec: TZMString; var idx: Integer): TZMDirEntry; |
||
593 | function ForEach(func: TZMForEachFunction; var Data): Integer; |
||
594 | function FullVersionString: String; |
||
595 | function GetAddPassword: String; overload; |
||
596 | function GetAddPassword(var Response: TmsgDlgBtn): String; overload; |
||
597 | {$IFDEF VERD2005up} |
||
598 | function GetEnumerator: TZipMasterEnumerator; |
||
599 | {$ENDIF} |
||
600 | function GetExtrPassword: String; overload; |
||
601 | function GetExtrPassword(var Response: TmsgDlgBtn): String; overload; |
||
602 | function GetPassword(const DialogCaption, MsgTxt: String; |
||
603 | pwb: TmsgDlgButtons; var ResultStr: String): TmsgDlgBtn; |
||
604 | function IndexOf(const FName: TZMString): Integer; |
||
605 | function IsZipSFX(const SFXExeName: String): Integer; |
||
606 | function List: Integer; |
||
607 | function MakeTempFileName(const Prefix, Extension: String): String; |
||
608 | function QueryZip(const FName: TFileName): Integer; |
||
609 | function ReadSpan(const InFileName: String; var OutFilePath: String): Integer; |
||
610 | function Rename(RenameList: TList; DateTime: Integer; How: TZMRenameOpts = |
||
611 | htrDefault): Integer; |
||
612 | procedure ShowExceptionError(const ZMExcept: EZMException); |
||
613 | procedure ShowZipFmtMessage(Id: Integer; const Args: array of const); |
||
614 | procedure ShowZipMessage(Ident: Integer; const UserStr: String); |
||
615 | function TheErrorCode(errCode: Integer): Integer; |
||
616 | function Undeflate(OutStream, InStream: TStream; Length: Int64; var Method: |
||
617 | TZMDeflates; var CRC: Cardinal): Integer; |
||
618 | function WriteSpan(const InFileName, OutFileName: String): Integer; |
||
619 | function ZipLoadStr(Id: Integer): string; |
||
620 | // published |
||
621 | property Active: Boolean Read GetActive Write SetActive default True; |
||
622 | property AddCompLevel: Integer Read fAddCompLevel Write fAddCompLevel default 9; |
||
623 | property AddFrom: TDateTime Read fFromDate Write fFromDate; |
||
624 | property AddOptions: TZMAddOpts read FAddOptions write FAddOptions; |
||
625 | property AddStoreSuffixes: TZMAddStoreExts |
||
626 | Read fAddStoreSuffixes Write fAddStoreSuffixes; |
||
627 | property Build: Integer Read GetBuild; |
||
628 | property Busy: Boolean Read GetBusy; |
||
629 | property Cancel: Boolean Read GetCancel Write SetCancel; |
||
630 | property ConfirmErase: Boolean Read fConfirmErase Write fConfirmErase default True; |
||
631 | property Count: Integer Read GetCount; |
||
632 | property DirEntry[idx: Integer]: TZMDirEntry Read GetDirEntry; default; |
||
633 | property DirOnlyCnt: Integer Read GetDirOnlyCnt; |
||
634 | property DLLDirectory: String Read fDLLDirectory Write fDLLDirectory; |
||
635 | property DLL_Build: Integer Read GetDLL_Build; |
||
636 | property DLL_Load: Boolean Read GetDLL_Load Write SetDLL_Load; |
||
637 | property DLL_Path: String Read GetDLL_Path; |
||
638 | property DLL_Version: String Read GetDLL_Version; |
||
639 | property EncodeAs: TZMEncodingOpts read FEncodeAs write SetEncodeAs; |
||
640 | //1 Filename and comment character encoding |
||
641 | property Encoding: TZMEncodingOpts Read fEncoding Write SetEncoding default zeoAuto; |
||
642 | //1 codepage to use to decode filename |
||
643 | property Encoding_CP: Cardinal Read fEncoding_CP Write SetEncoding_CP; |
||
644 | property ErrCode: Integer Read GetErrCode Write SetErrCode; |
||
645 | property ErrMessage: TZMString Read GetErrMessage; |
||
646 | property ExtAddStoreSuffixes: String Read fExtAddStoreSuffixes |
||
647 | Write fExtAddStoreSuffixes; |
||
648 | property ExtrBaseDir: String Read fExtrBaseDir Write fExtrBaseDir; |
||
649 | property ExtrOptions: TZMExtrOpts Read fExtrOptions Write fExtrOptions; |
||
650 | property FSpecArgs: TStrings read FFSpecArgs write SetFSpecArgs; |
||
651 | property FSpecArgsExcl: TStrings Read fFSpecArgsExcl Write SetFSpecArgsExcl; |
||
652 | property DllErrCode: Integer read GetDllErrCode; |
||
653 | property Handle: HWND Read fHandle Write fHandle; |
||
654 | property HowToDelete: TZMDeleteOpts |
||
655 | Read fHowToDelete Write fHowToDelete default htdAllowUndo; |
||
656 | property IsSpanned: Boolean Read GetIsSpanned; |
||
657 | property KeepFreeOnAllDisks: Cardinal Read fFreeOnAllDisks Write fFreeOnAllDisks; |
||
658 | property KeepFreeOnDisk1: Cardinal Read fFreeOnDisk1 Write fFreeOnDisk1; |
||
659 | property Language: string read GetLanguage write SetLanguage; |
||
660 | property LanguageInfo[Idx: Integer; info: Cardinal]: String Read GetLanguageInfo; |
||
661 | property MaxVolumeSize: Integer Read fMaxVolumeSize Write fMaxVolumeSize; |
||
662 | property MaxVolumeSizeKb: Integer read FMaxVolumeSizeKb write FMaxVolumeSizeKb; |
||
663 | property MinFreeVolumeSize: Integer Read fMinFreeVolSize |
||
664 | Write fMinFreeVolSize default 65536; |
||
665 | property NoReadAux: Boolean read GetNoReadAux write SetNoReadAux; |
||
666 | property NoSkipping: TZMSkipAborts read FNoSkipping write FNoSkipping default |
||
667 | DefNoSkips; |
||
668 | property NotMainThread: Boolean Read fNotMainThread Write fNotMainThread; |
||
669 | property Password: String read FPassword write SetPassword; |
||
670 | property PasswordReqCount: Longword Read fPasswordReqCount |
||
671 | Write SetPasswordReqCount default 1; |
||
672 | property Pipes: TZMPipeList read FPipes write SetPipes; |
||
673 | property RootDir: String Read fRootDir Write fRootDir; |
||
674 | property SFXCaption: TZMString read FSFXCaption write SetSFXCaption; |
||
675 | property SFXCommandLine: TZMString read FSFXCommandLine write SetSFXCommandLine; |
||
676 | property SFXDefaultDir: String read FSFXDefaultDir write SetSFXDefaultDir; |
||
677 | property SFXIcon: TIcon Read fSFXIcon Write SetSFXIcon; |
||
678 | property SFXMessage: TZMString read FSFXMessage write SetSFXMessage; |
||
679 | property SFXOffset: Integer Read GetSFXOffset; |
||
680 | property SFXOptions: TZMSFXOpts read FSFXOptions write SetSFXOptions; |
||
681 | property SFXOverwriteMode: TZMOvrOpts read FSFXOverwriteMode write |
||
682 | SetSFXOverwriteMode default ovrConfirm; |
||
683 | property SFXPath: String read FSFXPath write FSFXPath; |
||
684 | property SFXRegFailPath: String read FSFXRegFailPath write SetSFXRegFailPath; |
||
685 | property SpanOptions: TZMSpanOpts read FSpanOptions write SetSpanOptions; |
||
686 | property SuccessCnt: Integer Read GetSuccessCnt; |
||
687 | property TempDir: String Read fTempDir Write fTempDir; |
||
688 | property TotalSizeToProcess: Int64 Read GetTotalSizeToProcess; |
||
689 | property Trace: Boolean Read fTrace Write fTrace; |
||
690 | property Unattended: Boolean Read fUnattended Write fUnattended; |
||
691 | property UseDirOnlyEntries: Boolean read FUseDirOnlyEntries write |
||
692 | SetUseDirOnlyEntries default False; |
||
693 | {$IFNDEF UNICODE} |
||
694 | property UseUTF8: Boolean read FUseUTF8 write SetUseUTF8; |
||
695 | {$ENDIF} |
||
696 | property Verbose: Boolean Read fVerbose Write fVerbose; |
||
697 | property Version: String Read GetVersion Write SetVersion; |
||
698 | property WriteOptions: TZMWriteOpts read FWriteOptions write SetWriteOptions; |
||
699 | property ZipComment: String read GetZipComment write SetZipComment; |
||
700 | property ZipEOC: Int64 Read GetZipEOC; |
||
701 | property ZipFileName: String Read fZipFileName Write SetZipFileName; |
||
702 | property ZipFileSize: Int64 Read GetZipFileSize; |
||
703 | property ZipSOC: Int64 Read GetZipSOC; |
||
704 | property ZipStream: TMemoryStream read GetZipStream; |
||
705 | { Events } |
||
706 | property OnCheckTerminate: TZMCheckTerminateEvent |
||
707 | Read fOnCheckTerminate Write fOnCheckTerminate; |
||
708 | property OnCopyZippedOverwrite: TZMCopyZippedOverwriteEvent |
||
709 | Read fOnCopyZippedOverwrite Write fOnCopyZippedOverwrite; |
||
710 | property OnCRC32Error: TZMCRC32ErrorEvent Read fOnCRC32Error Write fOnCRC32Error; |
||
711 | property OnDirUpdate: TNotifyEvent Read fOnDirUpdate Write fOnDirUpdate; |
||
712 | property OnExtractOverwrite: TZMExtractOverwriteEvent |
||
713 | Read fOnExtractOverwrite Write fOnExtractOverwrite; |
||
714 | property OnFileComment: TZMFileCommentEvent |
||
715 | Read fOnFileComment Write fOnFileComment; |
||
716 | property OnFileExtra: TZMFileExtraEvent Read fOnFileExtra Write fOnFileExtra; |
||
717 | property OnGetNextDisk: TZMGetNextDiskEvent |
||
718 | Read fOnGetNextDisk Write fOnGetNextDisk; |
||
719 | property OnLoadStr: TZMLoadStrEvent read GetOnLoadStr write SetOnLoadStr; |
||
720 | property OnMessage: TZMMessageEvent Read fOnMessage Write fOnMessage; |
||
721 | property OnNewName: TZMNewNameEvent Read fOnNewName Write fOnNewName; |
||
722 | property OnPasswordError: TZMPasswordErrorEvent |
||
723 | Read fOnPasswordError Write fOnPasswordError; |
||
724 | property OnProgress: TZMProgressEvent Read fOnProgress Write fOnProgress; |
||
725 | property OnSetAddName: TZMSetAddNameEvent Read fOnSetAddName Write fOnSetAddName; |
||
726 | property OnSetCompLevel: TZMSetCompLevel Read fOnSetCompLevel Write fOnSetCompLevel; |
||
727 | property OnSetExtName: TZMSetExtNameEvent Read fOnSetExtName Write fOnSetExtName; |
||
728 | property OnSkipped: TZMSkippedEvent read FOnSkipped write FOnSkipped; |
||
729 | property OnStateChange: TZMStateChange Read fOnStateChange Write fOnStateChange; |
||
730 | property OnStatusDisk: TZMStatusDiskEvent Read fOnStatusDisk Write fOnStatusDisk; |
||
731 | property OnStream: TZMStreamEvent Read fOnStream Write fOnStream; |
||
732 | property OnTick: TZMTickEvent Read fOnTick Write fOnTick; |
||
733 | property OnZipDialog: TZMDialogEvent Read fOnZipDialog Write fOnZipDialog; |
||
734 | end; |
||
735 | |||
736 | TZipMaster19 = class(TCustomZipMaster19) |
||
737 | published |
||
738 | property Active default True; |
||
739 | property AddCompLevel default 9; |
||
740 | property AddFrom; |
||
741 | property AddOptions; |
||
742 | property AddStoreSuffixes; |
||
743 | property ConfirmErase default True; |
||
744 | property DLLDirectory; |
||
745 | property DLL_Load; |
||
746 | //1 Filename and comment character encoding |
||
747 | property Encoding default zeoAuto; |
||
748 | property ExtAddStoreSuffixes; |
||
749 | property ExtrBaseDir; |
||
750 | property ExtrOptions; |
||
751 | property FSpecArgs; |
||
752 | property FSpecArgsExcl; |
||
753 | property HowToDelete; |
||
754 | property KeepFreeOnAllDisks; |
||
755 | property KeepFreeOnDisk1; |
||
756 | property Language; |
||
757 | property MaxVolumeSize; |
||
758 | property MaxVolumeSizeKb; |
||
759 | property MinFreeVolumeSize default 65536; |
||
760 | property NoReadAux; |
||
761 | property NoSkipping default DefNoSkips; |
||
762 | { Events } |
||
763 | property OnCheckTerminate; |
||
764 | property OnCopyZippedOverwrite; |
||
765 | property OnCRC32Error; |
||
766 | property OnDirUpdate; |
||
767 | property OnExtractOverwrite; |
||
768 | property OnFileComment; |
||
769 | property OnFileExtra; |
||
770 | property OnGetNextDisk; |
||
771 | property OnLoadStr; |
||
772 | property OnMessage; |
||
773 | property OnNewName; |
||
774 | property OnPasswordError; |
||
775 | property OnProgress; |
||
776 | property OnSetAddName; |
||
777 | property OnSetCompLevel; |
||
778 | property OnSetExtName; |
||
779 | property OnSkipped; |
||
780 | property OnStatusDisk; |
||
781 | property OnStream; |
||
782 | property OnTick; |
||
783 | property OnZipDialog; |
||
784 | property Password; |
||
785 | property PasswordReqCount default 1; |
||
786 | // SFX |
||
787 | property RootDir; |
||
788 | property SFXCaption; |
||
789 | property SFXCommandLine; |
||
790 | property SFXDefaultDir; |
||
791 | property SFXIcon; |
||
792 | property SFXMessage; |
||
793 | property SFXOptions; |
||
794 | property SFXOverwriteMode; |
||
795 | property SFXPath; |
||
796 | property SFXRegFailPath; |
||
797 | property SpanOptions; |
||
798 | property TempDir; |
||
799 | property Trace; |
||
800 | property Unattended; |
||
801 | property UseDirOnlyEntries; |
||
802 | {$IFNDEF UNICODE} |
||
803 | property UseUTF8; |
||
804 | {$ENDIF} |
||
805 | property Verbose; |
||
806 | property Version; |
||
807 | property WriteOptions; |
||
808 | property ZipComment; |
||
809 | property ZipFileName; |
||
810 | end; |
||
811 | |||
812 | // default file extensions that are best 'stored' |
||
813 | const |
||
814 | ZMDefAddStoreSuffixes = [assGIF..assJAR, assJPG..ass7Zp, assMP3..assAVI]; |
||
815 | |||
816 | // Configuration options - rebuild if changed |
||
817 | //__ USE_COMPRESSED_STRINGS - undefine to use ResourceStrings |
||
818 | {$Define USE_COMPRESSED_STRINGS} |
||
819 | |||
820 | //__ STATIC_LOAD_DELZIP_DLL - define to statically load dll |
||
821 | //{$DEFINE STATIC_LOAD_DELZIP_DLL} |
||
822 | |||
823 | //__ SINGLE_ZIPMASTER_VERSION - define if no other version is installed |
||
824 | //{$DEFINE SINGLE_ZIPMASTER_VERSION} |
||
825 | |||
826 | {$IFDEF SINGLE_ZIPMASTER_VERSION} |
||
827 | type |
||
828 | TZipMaster = TZipMaster19; |
||
829 | {$ENDIF} |
||
830 | |||
831 | procedure Register; |
||
832 | |||
833 | implementation |
||
834 | |||
835 | uses |
||
836 | Forms, |
||
837 | ZMCompat19, ZMUtils19, ZMCore19, ZMWrkr19, ZMMsg19, ZMDLLOpr19, ZMMatch19, ZMMsgStr19, |
||
838 | ZMUTF819; |
||
839 | |||
840 | {$R ZipMstr19.Res ZipMstr19.rc} |
||
841 | {$R 'res\zmres19_str.res'} |
||
842 | |||
843 | const |
||
844 | DelayingLanguage = 1; |
||
845 | DelayingFileName = 2; |
||
846 | DelayingComment = 4; |
||
847 | DelayingDLL = 8; |
||
848 | |||
849 | procedure Register; |
||
850 | begin |
||
851 | {$IFDEF SINGLE_ZIPMASTER_VERSION} |
||
852 | RegisterComponents('DelphiZip', [TZipMaster]); |
||
853 | {$ELSE} |
||
854 | RegisterComponents('DelphiZip 19', [TZipMaster19]); |
||
855 | {$ENDIF} |
||
856 | end; |
||
857 | |||
858 | {TZMProgressDetails} |
||
859 | function TZMProgressDetails.GetItemPerCent: Integer; |
||
860 | begin |
||
861 | if (ItemSize > 0) and (ItemPosition > 0) then |
||
862 | Result := (100 * ItemPosition) div ItemSize |
||
863 | else |
||
864 | Result := 0; |
||
865 | end; |
||
866 | |||
867 | function TZMProgressDetails.GetTotalPerCent: Integer; |
||
868 | begin |
||
869 | if (TotalSize > 0) and (TotalPosition > 0) then |
||
870 | Result := (100 * TotalPosition) div TotalSize |
||
871 | else |
||
872 | Result := 0; |
||
873 | end; |
||
874 | |||
875 | {TZMDirEntry} |
||
876 | function TZMDirEntry.GetDateStamp: TDateTime; |
||
877 | begin |
||
878 | Result := FileDateToLocalDateTime(GetDateTime); |
||
879 | end; |
||
880 | |||
881 | // return first data for Tag |
||
882 | function TZMDirEntry.GetExtraData(Tag: Word): TZMRawBytes; |
||
883 | var |
||
884 | i: Integer; |
||
885 | sz: Integer; |
||
886 | begin |
||
887 | Result := ExtraField; |
||
888 | if (ExtraFieldLength >= 4) and XData(Result, Word(Tag), i, sz) then |
||
889 | Result := Copy(Result, 5, sz - 4) |
||
890 | else |
||
891 | Result := ''; |
||
892 | end; |
||
893 | |||
894 | function TZMDirEntry.GetIsDirOnly: boolean; |
||
895 | begin |
||
896 | Result := (StatusBits and zsbDirOnly) <> 0; |
||
897 | end; |
||
898 | |||
899 | function TZMDirEntry.XData(const x: TZMRawBytes; Tag: Word; var idx, size: |
||
900 | Integer): Boolean; |
||
901 | var |
||
902 | i: Integer; |
||
903 | l: Integer; |
||
904 | wsz: Word; |
||
905 | wtg: Word; |
||
906 | begin |
||
907 | Result := False; |
||
908 | idx := 0; |
||
909 | size := 0; |
||
910 | i := 1; |
||
911 | l := Length(x); |
||
912 | while i <= l - 4 do |
||
913 | begin |
||
914 | wtg := pWord(@x[i])^; |
||
915 | wsz := pWord(@x[i + 2])^; |
||
916 | if wtg = Tag then |
||
917 | begin |
||
918 | Result := (i + wsz + 4) <= l + 1; |
||
919 | if Result then |
||
920 | begin |
||
921 | idx := i; |
||
922 | size := wsz + 4; |
||
923 | end; |
||
924 | break; |
||
925 | end; |
||
926 | i := i + wsz + 4; |
||
927 | end; |
||
928 | end; |
||
929 | |||
930 | {TZMDirRec} |
||
931 | function TZMDirRec.ChangeStamp(ndate: TDateTime): Integer; |
||
932 | begin |
||
933 | Result := ChangeDate(DateTimeToFileDate(ndate)); |
||
934 | end; |
||
935 | |||
936 | |||
937 | {$IFDEF VERD2005up} |
||
938 | {TZipMasterEnumerator} |
||
939 | constructor TZipMasterEnumerator.Create(aMaster: TCustomZipMaster19); |
||
940 | begin |
||
941 | inherited Create; |
||
942 | FIndex := -1; |
||
943 | FOwner := aMaster; |
||
944 | end; |
||
945 | |||
946 | function TZipMasterEnumerator.GetCurrent: TZMDirEntry; |
||
947 | begin |
||
948 | Result := FOwner[FIndex]; |
||
949 | end; |
||
950 | |||
951 | function TCustomZipMaster19.GetEnumerator: TZipMasterEnumerator; |
||
952 | begin |
||
953 | Result := TZipMasterEnumerator.Create(Self); |
||
954 | end; |
||
955 | |||
956 | function TZipMasterEnumerator.MoveNext: boolean; |
||
957 | begin |
||
958 | Result := FIndex < (FOwner.Count- 1); |
||
959 | if Result then |
||
960 | Inc(FIndex); |
||
961 | end; |
||
962 | {$ENDIF} |
||
963 | |||
964 | {TCustomZipMaster19} |
||
965 | procedure TCustomZipMaster19.AbortDLL; |
||
966 | begin |
||
967 | TZMDLLOpr(fWorker).AbortDLL; |
||
968 | end; |
||
969 | |||
970 | function TCustomZipMaster19.Add: Integer; |
||
971 | begin |
||
972 | if Permitted then |
||
973 | try |
||
974 | Start; |
||
975 | TZMDLLOpr(fWorker).Add; |
||
976 | Done; |
||
977 | except |
||
978 | On E: Exception do |
||
979 | DoneBad(E); |
||
980 | end; |
||
981 | Result := ErrCode; |
||
982 | end; |
||
983 | |||
984 | function TCustomZipMaster19.AddStreamToFile(const FileName: String; |
||
985 | FileDate, FileAttr: Dword): Integer; |
||
986 | begin |
||
987 | if Permitted then |
||
988 | try |
||
989 | Start; |
||
990 | TZMDLLOpr(fWorker).AddStreamToFile(FileName, FileDate, FileAttr); |
||
991 | Done; |
||
992 | except |
||
993 | On E: Exception do |
||
994 | DoneBad(E); |
||
995 | end; |
||
996 | Result := ErrCode; |
||
997 | end; |
||
998 | |||
999 | function TCustomZipMaster19.AddStreamToStream(InStream: TMemoryStream): |
||
1000 | TMemoryStream; |
||
1001 | begin |
||
1002 | Result := nil; |
||
1003 | if Permitted then |
||
1004 | try |
||
1005 | Start; |
||
1006 | TZMDLLOpr(fWorker).AddStreamToStream(InStream); |
||
1007 | if SuccessCnt = 1 then |
||
1008 | Result := ZipStream; |
||
1009 | Done; |
||
1010 | except |
||
1011 | On E: Exception do |
||
1012 | DoneBad(E); |
||
1013 | end; |
||
1014 | end; |
||
1015 | |||
1016 | function TCustomZipMaster19.AddZippedFiles(SrcZipMaster: TCustomZipMaster19; |
||
1017 | merge: TZMMergeOpts): Integer; |
||
1018 | begin |
||
1019 | if Permitted then |
||
1020 | try |
||
1021 | Start; |
||
1022 | if (not assigned(SrcZipMaster)) or (SrcZipMaster.ZipFileName = '') then |
||
1023 | raise EZipMaster.CreateResDisp(GE_NoZipSpecified, True); |
||
1024 | if SrcZipMaster.Permitted then |
||
1025 | begin |
||
1026 | try |
||
1027 | SrcZipMaster.Start; |
||
1028 | TZMWorker(fWorker).AddZippedFiles(TZMWorker(SrcZipMaster.fWorker), merge); |
||
1029 | SrcZipMaster.Done; |
||
1030 | except |
||
1031 | on E: Exception do |
||
1032 | begin |
||
1033 | SrcZipMaster.DoneBad(E); |
||
1034 | raise; |
||
1035 | end; |
||
1036 | end; |
||
1037 | end |
||
1038 | else |
||
1039 | raise EZipMaster.CreateResStr(GE_WasBusy, 'Source'); |
||
1040 | Done; |
||
1041 | except |
||
1042 | on E: Exception do |
||
1043 | DoneBad(E); |
||
1044 | end; |
||
1045 | Result := ErrCode; |
||
1046 | end; |
||
1047 | |||
1048 | procedure TCustomZipMaster19.AfterConstruction; |
||
1049 | begin |
||
1050 | inherited; |
||
1051 | fWorker := TZMDLLOpr.Create(Self); |
||
1052 | fDelaying := 0; |
||
1053 | BusyFlag := 0; |
||
1054 | fCurWaitCount := 0; |
||
1055 | fNotMainThread := False; |
||
1056 | FNoReadAux := False; |
||
1057 | FAuxChanged := False; |
||
1058 | fFSpecArgs := TStringList.Create; |
||
1059 | fFSpecArgsExcl := TStringList.Create; |
||
1060 | FPipes := TZMPipeListImp.Create; |
||
1061 | fAddCompLevel := 9; // default to tightest compression |
||
1062 | fAddStoreSuffixes := ZMDefAddStoreSuffixes; |
||
1063 | fEncoding := zeoAuto; |
||
1064 | fEncrypt := False; |
||
1065 | fFromDate := 0; |
||
1066 | fHandle := Application.Handle; |
||
1067 | fHowToDelete := htdAllowUndo; |
||
1068 | fPassword := ''; |
||
1069 | fPasswordReqCount := 1; |
||
1070 | fUnattended := False; |
||
1071 | fUseDirOnlyEntries := False; |
||
1072 | fUseDelphiBin := True; |
||
1073 | fMinFreeVolSize := 65536; |
||
1074 | fMaxVolumeSize := 0; |
||
1075 | fMaxVolumeSizeKb := 0; |
||
1076 | fFreeOnAllDisks := 0; |
||
1077 | fFreeOnDisk1 := 0; |
||
1078 | fConfirmErase := False; |
||
1079 | FNoSkipping := DefNoSkips; |
||
1080 | fActive := 2; |
||
1081 | end; |
||
1082 | |||
1083 | function TCustomZipMaster19.AppendSlash(const sDir: String): String; |
||
1084 | begin |
||
1085 | Result := DelimitPath(sDir, True); |
||
1086 | end; |
||
1087 | |||
1088 | procedure TCustomZipMaster19.AuxWasChanged; |
||
1089 | begin |
||
1090 | if (not fNoReadAux) or (csDesigning in ComponentState) or |
||
1091 | (csLoading in ComponentState) then |
||
1092 | FAuxChanged := True; |
||
1093 | end; |
||
1094 | |||
1095 | procedure TCustomZipMaster19.BeforeDestruction; |
||
1096 | begin |
||
1097 | Cancel := True; // stop any activity |
||
1098 | fActive := 0; |
||
1099 | fOnMessage := nil; // stop any messages being sent |
||
1100 | fOnStateChange := nil; |
||
1101 | fOnStream := nil; |
||
1102 | fOnTick := nil; |
||
1103 | fOnZipDialog := nil; |
||
1104 | if fWorker is TZMCore then |
||
1105 | TZMCore(fWorker).Kill; |
||
1106 | FreeAndNil(fWorker); |
||
1107 | FreeAndNil(fFSpecArgs); |
||
1108 | FreeAndNil(fFSpecArgsExcl); |
||
1109 | FreeAndNil(FPipes); |
||
1110 | inherited; |
||
1111 | end; |
||
1112 | |||
1113 | function TCustomZipMaster19.CanStart: Boolean; |
||
1114 | begin |
||
1115 | if not IsActive then //not Active |
||
1116 | Result := False |
||
1117 | else |
||
1118 | Result := Stopped; |
||
1119 | end; |
||
1120 | |||
1121 | function TCustomZipMaster19.ChangeFileDetails(func: TZMChangeFunction; |
||
1122 | var Data): Integer; |
||
1123 | begin |
||
1124 | Result := 0; |
||
1125 | if Permitted then |
||
1126 | try |
||
1127 | Start; |
||
1128 | Result := TZMWorker(fWorker).ChangeFileDetails(@func, Data); |
||
1129 | Done; |
||
1130 | except |
||
1131 | On E: Exception do |
||
1132 | DoneBad(E); |
||
1133 | end; |
||
1134 | end; |
||
1135 | |||
1136 | procedure TCustomZipMaster19.Clear; |
||
1137 | begin |
||
1138 | if Permitted then |
||
1139 | begin |
||
1140 | TZMWorker(fWorker).Clear; |
||
1141 | Pipes.Clear; |
||
1142 | Done; |
||
1143 | fReentry := False; |
||
1144 | end; |
||
1145 | end; |
||
1146 | |||
1147 | function TCustomZipMaster19.ConvertToSFX: Integer; |
||
1148 | begin |
||
1149 | Result := 0; |
||
1150 | if Permitted then |
||
1151 | try |
||
1152 | Start; |
||
1153 | Result := TZMWorker(fWorker).ConvertToSFX('', nil); |
||
1154 | Done; |
||
1155 | except |
||
1156 | On E: Exception do |
||
1157 | DoneBad(E); |
||
1158 | end; |
||
1159 | if ErrCode <> 0 then |
||
1160 | Result := ErrCode; |
||
1161 | end; |
||
1162 | |||
1163 | function TCustomZipMaster19.ConvertToSpanSFX(const OutFile: String): Integer; |
||
1164 | begin |
||
1165 | Result := 0; |
||
1166 | if Permitted then |
||
1167 | try |
||
1168 | Start; |
||
1169 | Result := TZMWorker(fWorker).ConvertToSpanSFX(OutFile, nil); |
||
1170 | Done; |
||
1171 | except |
||
1172 | On E: Exception do |
||
1173 | DoneBad(E); |
||
1174 | end; |
||
1175 | if ErrCode <> 0 then |
||
1176 | Result := ErrCode; |
||
1177 | end; |
||
1178 | |||
1179 | function TCustomZipMaster19.ConvertToZIP: Integer; |
||
1180 | begin |
||
1181 | Result := 0; |
||
1182 | if Permitted then |
||
1183 | try |
||
1184 | Start; |
||
1185 | Result := TZMWorker(fWorker).ConvertToZIP; |
||
1186 | Done; |
||
1187 | except |
||
1188 | On E: Exception do |
||
1189 | DoneBad(E); |
||
1190 | end; |
||
1191 | if ErrCode <> 0 then |
||
1192 | Result := ErrCode; |
||
1193 | end; |
||
1194 | |||
1195 | function TCustomZipMaster19.CopyZippedFiles(DestZipMaster: TCustomZipMaster19; |
||
1196 | DeleteFromSource: Boolean; OverwriteDest: TZMMergeOpts): Integer; |
||
1197 | var |
||
1198 | DestWorker: TZMWorker; |
||
1199 | MyWorker: TZMWorker; |
||
1200 | begin |
||
1201 | if not assigned(DestZipMaster) then |
||
1202 | begin |
||
1203 | Result := CF_NoDest; |
||
1204 | ShowZipMessage(Result, ''); |
||
1205 | Exit; |
||
1206 | end; |
||
1207 | DestWorker := DestZipMaster.fWorker as TZMWorker; |
||
1208 | MyWorker := fWorker as TZMWorker; |
||
1209 | // destination must not be busy and must not be allowed to become busy |
||
1210 | if DestZipMaster.Permitted then |
||
1211 | begin |
||
1212 | try |
||
1213 | DestZipMaster.Start; // lock it |
||
1214 | if Permitted then |
||
1215 | try |
||
1216 | Start; |
||
1217 | MyWorker.CopyZippedFiles(DestWorker, DeleteFromSource, OverwriteDest); |
||
1218 | done; |
||
1219 | except |
||
1220 | on E: Exception do |
||
1221 | DoneBad(E); |
||
1222 | end; |
||
1223 | DestZipMaster.done; // release it |
||
1224 | except |
||
1225 | on E: Exception do |
||
1226 | DestZipMaster.DoneBad(E); |
||
1227 | end; |
||
1228 | Result := ErrCode; |
||
1229 | end |
||
1230 | else |
||
1231 | begin |
||
1232 | Result := GE_WasBusy; |
||
1233 | ShowZipFmtMessage(Result,[DestZipMaster.ZipFileName]); |
||
1234 | end; |
||
1235 | end; |
||
1236 | |||
1237 | function TCustomZipMaster19.Copy_File(const InFileName, OutFileName: String): Integer; |
||
1238 | begin |
||
1239 | Result := 0; |
||
1240 | if Permitted then |
||
1241 | try |
||
1242 | Start; |
||
1243 | Result := TZMWorker(fWorker).Copy_File(InFileName, OutFileName); |
||
1244 | Done; |
||
1245 | except |
||
1246 | on E: Exception do |
||
1247 | DoneBad(E); |
||
1248 | end; |
||
1249 | if ErrCode <> 0 then |
||
1250 | Result := ErrCode; |
||
1251 | end; |
||
1252 | |||
1253 | function TCustomZipMaster19.Deflate(OutStream, InStream: TStream; Length: |
||
1254 | Int64; var Method: TZMDeflates; var CRC: Cardinal): Integer; |
||
1255 | begin |
||
1256 | if Permitted then |
||
1257 | try |
||
1258 | Start; |
||
1259 | TZMDLLOpr(fWorker).Deflate(OutStream, InStream, Length, Method, CRC); |
||
1260 | Done; |
||
1261 | except |
||
1262 | on E: Exception do |
||
1263 | DoneBad(E); |
||
1264 | end; |
||
1265 | Result := ErrCode; |
||
1266 | end; |
||
1267 | |||
1268 | function TCustomZipMaster19.Delete: Integer; |
||
1269 | begin |
||
1270 | if Permitted then |
||
1271 | try |
||
1272 | Start; |
||
1273 | TZMWorker(fWorker).Delete; |
||
1274 | Done; |
||
1275 | except |
||
1276 | on E: Exception do |
||
1277 | DoneBad(E); |
||
1278 | end; |
||
1279 | Result := ErrCode; |
||
1280 | end; |
||
1281 | |||
1282 | procedure TCustomZipMaster19.DoDelays; |
||
1283 | var |
||
1284 | delay: Integer; |
||
1285 | begin |
||
1286 | if Permitted then |
||
1287 | try |
||
1288 | Start; |
||
1289 | delay := fDelaying; |
||
1290 | fDelaying := 0; |
||
1291 | if (delay and DelayingLanguage) <> 0 then |
||
1292 | SetZipMsgLanguage(fLanguage); |
||
1293 | if (delay and DelayingFileName) <> 0 then |
||
1294 | TZMWorker(fWorker).Set_ZipFileName(fZipFileName, zloFull); |
||
1295 | if (ErrCode = 0) and ((delay and DelayingComment) <> 0) then |
||
1296 | TZMWorker(fWorker).Set_ZipComment(AnsiString(fZipComment)); |
||
1297 | if (ErrCode = 0) and ((delay and DelayingDLL) <> 0) then |
||
1298 | begin |
||
1299 | TZMDLLOpr(fWorker).DLL_Load := fDLLLoad; |
||
1300 | fDLLLoad := TZMDLLOpr(fWorker).DLL_Load; // true if it loaded |
||
1301 | end; |
||
1302 | Done; |
||
1303 | except |
||
1304 | On E: Exception do |
||
1305 | DoneBad(E); |
||
1306 | end; |
||
1307 | end; |
||
1308 | |||
1309 | procedure TCustomZipMaster19.Done(Good: Boolean = True); |
||
1310 | var |
||
1311 | z: TZMWorker; |
||
1312 | begin |
||
1313 | z := fWorker as TZMWorker; |
||
1314 | z.Done(Good); |
||
1315 | if Good then |
||
1316 | begin |
||
1317 | fFSpecArgs.Assign(z.FSpecArgs); |
||
1318 | fFSpecArgsExcl.Assign(z.FSpecArgsExcl); |
||
1319 | fZipComment := z.ZipComment; |
||
1320 | fZipFileName := z.ZipFileName; |
||
1321 | if not NoReadAux then |
||
1322 | begin |
||
1323 | // set Aux properties from current |
||
1324 | if z.GetAuxProperties then |
||
1325 | fAuxChanged := False; |
||
1326 | end; |
||
1327 | end; |
||
1328 | Dec(BusyFlag); |
||
1329 | if Trace then |
||
1330 | TZMCore(fWorker).Diag('done = ' + IntToStr(BusyFlag)); |
||
1331 | if BusyFlag = 0 then |
||
1332 | begin |
||
1333 | StateChanged(zsIdle); |
||
1334 | // Are we waiting to go inactive? |
||
1335 | if fActive < 0 then |
||
1336 | begin |
||
1337 | fActive := 0; |
||
1338 | StateChanged(zsDisabled); |
||
1339 | end; |
||
1340 | end; |
||
1341 | end; |
||
1342 | |||
1343 | procedure TCustomZipMaster19.DoneBad(E: Exception); |
||
1344 | begin |
||
1345 | Done(False); |
||
1346 | Pipes.Clear; |
||
1347 | if E is EZMException then // Catch all Zip specific errors. |
||
1348 | ShowExceptionError(EZMException(E)) |
||
1349 | else |
||
1350 | if E is EOutOfMemory then |
||
1351 | ShowZipMessage(GE_NoMem, '') |
||
1352 | else |
||
1353 | ShowZipMessage(LI_ErrorUnknown, E.Message); |
||
1354 | // the error ErrMessage of an unknown error is displayed ... |
||
1355 | end; |
||
1356 | |||
1357 | function TCustomZipMaster19.EraseFile(const FName: String; How: TZMDeleteOpts): Integer; |
||
1358 | begin |
||
1359 | Result := ZMUtils19.EraseFile(FName, How = htdFinal); |
||
1360 | end; |
||
1361 | |||
1362 | function TCustomZipMaster19.Extract: Integer; |
||
1363 | begin |
||
1364 | if Permitted then |
||
1365 | try |
||
1366 | Start; |
||
1367 | TZMDLLOpr(fWorker).Extract; |
||
1368 | Done; |
||
1369 | except |
||
1370 | on E: Exception do |
||
1371 | DoneBad(E); |
||
1372 | end; |
||
1373 | Result := ErrCode; |
||
1374 | end; |
||
1375 | |||
1376 | function TCustomZipMaster19.ExtractFileToStream(const FileName: String): |
||
1377 | TMemoryStream; |
||
1378 | begin |
||
1379 | Result := nil; |
||
1380 | if Permitted then |
||
1381 | try |
||
1382 | Start; |
||
1383 | TZMDLLOpr(fWorker).ExtractFileToStream(FileName); |
||
1384 | if SuccessCnt = 1 then |
||
1385 | Result := ZipStream; |
||
1386 | Done; |
||
1387 | except |
||
1388 | On E: Exception do |
||
1389 | DoneBad(E); |
||
1390 | end; |
||
1391 | end; |
||
1392 | |||
1393 | function TCustomZipMaster19.ExtractStreamToStream(InStream: TMemoryStream; |
||
1394 | OutSize: Longword): TMemoryStream; |
||
1395 | begin |
||
1396 | Result := nil; |
||
1397 | if Permitted then |
||
1398 | try |
||
1399 | Start; |
||
1400 | TZMDLLOpr(fWorker).ExtractStreamToStream(InStream, OutSize); |
||
1401 | if SuccessCnt = 1 then |
||
1402 | Result := ZipStream; |
||
1403 | Done; |
||
1404 | except |
||
1405 | On E: Exception do |
||
1406 | DoneBad(E); |
||
1407 | end; |
||
1408 | end; |
||
1409 | |||
1410 | function TCustomZipMaster19.Find(const fspec: TZMString; var idx: Integer): TZMDirEntry; |
||
1411 | var |
||
1412 | c: Integer; |
||
1413 | begin |
||
1414 | if idx < 0 then |
||
1415 | idx := -1; |
||
1416 | c := pred(Count); |
||
1417 | while idx < c do |
||
1418 | begin |
||
1419 | Inc(idx); |
||
1420 | Result := GetDirEntry(idx); |
||
1421 | if FileNameMatch(fspec, Result.FileName{$IFNDEF UNICODE}, UseUTF8{$ENDIF}) then |
||
1422 | exit; |
||
1423 | end; |
||
1424 | idx := -1; |
||
1425 | Result := nil; |
||
1426 | end; |
||
1427 | |||
1428 | function TCustomZipMaster19.ForEach(func: TZMForEachFunction; var Data): Integer; |
||
1429 | begin |
||
1430 | Result := 0; |
||
1431 | if Permitted then |
||
1432 | try |
||
1433 | Start; |
||
1434 | Result := TZMWorker(fWorker).ForEach(@func, Data); |
||
1435 | Done; |
||
1436 | except |
||
1437 | On E: Exception do |
||
1438 | DoneBad(E); |
||
1439 | end; |
||
1440 | end; |
||
1441 | |||
1442 | function TCustomZipMaster19.FullVersionString: String; |
||
1443 | begin |
||
1444 | Result := 'ZipMaster ' + Version; |
||
1445 | Result := Result + ', DLL ' + GetDLL_Version1(True); |
||
1446 | end; |
||
1447 | |||
1448 | function TCustomZipMaster19.GetActive: Boolean; |
||
1449 | begin |
||
1450 | Result := fActive <> 0; |
||
1451 | end; |
||
1452 | |||
1453 | function TCustomZipMaster19.GetAddPassword: String; |
||
1454 | var |
||
1455 | Resp: TmsgDlgBtn; |
||
1456 | begin |
||
1457 | Result := TZMDLLOpr(fWorker).GetAddPassword(Resp); |
||
1458 | if not Busy then |
||
1459 | Password := Result; |
||
1460 | end; |
||
1461 | |||
1462 | function TCustomZipMaster19.GetAddPassword(var Response: TmsgDlgBtn): String; |
||
1463 | begin |
||
1464 | Result := TZMDLLOpr(fWorker).GetAddPassword(Response); |
||
1465 | if not Busy then |
||
1466 | Password := Result; |
||
1467 | end; |
||
1468 | |||
1469 | function TCustomZipMaster19.GetBuild: Integer; |
||
1470 | begin |
||
1471 | Result := ZIPMASTERPRIV; |
||
1472 | end; |
||
1473 | |||
1474 | function TCustomZipMaster19.GetBusy: Boolean; |
||
1475 | begin |
||
1476 | Result := BusyFlag <> 0; |
||
1477 | end; |
||
1478 | |||
1479 | function TCustomZipMaster19.GetCancel: Boolean; |
||
1480 | begin |
||
1481 | Result := TZMWorker(fWorker).Cancel <> 0; |
||
1482 | end; |
||
1483 | |||
1484 | function TCustomZipMaster19.GetCount: Integer; |
||
1485 | begin |
||
1486 | if IsActive then |
||
1487 | Result := TZMWorker(fWorker).CentralDir.Count |
||
1488 | else |
||
1489 | Result := 0; |
||
1490 | end; |
||
1491 | |||
1492 | function TCustomZipMaster19.GetDirEntry(idx: Integer): TZMDirEntry; |
||
1493 | begin |
||
1494 | if IsActive then |
||
1495 | Result := TZMWorker(fWorker).CentralDir[idx] |
||
1496 | else |
||
1497 | Result := nil; |
||
1498 | end; |
||
1499 | |||
1500 | function TCustomZipMaster19.GetDirOnlyCnt: Integer; |
||
1501 | begin |
||
1502 | Result := TZMWorker(fWorker).CentralDir.DirOnlyCount; |
||
1503 | end; |
||
1504 | |||
1505 | function TCustomZipMaster19.GetDLL_Build: Integer; |
||
1506 | begin |
||
1507 | Result := 0; |
||
1508 | if Busy then |
||
1509 | Result := TZMDLLOpr(fWorker).DLL_Build |
||
1510 | else |
||
1511 | if Permitted then |
||
1512 | try |
||
1513 | Start; |
||
1514 | Result := TZMDLLOpr(fWorker).DLL_Build; |
||
1515 | Done; |
||
1516 | except |
||
1517 | On E: Exception do |
||
1518 | DoneBad(E); |
||
1519 | end; |
||
1520 | end; |
||
1521 | |||
1522 | function TCustomZipMaster19.GetDLL_Load: Boolean; |
||
1523 | begin |
||
1524 | if (csDesigning in ComponentState) or (csLoading in ComponentState) then |
||
1525 | Result := fDLLLoad |
||
1526 | else |
||
1527 | begin |
||
1528 | Result := TZMDLLOpr(fWorker).DLL_Load; |
||
1529 | fDLLLoad := Result; |
||
1530 | end; |
||
1531 | end; |
||
1532 | |||
1533 | function TCustomZipMaster19.GetDLL_Path: String; |
||
1534 | begin |
||
1535 | Result := ''; |
||
1536 | if Busy then |
||
1537 | Result := TZMDLLOpr(fWorker).DLL_Path |
||
1538 | else |
||
1539 | if Permitted then |
||
1540 | try |
||
1541 | Start; |
||
1542 | Result := TZMDLLOpr(fWorker).DLL_Path; |
||
1543 | Done; |
||
1544 | except |
||
1545 | On E: Exception do |
||
1546 | DoneBad(E); |
||
1547 | end; |
||
1548 | end; |
||
1549 | |||
1550 | function TCustomZipMaster19.GetDLL_Version: String; |
||
1551 | begin |
||
1552 | Result := GetDLL_Version1(False); |
||
1553 | end; |
||
1554 | |||
1555 | function TCustomZipMaster19.GetDLL_Version1(load: boolean): String; |
||
1556 | begin |
||
1557 | Result := ''; |
||
1558 | if Busy then |
||
1559 | Result := TZMDLLOpr(fWorker).DLL_Version(load) |
||
1560 | else |
||
1561 | if Permitted then |
||
1562 | try |
||
1563 | Start; |
||
1564 | Result := TZMDLLOpr(fWorker).DLL_Version(load); |
||
1565 | Done; |
||
1566 | except |
||
1567 | On E: Exception do |
||
1568 | DoneBad(E); |
||
1569 | end; |
||
1570 | end; |
||
1571 | |||
1572 | function TCustomZipMaster19.GetErrCode: Integer; |
||
1573 | begin |
||
1574 | Result := TZMWorker(fWorker).ErrCode; |
||
1575 | if fReentry then |
||
1576 | Result := Result or ZMReentry_Error |
||
1577 | else |
||
1578 | if not IsActive then |
||
1579 | Result := GE_Inactive; |
||
1580 | end; |
||
1581 | |||
1582 | function TCustomZipMaster19.GetErrMessage: TZMString; |
||
1583 | begin |
||
1584 | if IsActive then |
||
1585 | Result := TZMWorker(fWorker).ErrMessage |
||
1586 | else |
||
1587 | Result := ZipLoadStr(GE_Inactive); |
||
1588 | if fReentry then |
||
1589 | Result := TZMCore(fWorker).ZipFmtLoadStr(GE_WasBusy, [Result]); |
||
1590 | end; |
||
1591 | |||
1592 | function TCustomZipMaster19.GetExtrPassword: String; |
||
1593 | var |
||
1594 | Resp: TmsgDlgBtn; |
||
1595 | begin |
||
1596 | Result := TZMDLLOpr(fWorker).GetExtrPassword(Resp); |
||
1597 | if not Busy then |
||
1598 | Password := Result; |
||
1599 | end; |
||
1600 | |||
1601 | function TCustomZipMaster19.GetExtrPassword(var Response: TmsgDlgBtn): String; |
||
1602 | begin |
||
1603 | Result := TZMDLLOpr(fWorker).GetExtrPassword(Response); |
||
1604 | if not Busy then |
||
1605 | Password := Result; |
||
1606 | end; |
||
1607 | |||
1608 | function TCustomZipMaster19.GetDllErrCode: Integer; |
||
1609 | begin |
||
1610 | Result := TZMWorker(fWorker).DllErrCode; |
||
1611 | end; |
||
1612 | |||
1613 | function TCustomZipMaster19.GetIsSpanned: Boolean; |
||
1614 | begin |
||
1615 | Result := TZMWorker(fWorker).CentralDir.MultiDisk; |
||
1616 | end; |
||
1617 | |||
1618 | function TCustomZipMaster19.GetLanguage: string; |
||
1619 | begin |
||
1620 | if (csDesigning in ComponentState) or (csLoading in ComponentState) then |
||
1621 | Result := fLanguage |
||
1622 | else |
||
1623 | Result := GetZipMsgLanguage(0); |
||
1624 | end; |
||
1625 | |||
1626 | class function TCustomZipMaster19.GetLanguageInfo(Idx: Integer; info: Cardinal): String; |
||
1627 | begin |
||
1628 | Result := GetZipMsgLanguageInfo(Idx, info); |
||
1629 | end; |
||
1630 | |||
1631 | function TCustomZipMaster19.GetNoReadAux: Boolean; |
||
1632 | begin |
||
1633 | Result := FNoReadAux; |
||
1634 | if not ((csDesigning in ComponentState) or (csLoading in ComponentState)) then |
||
1635 | Result := Result or FAuxChanged; |
||
1636 | end; |
||
1637 | |||
1638 | function TCustomZipMaster19.GetOnLoadStr: TZMLoadStrEvent; |
||
1639 | begin |
||
1640 | Result := OnZMStr; |
||
1641 | end; |
||
1642 | |||
1643 | function TCustomZipMaster19.GetPassword(const DialogCaption, MsgTxt: String; |
||
1644 | pwb: TmsgDlgButtons; var ResultStr: String): TmsgDlgBtn; |
||
1645 | begin |
||
1646 | Result := TZMDLLOpr(fWorker).GetPassword(DialogCaption, MsgTxt, pwb, ResultStr); |
||
1647 | end; |
||
1648 | |||
1649 | function TCustomZipMaster19.GetSFXOffset: Integer; |
||
1650 | begin |
||
1651 | Result := TZMWorker(fWorker).CentralDir.SFXOffset; |
||
1652 | end; |
||
1653 | |||
1654 | function TCustomZipMaster19.GetSuccessCnt: Integer; |
||
1655 | begin |
||
1656 | Result := TZMWorker(fWorker).SuccessCnt; |
||
1657 | end; |
||
1658 | |||
1659 | function TCustomZipMaster19.GetTotalSizeToProcess: Int64; |
||
1660 | begin |
||
1661 | Result := TZMWorker(fWorker).TotalSizeToProcess; |
||
1662 | end; |
||
1663 | |||
1664 | function TCustomZipMaster19.GetVersion: String; |
||
1665 | begin |
||
1666 | Result := ZIPMASTERBUILD; |
||
1667 | end; |
||
1668 | |||
1669 | function TCustomZipMaster19.GetZipComment: String; |
||
1670 | begin |
||
1671 | Result := string(fZipComment); |
||
1672 | end; |
||
1673 | |||
1674 | function TCustomZipMaster19.GetZipEOC: Int64; |
||
1675 | begin |
||
1676 | Result := TZMWorker(fWorker).CentralDir.EOCOffset; |
||
1677 | end; |
||
1678 | |||
1679 | function TCustomZipMaster19.GetZipFileSize: Int64; |
||
1680 | begin |
||
1681 | Result := TZMWorker(fWorker).CentralDir.ZipFileSize; |
||
1682 | end; |
||
1683 | |||
1684 | function TCustomZipMaster19.GetZipSOC: Int64; |
||
1685 | begin |
||
1686 | Result := TZMWorker(fWorker).CentralDir.SOCOffset; |
||
1687 | end; |
||
1688 | |||
1689 | function TCustomZipMaster19.GetZipStream: TMemoryStream; |
||
1690 | begin |
||
1691 | Result := TZMDLLOpr(fWorker).ZipStream; |
||
1692 | end; |
||
1693 | |||
1694 | function TCustomZipMaster19.IndexOf(const FName: TZMString): Integer; |
||
1695 | var |
||
1696 | fn: TZMString; |
||
1697 | begin |
||
1698 | fn := FName; |
||
1699 | for Result := 0 to pred(Count) do |
||
1700 | if FileNameMatch(fn, GetDirEntry(Result).FileName{$IFNDEF UNICODE}, UseUTF8{$ENDIF}) then |
||
1701 | exit; |
||
1702 | Result := -1; |
||
1703 | end; |
||
1704 | |||
1705 | function TCustomZipMaster19.IsActive: boolean; |
||
1706 | begin |
||
1707 | Result := (FActive <> 0); |
||
1708 | if Result and ((csDesigning in ComponentState) or (csLoading in ComponentState)) then |
||
1709 | Result := False; // never Active while loading or designing |
||
1710 | end; |
||
1711 | |||
1712 | function TCustomZipMaster19.IsZipSFX(const SFXExeName: String): Integer; |
||
1713 | begin |
||
1714 | Result := 0; |
||
1715 | if Permitted then |
||
1716 | try |
||
1717 | Start; |
||
1718 | Result := TZMWorker(fWorker).IsZipSFX(SFXExeName); |
||
1719 | Done; |
||
1720 | except |
||
1721 | On E: Exception do |
||
1722 | DoneBad(E); |
||
1723 | end; |
||
1724 | if ErrCode <> 0 then |
||
1725 | Result := ErrCode; |
||
1726 | end; |
||
1727 | |||
1728 | function TCustomZipMaster19.List: Integer; |
||
1729 | begin |
||
1730 | if Permitted then |
||
1731 | try |
||
1732 | Start; |
||
1733 | TZMWorker(fWorker).List; |
||
1734 | Done; |
||
1735 | except |
||
1736 | On E: Exception do |
||
1737 | DoneBad(E); |
||
1738 | end; |
||
1739 | Result := ErrCode; |
||
1740 | end; |
||
1741 | |||
1742 | procedure TCustomZipMaster19.Loaded; |
||
1743 | begin |
||
1744 | inherited; |
||
1745 | if IsActive then |
||
1746 | DoDelays; |
||
1747 | end; |
||
1748 | |||
1749 | function TCustomZipMaster19.MakeTempFileName(const Prefix, Extension: String): String; |
||
1750 | begin |
||
1751 | Result := TZMWorker(fWorker).MakeTempFileName(Prefix, Extension); |
||
1752 | end; |
||
1753 | |||
1754 | function TCustomZipMaster19.Permitted: Boolean; |
||
1755 | begin |
||
1756 | Result := False; |
||
1757 | if IsActive then |
||
1758 | begin |
||
1759 | Inc(BusyFlag); |
||
1760 | if BusyFlag <> 1 then |
||
1761 | begin |
||
1762 | Dec(BusyFlag); |
||
1763 | ReEntered; |
||
1764 | end |
||
1765 | else |
||
1766 | Result := True; |
||
1767 | end; |
||
1768 | if Result then |
||
1769 | StateChanged(zsBusy); |
||
1770 | end; |
||
1771 | |||
1772 | function TCustomZipMaster19.QueryZip(const FName: TFileName): Integer; |
||
1773 | begin |
||
1774 | Result := ZMUtils19.QueryZip(FName); |
||
1775 | end; |
||
1776 | |||
1777 | function TCustomZipMaster19.ReadSpan(const InFileName: String; |
||
1778 | var OutFilePath: String): Integer; |
||
1779 | begin |
||
1780 | Result := 0; |
||
1781 | if Permitted then |
||
1782 | try |
||
1783 | Start; |
||
1784 | Result := TZMWorker(fWorker).ReadSpan(InFileName, OutFilePath, False); |
||
1785 | Done; |
||
1786 | except |
||
1787 | On E: Exception do |
||
1788 | DoneBad(E); |
||
1789 | end; |
||
1790 | end; |
||
1791 | |||
1792 | procedure TCustomZipMaster19.ReEntered; |
||
1793 | begin |
||
1794 | fReentry := True; |
||
1795 | if Verbose then |
||
1796 | TZMCore(fWorker).Diag('Re-entry'); |
||
1797 | end; |
||
1798 | |||
1799 | function TCustomZipMaster19.Rename(RenameList: TList; DateTime: Integer; How: |
||
1800 | TZMRenameOpts = htrDefault): Integer; |
||
1801 | begin |
||
1802 | if Permitted then |
||
1803 | try |
||
1804 | Start; |
||
1805 | TZMWorker(fWorker).Rename(RenameList, DateTime, How); |
||
1806 | Done; |
||
1807 | except |
||
1808 | On E: Exception do |
||
1809 | DoneBad(E); |
||
1810 | end; |
||
1811 | Result := ErrCode; |
||
1812 | end; |
||
1813 | |||
1814 | (* TCustomZipMaster19.SetActive |
||
1815 | sets the following values |
||
1816 | |||
1817 | 1 - active |
||
1818 | -1 - active in design/loading state (no Active functions allowed) |
||
1819 | *) |
||
1820 | procedure TCustomZipMaster19.SetActive(Value: Boolean); |
||
1821 | var |
||
1822 | was: Integer; |
||
1823 | begin |
||
1824 | if (csDesigning in ComponentState) or (csLoading in ComponentState) then |
||
1825 | begin |
||
1826 | if Value then |
||
1827 | fActive := 1// set but ignored |
||
1828 | else |
||
1829 | fActive := 0; |
||
1830 | exit; |
||
1831 | end; |
||
1832 | if Value <> (FActive > 0) then |
||
1833 | begin |
||
1834 | was := FActive; |
||
1835 | if Value then |
||
1836 | begin |
||
1837 | fActive := 1; |
||
1838 | // reject change active to inactive to active while busy |
||
1839 | if was = 0 then |
||
1840 | begin |
||
1841 | // changed to 'active' |
||
1842 | StateChanged(zsIdle); |
||
1843 | if (fDelaying <> 0) and (BusyFlag = 0) then |
||
1844 | DoDelays; |
||
1845 | end; |
||
1846 | end |
||
1847 | else |
||
1848 | begin |
||
1849 | if BusyFlag <> 0 then |
||
1850 | fActive := -3 // clear when 'done' |
||
1851 | else |
||
1852 | begin |
||
1853 | fActive := 0; // now inactive |
||
1854 | StateChanged(zsDisabled); |
||
1855 | end; |
||
1856 | end; |
||
1857 | end; |
||
1858 | end; |
||
1859 | |||
1860 | procedure TCustomZipMaster19.SetCancel(Value: Boolean); |
||
1861 | begin |
||
1862 | if Value <> Cancel then |
||
1863 | begin |
||
1864 | if Value then |
||
1865 | TZMWorker(fWorker).Cancel := DS_Canceled |
||
1866 | else |
||
1867 | TZMWorker(fWorker).Cancel := 0; |
||
1868 | end; |
||
1869 | end; |
||
1870 | |||
1871 | procedure TCustomZipMaster19.SetDLL_Load(const Value: Boolean); |
||
1872 | begin |
||
1873 | if Value <> fDLLLoad then |
||
1874 | if Permitted then |
||
1875 | try |
||
1876 | Start; |
||
1877 | TZMDLLOpr(fWorker).DLL_Load := Value; |
||
1878 | fDLLLoad := TZMDLLOpr(fWorker).DLL_Load; // true if it loaded |
||
1879 | Done; |
||
1880 | except |
||
1881 | On E: Exception do |
||
1882 | DoneBad(E); |
||
1883 | end |
||
1884 | else |
||
1885 | if not IsActive then //not Active |
||
1886 | begin |
||
1887 | fDLLLoad := Value; |
||
1888 | fDelaying := fDelaying or DelayingDLL; // delay until Active |
||
1889 | end; |
||
1890 | end; |
||
1891 | |||
1892 | procedure TCustomZipMaster19.SetEncodeAs(const Value: TZMEncodingOpts); |
||
1893 | begin |
||
1894 | if fEncodeAs <> Value then |
||
1895 | begin |
||
1896 | fEncodeAs := Value; |
||
1897 | if Permitted then |
||
1898 | begin |
||
1899 | try |
||
1900 | StartNoDll; // avoid loading the dll |
||
1901 | Done; |
||
1902 | except |
||
1903 | On E: Exception do |
||
1904 | DoneBad(E); |
||
1905 | end; |
||
1906 | end; |
||
1907 | end; |
||
1908 | end; |
||
1909 | |||
1910 | procedure TCustomZipMaster19.SetEncoding(const Value: TZMEncodingOpts); |
||
1911 | begin |
||
1912 | if fEncoding <> Value then |
||
1913 | begin |
||
1914 | fEncoding := Value; |
||
1915 | if Permitted then |
||
1916 | begin |
||
1917 | try |
||
1918 | StartNoDll; // avoid loading the dll |
||
1919 | Done; |
||
1920 | except |
||
1921 | On E: Exception do |
||
1922 | DoneBad(E); |
||
1923 | end; |
||
1924 | end; |
||
1925 | end; |
||
1926 | end; |
||
1927 | |||
1928 | procedure TCustomZipMaster19.SetEncoding_CP(Value: Cardinal); |
||
1929 | var |
||
1930 | info: TCPInfo; |
||
1931 | begin |
||
1932 | if not GetCPInfo(Value, info) then |
||
1933 | Value := 0; |
||
1934 | if fEncoding_CP <> Value then |
||
1935 | begin |
||
1936 | fEncoding_CP := Value; |
||
1937 | if Permitted then |
||
1938 | begin |
||
1939 | try |
||
1940 | StartNoDll; // avoid loading the dll |
||
1941 | Done; |
||
1942 | except |
||
1943 | On E: Exception do |
||
1944 | DoneBad(E); |
||
1945 | end; |
||
1946 | end; |
||
1947 | end; |
||
1948 | end; |
||
1949 | |||
1950 | procedure TCustomZipMaster19.SetErrCode(Value: Integer); |
||
1951 | begin |
||
1952 | if Stopped then |
||
1953 | TZMWorker(fWorker).ErrCode := Value; |
||
1954 | end; |
||
1955 | |||
1956 | procedure TCustomZipMaster19.SetFSpecArgs(const Value: TStrings); |
||
1957 | begin |
||
1958 | if Value <> fFSpecArgs then |
||
1959 | fFSpecArgs.Assign(Value); |
||
1960 | end; |
||
1961 | |||
1962 | procedure TCustomZipMaster19.SetFSpecArgsExcl(const Value: TStrings); |
||
1963 | begin |
||
1964 | if Value <> fFSpecArgsExcl then |
||
1965 | fFSpecArgsExcl.Assign(Value); |
||
1966 | end; |
||
1967 | |||
1968 | procedure TCustomZipMaster19.SetLanguage(const Value: string); |
||
1969 | begin |
||
1970 | if Permitted then |
||
1971 | try |
||
1972 | fLanguage := Value; |
||
1973 | Start; |
||
1974 | SetZipMsgLanguage(Value); |
||
1975 | Done; |
||
1976 | except |
||
1977 | On E: Exception do |
||
1978 | DoneBad(E); |
||
1979 | end |
||
1980 | else |
||
1981 | if not IsActive then //not Active |
||
1982 | begin |
||
1983 | fLanguage := Value; |
||
1984 | fDelaying := fDelaying or DelayingLanguage; // delay until Active |
||
1985 | end; |
||
1986 | end; |
||
1987 | |||
1988 | procedure TCustomZipMaster19.SetNoReadAux(const Value: Boolean); |
||
1989 | begin |
||
1990 | // must check changes in composite value |
||
1991 | if NoReadAux <> Value then |
||
1992 | begin |
||
1993 | FNoReadAux := Value; |
||
1994 | FAuxChanged := False; // reset |
||
1995 | end; |
||
1996 | end; |
||
1997 | |||
1998 | procedure TCustomZipMaster19.SetOnLoadStr(const Value: TZMLoadStrEvent); |
||
1999 | begin |
||
2000 | {ZMMsgStr19.}OnZMStr := Value; |
||
2001 | end; |
||
2002 | |||
2003 | procedure TCustomZipMaster19.SetPassword(const Value: String); |
||
2004 | begin |
||
2005 | if fPassword <> Value then |
||
2006 | begin |
||
2007 | fPassword := Value; |
||
2008 | if Busy then |
||
2009 | TZMDLLOpr(fWorker).Password := Value; // allow changes |
||
2010 | end; |
||
2011 | end; |
||
2012 | |||
2013 | procedure TCustomZipMaster19.SetPasswordReqCount(Value: Longword); |
||
2014 | begin |
||
2015 | if Value > 15 then |
||
2016 | Value := 15; |
||
2017 | if Value <> fPasswordReqCount then |
||
2018 | begin |
||
2019 | fPasswordReqCount := Value; |
||
2020 | if Busy then |
||
2021 | TZMDLLOpr(fWorker).PasswordReqCount := Value; // allow changes |
||
2022 | end; |
||
2023 | end; |
||
2024 | |||
2025 | procedure TCustomZipMaster19.SetPipes(const Value: TZMPipeList); |
||
2026 | begin |
||
2027 | // FPipes := Value; |
||
2028 | end; |
||
2029 | |||
2030 | procedure TCustomZipMaster19.SetSFXCaption(const Value: TZMString); |
||
2031 | begin |
||
2032 | if FSFXCaption <> Value then |
||
2033 | begin |
||
2034 | FSFXCaption := Value; |
||
2035 | AuxWasChanged; |
||
2036 | end; |
||
2037 | end; |
||
2038 | |||
2039 | procedure TCustomZipMaster19.SetSFXCommandLine(const Value: TZMString); |
||
2040 | begin |
||
2041 | if FSFXCommandLine <> Value then |
||
2042 | begin |
||
2043 | FSFXCommandLine := Value; |
||
2044 | AuxWasChanged; |
||
2045 | end; |
||
2046 | end; |
||
2047 | |||
2048 | procedure TCustomZipMaster19.SetSFXDefaultDir(const Value: String); |
||
2049 | begin |
||
2050 | if FSFXDefaultDir <> Value then |
||
2051 | begin |
||
2052 | FSFXDefaultDir := Value; |
||
2053 | AuxWasChanged; |
||
2054 | end; |
||
2055 | end; |
||
2056 | |||
2057 | procedure TCustomZipMaster19.SetSFXIcon(Value: TIcon); |
||
2058 | begin |
||
2059 | if Value <> fSFXIcon then |
||
2060 | begin |
||
2061 | if Assigned(Value) and not Value.Empty then |
||
2062 | begin |
||
2063 | if not Assigned(fSFXIcon) then |
||
2064 | fSFXIcon := TIcon.Create; |
||
2065 | fSFXIcon.Assign(Value); |
||
2066 | end |
||
2067 | else |
||
2068 | FreeAndNil(fSFXIcon); |
||
2069 | AuxWasChanged; |
||
2070 | end; |
||
2071 | end; |
||
2072 | |||
2073 | procedure TCustomZipMaster19.SetSFXMessage(const Value: TZMString); |
||
2074 | begin |
||
2075 | if FSFXMessage <> Value then |
||
2076 | begin |
||
2077 | FSFXMessage := Value; |
||
2078 | AuxWasChanged; |
||
2079 | end; |
||
2080 | end; |
||
2081 | |||
2082 | procedure TCustomZipMaster19.SetSFXOptions(const Value: TZMSFXOpts); |
||
2083 | begin |
||
2084 | if FSFXOptions <> Value then |
||
2085 | begin |
||
2086 | FSFXOptions := Value; |
||
2087 | AuxWasChanged; |
||
2088 | end; |
||
2089 | end; |
||
2090 | |||
2091 | procedure TCustomZipMaster19.SetSFXOverwriteMode(const Value: TZMOvrOpts); |
||
2092 | begin |
||
2093 | if FSFXOverwriteMode <> Value then |
||
2094 | begin |
||
2095 | FSFXOverwriteMode := Value; |
||
2096 | AuxWasChanged; |
||
2097 | end; |
||
2098 | end; |
||
2099 | |||
2100 | procedure TCustomZipMaster19.SetSFXRegFailPath(const Value: String); |
||
2101 | begin |
||
2102 | if FSFXRegFailPath <> Value then |
||
2103 | begin |
||
2104 | FSFXRegFailPath := Value; |
||
2105 | AuxWasChanged; |
||
2106 | end; |
||
2107 | end; |
||
2108 | |||
2109 | procedure TCustomZipMaster19.SetSpanOptions(const Value: TZMSpanOpts); |
||
2110 | begin |
||
2111 | if FSpanOptions <> Value then |
||
2112 | begin |
||
2113 | if (Value * [spNoVolumeName, spCompatName]) <> (FSpanOptions * [spNoVolumeName, spCompatName]) then |
||
2114 | AuxWasChanged; |
||
2115 | FSpanOptions := Value; |
||
2116 | end; |
||
2117 | end; |
||
2118 | |||
2119 | procedure TCustomZipMaster19.SetUseDirOnlyEntries(const Value: Boolean); |
||
2120 | begin |
||
2121 | if Value <> FUseDirOnlyEntries then |
||
2122 | begin |
||
2123 | FUseDirOnlyEntries := Value; |
||
2124 | if Permitted then |
||
2125 | begin |
||
2126 | try |
||
2127 | StartNoDll; // avoid loading the dll |
||
2128 | Done; |
||
2129 | except |
||
2130 | On E: Exception do |
||
2131 | DoneBad(E); |
||
2132 | end; |
||
2133 | end; |
||
2134 | end; |
||
2135 | end; |
||
2136 | |||
2137 | {$IFNDEF UNICODE} |
||
2138 | procedure TCustomZipMaster19.SetUseUTF8(const Value: Boolean); |
||
2139 | begin |
||
2140 | if Value <> FUseUTF8 then |
||
2141 | begin |
||
2142 | FUseUTF8 := Value; |
||
2143 | if Permitted then |
||
2144 | begin |
||
2145 | try |
||
2146 | StartNoDll; // avoid loading the dll |
||
2147 | Done; |
||
2148 | except |
||
2149 | On E: Exception do |
||
2150 | DoneBad(E); |
||
2151 | end; |
||
2152 | end; |
||
2153 | end; |
||
2154 | end; |
||
2155 | {$ENDIF} |
||
2156 | |||
2157 | procedure TCustomZipMaster19.SetVersion(const Value: String); |
||
2158 | begin |
||
2159 | // Read only |
||
2160 | end; |
||
2161 | |||
2162 | procedure TCustomZipMaster19.SetWriteOptions(const Value: TZMWriteOpts); |
||
2163 | begin |
||
2164 | if FWriteOptions <> Value then |
||
2165 | begin |
||
2166 | if (zwoDiskSpan in Value) <> (zwoDiskSpan in FWriteOptions) then |
||
2167 | AuxWasChanged; |
||
2168 | FWriteOptions := Value; |
||
2169 | if not Busy then |
||
2170 | TZMCore(fWorker).WriteOptions := Value; |
||
2171 | end; |
||
2172 | end; |
||
2173 | |||
2174 | procedure TCustomZipMaster19.SetZipComment(const Value: String); |
||
2175 | var |
||
2176 | v: AnsiString; |
||
2177 | begin |
||
2178 | v := AnsiString(Value); |
||
2179 | if v <> fZipComment then |
||
2180 | if Permitted then |
||
2181 | try |
||
2182 | fZipComment := v; |
||
2183 | Start; |
||
2184 | TZMWorker(fWorker).Set_ZipComment(v); |
||
2185 | Done; |
||
2186 | except |
||
2187 | On E: Exception do |
||
2188 | DoneBad(E); |
||
2189 | end |
||
2190 | else |
||
2191 | if not IsActive then //not Active |
||
2192 | begin |
||
2193 | fZipComment := v; |
||
2194 | fDelaying := fDelaying or DelayingComment; |
||
2195 | end; |
||
2196 | end; |
||
2197 | |||
2198 | procedure TCustomZipMaster19.SetZipFileName(const Value: String); |
||
2199 | begin |
||
2200 | if Value <> fZipFileName then |
||
2201 | if Permitted then |
||
2202 | try |
||
2203 | fZipFileName := Value; |
||
2204 | Start; |
||
2205 | TZMWorker(fWorker).Set_ZipFileName(Value, zloFull); |
||
2206 | Done; |
||
2207 | except |
||
2208 | On E: Exception do |
||
2209 | DoneBad(E); |
||
2210 | end |
||
2211 | else |
||
2212 | if not IsActive then //not Active |
||
2213 | begin |
||
2214 | fZipFileName := Value; |
||
2215 | fDelaying := fDelaying or DelayingFileName; |
||
2216 | end; |
||
2217 | end; |
||
2218 | |||
2219 | procedure TCustomZipMaster19.ShowExceptionError(const ZMExcept: EZMException); |
||
2220 | begin |
||
2221 | TZMWorker(fWorker).ShowExceptionError(ZMExcept); |
||
2222 | end; |
||
2223 | |||
2224 | (*? TCustomZipMaster19.ShowZipFmtMessage |
||
2225 | 1.79 added |
||
2226 | *) |
||
2227 | procedure TCustomZipMaster19.ShowZipFmtMessage(Id: Integer; const Args: array of const); |
||
2228 | begin |
||
2229 | TZMWorker(fWorker).ShowZipFmtMsg(Id, Args, True); |
||
2230 | end; |
||
2231 | |||
2232 | procedure TCustomZipMaster19.ShowZipMessage(Ident: Integer; const UserStr: String); |
||
2233 | begin |
||
2234 | TZMWorker(fWorker).ShowZipMessage(Ident, UserStr); |
||
2235 | end; |
||
2236 | |||
2237 | procedure TCustomZipMaster19.Start; |
||
2238 | var |
||
2239 | z: TZMDLLOpr; |
||
2240 | begin |
||
2241 | fReentry := False; |
||
2242 | z := fWorker as TZMDLLOpr; |
||
2243 | z.StartUp; |
||
2244 | z.DLLDirectory := DLLDirectory; |
||
2245 | z.DLL_Load := fDLLLoad; |
||
2246 | z.NoReadAux := fNoReadAux; |
||
2247 | z.AuxChanged := fAuxChanged; |
||
2248 | end; |
||
2249 | |||
2250 | procedure TCustomZipMaster19.StartNoDll; |
||
2251 | var |
||
2252 | z: TZMWorker; |
||
2253 | begin |
||
2254 | fReentry := False; |
||
2255 | z := fWorker as TZMWorker; |
||
2256 | z.StartUp; |
||
2257 | z.NoReadAux := fNoReadAux; |
||
2258 | z.AuxChanged := fAuxChanged; |
||
2259 | end; |
||
2260 | |||
2261 | procedure TCustomZipMaster19.StartWaitCursor; |
||
2262 | begin |
||
2263 | if FCurWaitCount = 0 then |
||
2264 | begin |
||
2265 | FSaveCursor := Screen.Cursor; |
||
2266 | Screen.Cursor := crHourGlass; |
||
2267 | end; |
||
2268 | inc(FCurWaitCount); |
||
2269 | end; |
||
2270 | |||
2271 | procedure TCustomZipMaster19.StateChanged(newState: TZMStates); |
||
2272 | var |
||
2273 | NoCursor: boolean; |
||
2274 | begin |
||
2275 | NoCursor := NotMainThread; |
||
2276 | if assigned(OnStateChange) then |
||
2277 | OnStateChange(self, newState, NoCursor); |
||
2278 | if not NoCursor then |
||
2279 | begin |
||
2280 | if newState = zsBusy then |
||
2281 | StartWaitCursor |
||
2282 | else |
||
2283 | StopWaitCursor; |
||
2284 | end; |
||
2285 | end; |
||
2286 | |||
2287 | function TCustomZipMaster19.Stopped: Boolean; |
||
2288 | begin |
||
2289 | if BusyFlag = 0 then |
||
2290 | Result := True |
||
2291 | else |
||
2292 | begin |
||
2293 | Result := False; |
||
2294 | ReEntered; |
||
2295 | end; |
||
2296 | end; |
||
2297 | |||
2298 | procedure TCustomZipMaster19.StopWaitCursor; |
||
2299 | begin |
||
2300 | if FCurWaitCount > 0 then |
||
2301 | begin |
||
2302 | dec(FCurWaitCount); |
||
2303 | if FCurWaitCount < 1 then |
||
2304 | Screen.Cursor := FSaveCursor; |
||
2305 | end; |
||
2306 | end; |
||
2307 | |||
2308 | function TCustomZipMaster19.TheErrorCode(errCode: Integer): Integer; |
||
2309 | begin |
||
2310 | Result := errCode and (ZMReentry_Error - 1); |
||
2311 | end; |
||
2312 | |||
2313 | function TCustomZipMaster19.Undeflate(OutStream, InStream: TStream; Length: |
||
2314 | Int64; var Method: TZMDeflates; var CRC: Cardinal): Integer; |
||
2315 | begin |
||
2316 | if Permitted then |
||
2317 | try |
||
2318 | Start; |
||
2319 | TZMDLLOpr(fWorker).Undeflate(OutStream, InStream, Length, Method, CRC); |
||
2320 | Done; |
||
2321 | except |
||
2322 | on E: Exception do |
||
2323 | DoneBad(E); |
||
2324 | end; |
||
2325 | Result := ErrCode; |
||
2326 | end; |
||
2327 | |||
2328 | function TCustomZipMaster19.WriteSpan(const InFileName, OutFileName: String): Integer; |
||
2329 | begin |
||
2330 | Result := 0; |
||
2331 | if Permitted then |
||
2332 | try |
||
2333 | Start; |
||
2334 | Result := TZMWorker(fWorker).WriteSpan(InFileName, OutFileName, False); |
||
2335 | Done; |
||
2336 | except |
||
2337 | On E: Exception do |
||
2338 | DoneBad(E); |
||
2339 | end; |
||
2340 | if ErrCode <> 0 then |
||
2341 | Result := ErrCode; |
||
2342 | end; |
||
2343 | |||
2344 | function TCustomZipMaster19.ZipLoadStr(Id: Integer): string; |
||
2345 | begin |
||
2346 | if IsActive then |
||
2347 | Result := TZMCore(fWorker).ZipLoadStr(Id) |
||
2348 | else |
||
2349 | Result := LoadZipStr(Id); |
||
2350 | end; |
||
2351 | |||
2352 | end. |