home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 March / CMCD0304.ISO / Software / Freeware / Programare / nullsoft / nsis20.exe / Contrib / VPatch / Source / GUI / DLLWrapper.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2003-08-11  |  1.4 KB  |  54 lines

  1. unit DLLWrapper;
  2.  
  3. interface
  4.  
  5. uses Classes, SysUtils;
  6.  
  7.   function DoGenerate(const Source, Target: String; Stream: TStream; Config: String): Integer; forward;
  8.  
  9. implementation
  10.  
  11. uses PatchGenerator;
  12.  
  13. function DoGenerate(const Source, Target: String; Stream: TStream; Config: String): Integer;
  14. var
  15.   PG: TPatchGenerator;
  16.   a: Integer;
  17. begin
  18.   WriteLn('Generating '+ExtractFileName(Source)+' to '+ExtractFileName(Target)+'...');
  19.  
  20.   PG:=TPatchGenerator.Create;
  21.   PG.StartBlockSize:=512;
  22.   PG.MinimumBlockSize:=512;
  23.   PG.BlockDivider:=2;
  24.   PG.StepSize:=256;
  25.   try
  26.     a:=Pos(',',Config);
  27.     if(a=0) then a:=Length(Config)+1;
  28.     PG.StartBlockSize:=StrToInt(Copy(Config,1,a-1));
  29.     Config:=Copy(Config,a+1,Length(Config));
  30.  
  31.     a:=Pos(',',Config);
  32.     if(a=0) then a:=Length(Config)+1;
  33.     PG.MinimumBlockSize:=StrToInt(Copy(Config,1,a-1));
  34.     Config:=Copy(Config,a+1,Length(Config));
  35.  
  36.     a:=Pos(',',Config);
  37.     if(a=0) then a:=Length(Config)+1;
  38.     PG.BlockDivider:=StrToInt(Copy(Config,1,a-1));
  39.     Config:=Copy(Config,a+1,Length(Config));
  40.  
  41.     a:=Pos(',',Config);
  42.     if(a=0) then a:=Length(Config)+1;
  43.     PG.StepSize:=StrToInt(Copy(Config,1,a-1));
  44.   finally
  45.   end;
  46.  
  47.   Result:=PG.CreatePatch(Source,Target);
  48.   PG.WriteToStream(Stream);
  49.   PG.Free;
  50.   WriteLn(ExtractFileName(Source)+' -> '+ExtractFileName(Target)+': '+IntToStr(Result)+' bytes');
  51. end;
  52.  
  53. end.
  54.