Ver código fonte

* write output to screen if log file(s) cannot be opened (mantis #12532)

git-svn-id: trunk@13032 -
Jonas Maebe 16 anos atrás
pai
commit
f9a17c47bd
1 arquivos alterados com 17 adições e 1 exclusões
  1. 17 1
      rtl/inc/heaptrc.pp

+ 17 - 1
rtl/inc/heaptrc.pp

@@ -1283,7 +1283,15 @@ begin
 {$I-}
    append(ownfile);
    if IOResult<>0 then
-     Rewrite(ownfile);
+     begin
+       Rewrite(ownfile);
+       if IOResult<>0 then
+         begin
+           Writeln(stderr,'[heaptrc] Unable to open "',name,'", writing output to stderr instead.');
+           useownfile:=false;
+           exit;
+         end;
+     end;
 {$I+}
    useownfile:=true;
    for i:=0 to Paramcount do
@@ -1333,8 +1341,16 @@ begin
   if outputstr <> '' then
      SetHeapTraceOutput(outputstr);
 {$ifdef EXTRA}
+{$i-}
   Assign(error_file,'heap.err');
   Rewrite(error_file);
+{$i+}
+  if IOResult<>0 then
+    begin
+      writeln('[heaptrc] Unable to create heap.err extra log file, writing output to screen.');
+      Assign(error_file,'');
+      Rewrite(error_file);
+    end;
 {$endif EXTRA}
 end;