hedgewars/uUtils.pas
changeset 8425 4f226963faef
parent 8370 0c79946e96f8
child 8444 75db7bb8dce8
child 8498 eecadca7db50
equal deleted inserted replaced
8424:225ede46e3dc 8425:4f226963faef
   459         logfileBase:= 'preview';
   459         logfileBase:= 'preview';
   460 {$IFDEF USE_VIDEO_RECORDING}
   460 {$IFDEF USE_VIDEO_RECORDING}
   461     InitCriticalSection(logMutex);
   461     InitCriticalSection(logMutex);
   462 {$ENDIF}
   462 {$ENDIF}
   463 {$I-}
   463 {$I-}
   464 {$IFDEF MOBILE}
   464     f:= stderr; // if everything fails, write to stderr
   465     {$IFDEF IPHONEOS} Assign(f, UserPathPrefix + '/hw-' + logfileBase + '.log'); {$ENDIF}
       
   466     {$IFDEF ANDROID} Assign(f, pathPrefix + '/' + logfileBase + '.log'); {$ENDIF}
       
   467     i:= i; // avoid hint
       
   468 {$ELSE}
       
   469     f:= stdout; // if everything fails, write to stderr
       
   470     if (UserPathPrefix <> '') then
   465     if (UserPathPrefix <> '') then
   471         begin
   466         begin
       
   467         // create directory if it doesn't exist
   472         if not FileExists(UserPathPrefix + '/Logs/') then
   468         if not FileExists(UserPathPrefix + '/Logs/') then
   473             CreateDir(UserPathPrefix + '/Logs/');
   469             CreateDir(UserPathPrefix + '/Logs/');
       
   470 
       
   471         // if log is locked, write to the next one
   474         i:= 0;
   472         i:= 0;
   475         while(i < 7) do
   473         while(i < 7) do
   476             begin
   474             begin
   477             assign(f, UserPathPrefix + '/Logs/' + logfileBase + inttostr(i) + '.log');
   475             assign(f, UserPathPrefix + '/Logs/' + logfileBase + inttostr(i) + '.log');
   478             if IOResult = 0 then
   476             if IOResult = 0 then
   479                 break;
   477                 break;
   480             inc(i)
   478             inc(i)
   481             end;
   479             end;
   482         end;
   480         end;
   483 {$ENDIF}
       
   484     Rewrite(f);
   481     Rewrite(f);
   485 {$I+}
   482 {$I+}
   486 {$ENDIF}
   483 {$ENDIF}
   487 
   484 
   488 end;
   485 end;