Browse Source

* patch to allow append for TEventlog, from Ido. Mantis 18355

git-svn-id: trunk@17127 -
marco 14 years ago
parent
commit
c439d0107d
1 changed files with 11 additions and 2 deletions
  1. 11 2
      packages/fcl-base/src/eventlog.pp

+ 11 - 2
packages/fcl-base/src/eventlog.pp

@@ -29,6 +29,7 @@ Type
 
 
   TEventLog = Class(TComponent)
   TEventLog = Class(TComponent)
   Private
   Private
+    fAppendContent : Boolean;
     FEventIDOffset : DWord;
     FEventIDOffset : DWord;
     FLogHandle : Pointer;
     FLogHandle : Pointer;
     FStream : TFileStream;
     FStream : TFileStream;
@@ -84,6 +85,7 @@ Type
     Procedure Info (const Msg : String); {$ifndef fpc }Overload;{$endif}
     Procedure Info (const Msg : String); {$ifndef fpc }Overload;{$endif}
     Procedure Info (const Fmt : String; Args : Array of const); {$ifndef fpc }Overload;{$endif}
     Procedure Info (const Fmt : String; Args : Array of const); {$ifndef fpc }Overload;{$endif}
   Published
   Published
+    Property AppendContent : Boolean Read fAppendContent Write fAppendContent;
     Property Identification : String Read FIdentification Write SetIdentification;
     Property Identification : String Read FIdentification Write SetIdentification;
     Property LogType : TLogType Read Flogtype Write SetlogType;
     Property LogType : TLogType Read Flogtype Write SetlogType;
     Property Active : Boolean Read FActive write SetActive;
     Property Active : Boolean Read FActive write SetActive;
@@ -240,12 +242,19 @@ begin
 end;
 end;
 
 
 Procedure TEventLog.ActivateFileLog;
 Procedure TEventLog.ActivateFileLog;
-
+var
+  fFileFlags : Word;
 begin
 begin
   If (FFileName='') then
   If (FFileName='') then
     FFileName:=DefaultFileName;
     FFileName:=DefaultFileName;
   // This will raise an exception if the file cannot be opened for writing !
   // This will raise an exception if the file cannot be opened for writing !
-  FStream:=TFileStream.Create(FFileName,fmCreate or fmShareDenyWrite);
+  if fAppendContent and FileExists(FFileName) then
+    fFileFlags := fmOpenWrite
+  else
+    fFileFlags := fmCreate;
+
+  fFileFlags := fFileFlags or fmShareDenyWrite;
+  FStream:=TFileStream.Create(FFileName,fFileFlags);
 end;
 end;
 
 
 Procedure TEventLog.DeActivateFileLog;
 Procedure TEventLog.DeActivateFileLog;