From: DeaDDooMER Date: Sat, 5 Jan 2019 18:07:50 +0000 (+0300) Subject: fix file rewrite on win32 X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=7e9341416173d0324e03b6e2f808dcc66ca0f771;p=d2df-editor.git fix file rewrite on win32 --- diff --git a/src/editor/g_resources.pas b/src/editor/g_resources.pas index 4d636ee..880b727 100644 --- a/src/editor/g_resources.pas +++ b/src/editor/g_resources.pas @@ -52,7 +52,11 @@ implementation f.RemoveResource(section, name); f.AddResource(data, len, name, section); if FileExists(wad) then - ASSERT(RenameFile(wad, wad + '.bak')); + begin + if FileExists(wad + '.bak') then + ASSERT(DeleteFile(wad + '.bak')); + ASSERT(RenameFile(wad, wad + '.bak')) + end; f.SaveTo(wad); f.Free; res := 0 @@ -115,7 +119,11 @@ implementation ts.Free; if FileExists(wad) then - ASSERT(RenameFile(wad, wad + '.bak')); + begin + if FileExists(wad + '.bak') then + ASSERT(DeleteFile(wad + '.bak')); + ASSERT(RenameFile(wad, wad + '.bak')) + end; ASSERT(RenameFile(tmp, wad)); res := 0 end; @@ -201,7 +209,11 @@ implementation ts.Free; if FileExists(wad) then - ASSERT(RenameFile(wad, wad + '.bak')); + begin + if FileExists(wad + '.bak') then + ASSERT(DeleteFile(wad + '.bak')); + ASSERT(RenameFile(wad, wad + '.bak')) + end; ASSERT(RenameFile(tmp, wad)); res := 0 end;