Fix engine crash when trying to delete cameraFile but it doesn't exist
authorWuzzy <Wuzzy2@mail.ru>
Thu, 19 Jul 2018 19:35:28 +0200
changeset 13519 d8462cc9d42d
parent 13518 4c5c8a83e298
child 13522 31d0b0911cba
Fix engine crash when trying to delete cameraFile but it doesn't exist
hedgewars/uVideoRec.pas
--- a/hedgewars/uVideoRec.pas	Thu Jul 19 19:11:39 2018 +0200
+++ b/hedgewars/uVideoRec.pas	Thu Jul 19 19:35:28 2018 +0200
@@ -157,8 +157,15 @@
         AddFileLog('AVWrapper_Close() has failed.');
         halt(HaltVideoRec);
         end;
-    Erase(cameraFile);
-    if recordAudio then
+{$IOCHECKS OFF}
+    // Provoke IOResult to be set
+    FileSize(cameraFile);
+    if IOResult = 0 then
+        Erase(cameraFile)
+    else
+        AddFileLog('Warning: Tried to delete the cameraFile but it was already deleted');
+{$IOCHECKS ON}
+    if recordAudio and FileExists(soundFilePath) then
         DeleteFile(soundFilePath);
     SendIPC(_S'v'); // inform frontend that we finished
 end;