📄 kpzipobj.pas
字号:
Result^.offset_zip64_end_central := 0;
Result^.num_disks := 1;
end;
function TEndCentral.FZip64EOC_Instance: zip64_end_of_centralPtr;
begin
if (FZip64EOC = nil) then
FZip64EOC := GetNewFZip64EOC;
Result := FZip64EOC;
end;
function TEndCentral.FZip64EOCL_Instance: zip64_end_of_central_locatorPtr;
begin
if (FZip64EOCL = nil) then
FZip64EOCL := GetNewFZip64EOCL;
Result := FZip64EOCL;
end;
{***************** TSortedZip Methods *******************}
constructor TSortedZip.Create(WithDuplicates: TDuplicates);
begin
inherited Create(WithDuplicates);
SortMode := ByNone;
FIsZip64 := False;
end;
Function TSortedZip.AddObject(Item: tObject): Integer;
var
entry: TZipHeaderInfo;
begin
Result := inherited AddObject(Item);
if (not FIsZip64) then
begin
entry := Item as TZipHeaderInfo;
if (entry.FZip64_Extended <> nil)
then FIsZip64 := True;
end;
end;
function TSortedZip.Compare(Key1, Key2: Pointer): Integer;
var
K1: TZipHeaderInfo absolute Key1;
K2: TZipHeaderInfo absolute Key2;
tmpDateTime1, tmpDateTime2: TDateTime;
tmpSize: LongInt;
begin
case FSortMode of
ByName:
Result := CompareText(K1.directory + K1.filename, K2.directory + K2.filename);
ByFileName:
Result := CompareText(K1.filename, K2.filename);
ByDirectoryName:
Result := CompareText(K1.Directory, K2.directory);
ByDate:
begin
try
tmpDateTime1 := FileDateToDateTime(K1.last_mod_file_date_time);
except
tmpDateTime1 := 0;
end;
try
tmpDateTime2 := FileDateToDateTime(K2.last_mod_file_date_time);
except
tmpDateTime2 := 0;
end;
if (tmpDateTime2 > tmpDateTime1) then
Result := 1
else
Result := -1;
end;
ByCompressedSize:
begin
tmpSize := K2.compressed_size - K1.compressed_size;
if (tmpSize > 0) then
Result := 1
else
Result := -1;
end;
ByUnCompressedSize:
begin
tmpSize := K2.uncompressed_size - K1.uncompressed_size;
if (tmpSize > 0) then
Result := 1
else
Result := -1;
end;
ByRate:
Result := CBigRate(K2.uncompressed_size, K2.compressed_size) -
CBigRate(K1.uncompressed_size, K1.compressed_size);
ByNone:
begin
Result := K1.disk_number_start - K2.disk_number_start;
if Result = 0 then { modified 3/8/98 for 2.03 }
begin { this fixed the duplicate object bug }
if K1.relative_offset > K2.relative_offset then
Result := 1
else if K1.relative_offset = K2.relative_offset then
Result := 0
else
Result := -1;
end;
end;
else
Result := -1;
end;
{
If Result = 0 then
Result := -1;
}
end;
{$IFDEF KPDEMO}
function DRun: Boolean;
const
A1: array[0..12] of char = 'TApplication'#0;
A2: array[0..15] of char = 'TAlignPalette'#0;
{A3: array[0..18] of char = 'TPropertyInspector'#0;}
A4: array[0..11] of char = 'TAppBuilder'#0;
{$IFDEF WIN32}
{$IFDEF VER130}
{$IFDEF ISBCB5}
T1: array[0..15] of char = 'C++Builder 5'#0;
{$ENDIF}
{$IFDEF ISDELPHI5}
T1: array[0..15] of char = 'Delphi 5'#0;
{$ENDIF}
{$ENDIF}
{$IFDEF VER140}
{$IFDEF ISDELPHI6}
T1: array[0..15] of char = 'Delphi 6'#0;
{$ENDIF}
{$IFDEF ISBCB6}
T1: array[0..15] of char = 'C++Builder 6'#0;
{$ENDIF}
{$ENDIF}
{$IFDEF VER150}
T1: array[0..15] of char = 'Delphi 7'#0;
{$ENDIF}
{$IFDEF VER170}
T1: array[0..15] of char = 'Delphi 2005'#0;
{$ENDIF}
{$IFDEF VER120}
T1: array[0..15] of char = 'Delphi 4'#0;
{$ENDIF}
{$IFDEF VER100}
T1: array[0..15] of char = 'Delphi 3'#0;
{$ENDIF}
{$IFDEF VER90}
T1: array[0..15] of char = 'Delphi 2.0'#0;
{$ENDIF}
{$IFDEF VER93}
T1: array[0..15] of char = 'C++Builder'#0;
{$ENDIF}
{$IFDEF VER110}
T1: array[0..15] of char = 'C++Builder'#0;
{$ENDIF}
{$IFDEF VER125}
T1: array[0..15] of char = 'C++Builder 4'#0;
{$ENDIF}
{$ELSE}
T1: array[0..15] of char = 'Delphi'#0;
{$ENDIF}
begin
Result := (FindWindow(A1, T1) <> 0) and
(FindWindow(A2, nil) <> 0) and
{(FindWindow(A3,nil)<>0) and}
(FindWindow(A4, nil) <> 0);
end;
{$ENDIF}
procedure setZipSignatures(csig, lsig, esig: LongInt);
begin
if csig = 0 then
CENTSIG := DEF_CENTSIG
else
CENTSIG := csig;
if lsig = 0 then
LOCSIG := DEF_LOCSIG
else
LOCSIG := lsig;
if esig = 0 then
ENDSIG := DEF_ENDSIG
else
ENDSIG := esig;
ZIP64EOC := DEF_ZIP64ENDSIG;
ZIP64EOCL := DEF_ZIP64LOCATOR;
{
DEF_CENTSIG = $02014b50;
DEF_LOCSIG = $04034b50;
DEF_ENDSIG = $06054b50;
DEF_ZIP64ENDSIG = $06064b50;
DEF_ZI64LOCATOR = $07064b50;
}
LOC4 := LOBYTE(LOWORD(LOCSIG)); { $50; Last byte of LOCSIG }
LOC3 := HIBYTE(LOWORD(LOCSIG)); { $4b; 3rd byte of LOCSIG }
LOC2 := LOBYTE(HIWORD(LOCSIG)); { $03; 2nd byte of LOCSIG }
LOC1 := HIBYTE(HIWORD(LOCSIG)); { $04; 1st byte of LOCSIG }
END4 := LOBYTE(LOWORD(ENDSIG)); { $50; Last byte of ENDSIG }
end;
(*************************************************)
initialization
(*************************************************)
setZipSignatures(0, 0, 0);
{ $Id: kpZipObj.pas,v 1.1 2001-08-12 17:30:40-04 kp Exp kp $ }
{ $Log: 10062: kpZipObj.pas
{
{ Rev 1.0 8/14/2005 1:10:10 PM KLB Version: VCLZip Pro 3.06
{ Initial load of VCLZip Pro on this computer
}
{
{ Rev 1.9.1.6 4/2/2005 4:58:20 PM Supervisor Version: VCLZip 3.X
{ ZLib 1.2.2 default
{ Fixed ZLibDecompressStream
{ Delphi 2005 compatible
{ Other assorted bug fixes
}
{
{ Rev 1.9.1.5 7/28/2004 8:54:30 PM Supervisor Version: VCLZip 3.X
{ TOEMConvert
}
{
{ Rev 1.9.1.4 7/27/2004 11:04:26 PM Supervisor Version: VCLZip 3.X
{ Added WinZip ansi/oem compatability
}
{
{ Rev 1.9.1.3 7/22/2004 12:41:02 PM Supervisor Version: VCLZip 3.X
{ Fixed greater than 65K files problem
{ Fixed problem when CD spanned parts
{ Fixed OperationMode settings
{ Fixed Zip64 EOCL
}
{
{ Rev 1.9.1.2 7/19/2004 7:56:04 PM Supervisor Version: VCLZip 3.X
{ Fixed problem with GetSize.
}
{
{ Rev 1.9.1.1 1/5/2004 11:31:06 PM Supervisor Version: VCLZip 3.X
{ Version_needed_to_extract
}
{
{ Rev 1.9.1.0 11/1/2003 1:30:02 PM Supervisor Version: VCLZip 3.X
{ Remove Bogus Headers
}
{
{ Rev 1.9 10/15/2003 10:23:56 PM Supervisor Version: VCLZip 3.X
{ Add return value to overloaded AddObject.
}
{
{ Rev 1.8 10/15/2003 5:50:24 PM Supervisor Version: VCLZip 3.X
{ Add isZip64 property to TSortedZip
}
{
{ Rev 1.7 5/20/2003 10:46:22 PM Kevin Version: VCLZip3.00z64c
}
{
{ Rev 1.6 5/20/2003 4:51:32 PM Supervisor
{ fixed hints and warnings. And fixed check for whether zip64eoc is needed.
}
{
{ Rev 1.5 5/19/2003 10:45:04 PM Supervisor
{ After fixing streams. VCLZip still uses ErrorRpt. Also added setting of
{ capacity on the sorted containers to alleviate the memory problem caused by
{ growing array.
}
{
{ Rev 1.3 5/6/2003 6:11:40 PM Supervisor
}
{
{ Rev 1.2 5/3/2003 6:33:32 PM Supervisor
}
{
{ Rev 1.1 3/31/2003 6:17:54 PM Supervisor Version: VCLZip 3.00 Beta
}
{
{ Rev 1.0 10/15/2002 8:15:22 PM Supervisor
}
{
{ Rev 1.3 9/7/2002 8:48:48 AM Supervisor
{ Last modifications for FILE_INT
}
{
{ Rev 1.2 9/3/2002 11:32:46 PM Supervisor
{ Mod for FILE_INT
}
{
{ Rev 1.1 9/3/2002 10:48:06 PM Supervisor
{ Mod for FILE_INT
}
{
{ Rev 1.0 9/3/2002 8:16:54 PM Supervisor
}
{ Revision 1.1 2001-08-12 17:30:40-04 kp
{ Initial revision
{
{ Revision 1.28 2000-12-16 16:50:07-05 kp
{ 2.21 Final Release 12/12/00
{
{ Revision 1.27 2000-06-04 15:59:56-04 kp
{ - Fixed typo in creation of LOC header values.
{ - Changed so FileZipCommentPos is based on end of record instead of end of file.
{ - Reformatted code
{
{ Revision 1.26 2000-05-21 18:44:50-04 kp
{ - Moved declaration of signature globals to here.
{ - Modified setZipSignatures to set default values when passed 0's as values.
{
{ Revision 1.25 2000-05-13 17:07:48-04 kp
{ - Added setZipSignatures procedure
{ - Added code to initialize signatures to default values in Initialization section
{
{ Revision 1.24 1999-11-09 19:41:40-05 kp
{ - Modified to correctly handle extra fields in headers
{ - Removed check for Object Inspector Window in IDE Check
{
{ Revision 1.23 1999-10-24 09:32:11-04 kp
{ - Changed ReadCentralFromStream so the stream passed in is a var parameter.
{
{ Revision 1.22 1999-10-17 12:00:50-04 kp
{ - Changed min and max to kpmin and kpmax
{
{ Revision 1.21 1999-09-16 20:07:56-04 kp
{ - Moved defines to KPDEFS.INC
{
{ Revision 1.20 1999-09-14 21:33:46-04 kp
{ - Added D5 compatibility conditionals
{
{ Revision 1.19 1999-08-25 19:04:01-04 kp
{ - Fixes for D1
{
{ Revision 1.18 1999-08-25 18:00:47-04 kp
{ - Can now open a zero length file as an empty archive.
{
{ Revision 1.17 1999-07-06 19:58:51-04 kp
{ - Added Selected to assign and initialization methods
{
{ Revision 1.16 1999-07-05 11:25:06-04 kp
{ <>
{
{ Revision 1.15 1999-06-27 13:56:10-04 kp
{ - Added the Selected property to the TZipHeaderInfo class
{
{ Revision 1.14 1999-06-06 19:56:57-04 kp
{ - Slight fix for the new sig consts
{
{ Revision 1.13 1999-06-02 10:26:29-04 kp
{ - Added constants for header signatures
{
{ Revision 1.12 1999-06-01 21:53:58-04 kp
{ - Added to the size of the buffer for looking for the end of central record for 32bit.
{
{ Revision 1.11 1999-04-24 21:16:15-04 kp
{ - Fixed small problem with IDE check in BCB4
{
{ Revision 1.10 1999-03-30 19:43:22-05 kp
{ - Modified so that defining MAKESMALL will create a much smaller component.
{
{ Revision 1.9 1999-03-22 17:30:20-05 kp
{ - moved kplib to USES list in implementation
{
{ Revision 1.8 1999-03-22 17:21:16-05 kp
{ - Moved comments to bottom
{
{ Revision 1.7 1999-03-20 11:46:42-05 kp
{ - Fixed problem where setting ZipComment to '' caused an access violation
{
{ Revision 1.6 1999-03-14 21:33:05-05 kp
{ - Made some mods for BCB4
{
{ Revision 1.5 1999-02-17 17:24:36-05 kp
{ Moved AssignTo methods to public instead of private for TZipHeaderInfo and TEndCentral
{
{ Revision 1.4 1999-02-08 21:42:50-05 kp
{ Version 2.17
{
{ Revision 1.3 1999-01-25 19:12:59-05 kp
{ Modifed compiler directives
{ }
{ 7/9/98 6:47:20 PM
{ Version 2.13
{
{ 1) New property ResetArchiveBitOnZip causes each file's
{ archive bit to be turned off after being zipped.
{
{ 2) New Property SkipIfArchiveBitNotSet causes files
{ who's archive bit is not set to be skipped during zipping
{ operations.
{
{ 3) A few modifications were made to allow more
{ compatibility with BCB 1.
{
{ 4) Modified how directory information is used when
{ comparing filenames to be unzipped. Now it is always
{ used.
}
{
{ Mon 27 Apr 1998 17:30:52
{ Added call to new GoodTimeStamp.
}
{
{ Tue 10 Mar 1998 20:36:37
{ Modified the Compare procedure for the ByNone sort
{ because in Delphi 1 the integer wasn't big enough to
{ handle the difference operation which caused "duplicate
{ object" errors.
}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -