VPatch 2.1:
* Added argument checking and error handling to GenPat. Now returns exit codes as well to indicate success/failure (and the reason for failure). Only GenPat has changed in this version compared to 2.0 final. * Bug Fix: GenPat no longer gives an Access Violation when attempting to patch a file smaller than 64 bytes into a file larger than 64 bytes. git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3318 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
14f2e625e4
commit
b7c7a31b3e
5 changed files with 314 additions and 108 deletions
|
@ -32,6 +32,8 @@ unit PatchGenerator;
|
|||
|
||||
What's new
|
||||
----------
|
||||
2.1 20031219 Koen Added error checking to CreatePatch, returns
|
||||
negative numbers when there are errors.
|
||||
2.0 20030811 Koen Initial documentation
|
||||
}
|
||||
|
||||
|
@ -141,8 +143,8 @@ var
|
|||
retTO: Integer;
|
||||
noN: Integer;
|
||||
begin
|
||||
fsSource:=TFileStream.Create(SourceFileName,fmOpenRead);
|
||||
fsTarget:=TFileStream.Create(TargetFileName,fmOpenRead);
|
||||
fsSource:=TFileStream.Create(SourceFileName,fmOpenRead+fmShareDenyNone);
|
||||
fsTarget:=TFileStream.Create(TargetFileName,fmOpenRead+fmShareDenyNone);
|
||||
fm:=TMemoryStream.Create;
|
||||
|
||||
SetLength(PRay,INIT_BLOCK_COUNT);
|
||||
|
@ -150,7 +152,14 @@ begin
|
|||
|
||||
//Load those files into memory!
|
||||
SourceSize:=fsSource.Size;
|
||||
GetMem(Source,SourceSize);
|
||||
try
|
||||
GetMem(Source,SourceSize);
|
||||
except
|
||||
on EOutOfMemory do begin
|
||||
Result:=-2; // not enough memory for source file
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
fm.CopyFrom(fsSource,SourceSize);
|
||||
Move(fm.Memory^,Source^,SourceSize);
|
||||
SourceCRC:=FileCRC(fsSource);
|
||||
|
@ -158,13 +167,28 @@ begin
|
|||
|
||||
fm.Clear;
|
||||
TargetSize:=fsTarget.Size;
|
||||
GetMem(Target,TargetSize);
|
||||
try
|
||||
GetMem(Target,TargetSize);
|
||||
except
|
||||
on EOutOfMemory do begin
|
||||
FreeMem(Source,SourceSize);
|
||||
Result:=-3; // not enough memory for target file
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
fm.CopyFrom(fsTarget,TargetSize);
|
||||
Move(fm.Memory^,Target^,TargetSize);
|
||||
TargetCRC:=FileCRC(fsTarget);
|
||||
fsTarget.Free;
|
||||
fm.Free;
|
||||
|
||||
if(SourceCRC = TargetCRC) then begin
|
||||
FreeMem(Source,SourceSize);
|
||||
FreeMem(Target,TargetSize);
|
||||
Result:=-1;
|
||||
Exit;
|
||||
end;
|
||||
|
||||
PRay[0].TargetOffset:=0;
|
||||
PRay[0].SourceOffset:=0;
|
||||
PRay[0].Size:=0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue