From 3d2e9f4f029c5bb8868bb438d677c724ff6a2609 Mon Sep 17 00:00:00 2001 From: eddie-0815 Date: Thu, 22 Nov 2007 21:05:11 +0000 Subject: Added LogBuffer to dump binary data to a file. git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@628 b956fd51-792f-4845-bead-9b4dfca2ff2c --- Game/Code/Classes/ULog.pas | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'Game/Code') diff --git a/Game/Code/Classes/ULog.pas b/Game/Code/Classes/ULog.pas index 7f0b82c4..ac08f2d5 100644 --- a/Game/Code/Classes/ULog.pas +++ b/Game/Code/Classes/ULog.pas @@ -45,6 +45,7 @@ type // compability procedure LogStatus(Log1, Log2: string); procedure LogError(Log1, Log2: string); overload; + procedure LogBuffer(const buf : Pointer; const bufLength : Integer; filename : string); end; var @@ -256,6 +257,24 @@ begin Halt; end; +procedure TLog.LogBuffer(const buf: Pointer; const bufLength: Integer; filename: string); +var + f : TFileStream; +begin + f := nil; + + try + f := TFileStream.Create( filename, fmCreate); + f.Write( buf^, bufLength); + f.Free; + except + on e : Exception do begin + Log.LogError('TLog.LogBuffer: Failed to log buffer into file "' + filename + '". ErrMsg: ' + e.Message); + f.Free; + end; + end; +end; + end. -- cgit v1.2.3