Changeset 490 for tools/wow_patcher


Ignore:
Timestamp:
Sep 10, 2010, 6:50:32 AM (14 years ago)
Author:
george
Message:
  • Opraveno: Kontrola existence souboru.
  • Opraveno: Nevytvářet upravený soubor pokud úprava selže.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/wow_patcher/wowpatcher.pas

    r489 r490  
    3939
    4040procedure TWoWPatcher.DoRun;
    41 var
    42   ErrorMsg: String;
    4341begin
    4442  WriteLn('wowpatcher ' + Version + ' ' + ReleaseDate);
     
    134132  NotValid: Boolean;
    135133const
     134  // -1 means any byte value
    136135  StartSequence: array[0..15] of Integer = ($8D, $4D, $E8, $E8, -1, -1, -1, -1, $5B, $8B, $E5, $5D, $C3, $8D, $49, $00);
    137136  StartSequence2: array[0..15] of Integer = ($88, $1D, -1, -1, -1, -1, $E8, -1, -1, -1, -1, $5B, $8B, $E5, $5D, $C3);
    138137begin
    139   try
    140     NewFile := TFileStream.Create(NewFileName, fmCreate);
     138    if not FileExists(FileName) then begin
     139      WriteLn(Format('File %s not found', [FileName]));
     140      Exit;
     141    end;
    141142    try
    142143      OriginalFile := TFileStream.Create(FileName, fmOpenRead);
     
    180181      end;
    181182      WriteLn;
    182     end else WriteLn('not found');
     183    end else begin
     184      WriteLn('not found');
     185      Exit;
     186    end;
    183187
    184188    WriteLn;
     
    215219      end;
    216220      WriteLn;
    217     end else WriteLn('not found');
    218 
    219     NewFile.WriteBuffer(Buffer[0], Length(Buffer));
     221    end else begin
     222      WriteLn('not found');
     223      Exit;
     224    end;
     225
     226  try
     227    WriteLn(Format('Patched file %s created', [NewFileName]));
     228    NewFile := TFileStream.Create(NewFileName, fmCreate);
     229    if Length(Buffer) > 0 then
     230      NewFile.WriteBuffer(Buffer[0], Length(Buffer));
    220231  finally
    221232    NewFile.Free;
Note: See TracChangeset for help on using the changeset viewer.