From 8e14c1805af82b858c5106d9294d929ea7750a69 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Thu, 21 Oct 2021 23:17:04 -0700 Subject: [PATCH] fix filesystem race-condition --- bin/buildokvs.js | 1 + bin/buildpre.js | 6 +++--- bin/buildss.js | 4 +++- bin/makesorted.js | 1 + winmake.bat | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bin/buildokvs.js b/bin/buildokvs.js index a6abbd735..6d9e35afe 100644 --- a/bin/buildokvs.js +++ b/bin/buildokvs.js @@ -41,5 +41,6 @@ if (!a.fileexists(WScript.Arguments(1)) || a.getfile(WScript.Arguments(1)).datel source.writeline("!text \"" + ((val >= 0) ? (entries[i].substr(val + 1)) : "") + "\"") } + source.close() new ActiveXObject("wscript.shell").run('cmd /c %acme% -o ' + WScript.Arguments(1) + ' build\\okvs.tmp', 0, 1) } diff --git a/bin/buildpre.js b/bin/buildpre.js index c8f2cf05e..94627a43a 100644 --- a/bin/buildpre.js +++ b/bin/buildpre.js @@ -8,14 +8,14 @@ while (!b.atendofstream) entries.push(b.readline()) } -pre_off = a.getfile(WScript.Arguments(2)).size + a.getfile(WScript.Arguments(0) + "\\STANDARD").size -osize = pre_off +osize = a.getfile(WScript.Arguments(0) + "\\STANDARD").size +pre_off = a.getfile(WScript.Arguments(2)).size + osize groups = "*=0\n" + "!le16 " + entries.length + ", 0\n" for (i = 0; i < entries.length; i++) { - c = 0 + c = a.getfile(WScript.Arguments(2)).size size = osize if (a.fileexists(WScript.Arguments(0) + "\\" + entries[i])) diff --git a/bin/buildss.js b/bin/buildss.js index 1e74eb903..e5908f1ef 100644 --- a/bin/buildss.js +++ b/bin/buildss.js @@ -25,7 +25,9 @@ else entries.sort() -a.createtextfile("build\\GAMES.SORTED").write(entries.toString().replace(/,/g, "\n")) +f = a.createtextfile("build\\GAMES.SORTED") +f.write(entries.toString().replace(/,/g, "\n")) +f.close() ss_off = a.fileexists(WScript.Arguments(2)) ? a.getFile(WScript.Arguments(2)).size : 0 groups = "*=0\n" + "!le16 " + entries.length + ", 0\n" diff --git a/bin/makesorted.js b/bin/makesorted.js index 5ae016dcd..4e4dbd40f 100644 --- a/bin/makesorted.js +++ b/bin/makesorted.js @@ -33,4 +33,5 @@ while (!b.atendofstream) } } +a.createtextfile("build\\GAMES.CONF").write(c.toString().replace(/,/g, "\n")) a.createtextfile("build\\GAMES.SORTED").write(c.sort().toString().replace(/,/g, "\n")) diff --git a/winmake.bat b/winmake.bat index 0264db564..7d64dc357 100644 --- a/winmake.bat +++ b/winmake.bat @@ -60,6 +60,7 @@ cscript /nologo bin\subst.js res\HELPTEXT build\HELPTEXT >>build\log cscript /nologo bin\subst.js res\CREDITS build\CREDITS >>build\log for %%q in (res\GAMEHELP\*) do cscript /nologo bin\subst.js %%q build\GAMEHELP\%%~nxq >>build\log rem +rem create distribution version of GAMES.CONF without comments or blank lines rem create a sorted list of game filenames, without metadata or display names rem cscript /nologo bin\makesorted.js @@ -133,7 +134,7 @@ rem %CADIUS% ADDFILE "build\%DISK%" "/%VOLUME%/" "res\TITLE" >>build\log %CADIUS% ADDFILE "build\%DISK%" "/%VOLUME%/" "res\COVER" >>build\log %CADIUS% ADDFILE "build\%DISK%" "/%VOLUME%/" "res\HELP" >>build\log -%CADIUS% ADDFILE "build\%DISK%" "/%VOLUME%/" "res\GAMES.CONF" >>build\log +%CADIUS% ADDFILE "build\%DISK%" "/%VOLUME%/" "build\GAMES.CONF" >>build\log %CADIUS% ADDFILE "build\%DISK%" "/%VOLUME%/" "build\PREFS.CONF" >>build\log %CADIUS% ADDFILE "build\%DISK%" "/%VOLUME%/" "build\CREDITS" >>build\log %CADIUS% ADDFILE "build\%DISK%" "/%VOLUME%/" "build\HELPTEXT" >>build\log