mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 17:06:14 +02:00
* fix range errors
git-svn-id: trunk@7520 -
This commit is contained in:
parent
e2ff152eef
commit
fe1131ae04
@ -908,12 +908,13 @@ Procedure TZipper.GetFileInfo;
|
|||||||
|
|
||||||
Var
|
Var
|
||||||
Info : TSearchRec;
|
Info : TSearchRec;
|
||||||
I : Word;
|
I : Longint;
|
||||||
NewNode : TZipItem;
|
NewNode : TZipItem;
|
||||||
|
|
||||||
|
|
||||||
Begin
|
Begin
|
||||||
For I := 0 to FFiles.Count-1 do
|
For I := 0 to FFiles.Count-1 do
|
||||||
|
begin
|
||||||
If FindFirst(FFiles[I], STDATTR, Info)=0 then
|
If FindFirst(FFiles[I], STDATTR, Info)=0 then
|
||||||
try
|
try
|
||||||
NewNode:=TZipItem.Create;
|
NewNode:=TZipItem.Create;
|
||||||
@ -925,6 +926,7 @@ Begin
|
|||||||
finally
|
finally
|
||||||
FindClose(Info);
|
FindClose(Info);
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TZipper.OpenOutput;
|
Procedure TZipper.OpenOutput;
|
||||||
@ -972,17 +974,20 @@ Begin
|
|||||||
Crc32 := 0;
|
Crc32 := 0;
|
||||||
Compressed_Size := 0;
|
Compressed_Size := 0;
|
||||||
Uncompressed_Size := Item.Size;
|
Uncompressed_Size := Item.Size;
|
||||||
FileName_Length := Length(Item.Name);
|
FileName_Length := 0;
|
||||||
Extra_Field_Length := 0;
|
Extra_Field_Length := 0;
|
||||||
end ;
|
end ;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
|
||||||
Function TZipper.UpdateZipHeader(Item : TZipItem; FZip : TStream; ACRC : LongWord; AMethod : Word) : Boolean;
|
Function TZipper.UpdateZipHeader(Item : TZipItem; FZip : TStream; ACRC : LongWord; AMethod : Word) : Boolean;
|
||||||
|
var
|
||||||
|
ZFileName : ShortString;
|
||||||
Begin
|
Begin
|
||||||
|
ZFileName:=Item.Path+Item.Name;
|
||||||
With LocalHdr do
|
With LocalHdr do
|
||||||
begin
|
begin
|
||||||
|
FileName_Length := Length(ZFileName);
|
||||||
Compressed_Size := FZip.Size;
|
Compressed_Size := FZip.Size;
|
||||||
Crc32 := ACRC;
|
Crc32 := ACRC;
|
||||||
Compress_method:=AMethod;
|
Compress_method:=AMethod;
|
||||||
@ -994,7 +999,7 @@ Begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
FOutFile.WriteBuffer(LocalHdr,SizeOf(LocalHdr));
|
FOutFile.WriteBuffer(LocalHdr,SizeOf(LocalHdr));
|
||||||
FOutFile.WriteBuffer(Item.Name[1],Length(Item.Name));
|
FOutFile.WriteBuffer(ZFileName[1],Length(ZFileName));
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
|
||||||
@ -1064,7 +1069,7 @@ end;
|
|||||||
Procedure TZipper.ZipOneFile(Item : TZipItem);
|
Procedure TZipper.ZipOneFile(Item : TZipItem);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
CRC : Integer;
|
CRC : LongWord;
|
||||||
ZMethod : Word;
|
ZMethod : Word;
|
||||||
ZipStream : TStream;
|
ZipStream : TStream;
|
||||||
TmpFileName : String;
|
TmpFileName : String;
|
||||||
@ -1114,21 +1119,29 @@ Procedure TZipper.ZipAllFiles;
|
|||||||
Var
|
Var
|
||||||
Item : TZipItem;
|
Item : TZipItem;
|
||||||
I : Integer;
|
I : Integer;
|
||||||
|
filecnt : integer;
|
||||||
Begin
|
Begin
|
||||||
|
if FFiles.Count=0 then
|
||||||
|
exit;
|
||||||
FZipping:=True;
|
FZipping:=True;
|
||||||
Try
|
Try
|
||||||
GetFileInfo;
|
GetFileInfo;
|
||||||
OpenOutput;
|
OpenOutput;
|
||||||
Try
|
Try
|
||||||
|
filecnt:=0;
|
||||||
For I:=0 to FFiles.Count-1 do
|
For I:=0 to FFiles.Count-1 do
|
||||||
begin
|
begin
|
||||||
Item:=FFiles.Objects[i] as TZipItem;
|
Item:=FFiles.Objects[i] as TZipItem;
|
||||||
ZipOneFile(Item);
|
if assigned(Item) then
|
||||||
|
begin
|
||||||
|
ZipOneFile(Item);
|
||||||
|
inc(filecnt);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
BuildZipDirectory;
|
if filecnt>0 then
|
||||||
Finally
|
BuildZipDirectory;
|
||||||
CloseOutput;
|
finally
|
||||||
|
CloseOutput;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
FZipping:=False;
|
FZipping:=False;
|
||||||
|
Loading…
Reference in New Issue
Block a user