From 1310d651e8847c1121c659bfa4d55bf30dcff782 Mon Sep 17 00:00:00 2001 From: payonel Date: Tue, 25 Aug 2015 22:19:23 -0700 Subject: [PATCH] use lfs to rmdir instead of os.remove because windows is not posix compliant --- src/boot.lua | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/boot.lua b/src/boot.lua index d01597e..c485753 100755 --- a/src/boot.lua +++ b/src/boot.lua @@ -49,6 +49,8 @@ local function boot() end end + local os_remove_leaf = os.remove + local recursiveDelete function recursiveDelete(path) local mode = lfs.attributes(path,"mode") @@ -62,11 +64,11 @@ local function boot() if mode == "directory" then recursiveDelete(path .. "/" .. entry) end - os.remove(path .. "/" .. entry) + os_remove_leaf(path .. "/" .. entry) end end end - return os.remove(path) + return os_remove_leaf(path) end elsa = { @@ -130,6 +132,22 @@ local function boot() windowEventID = wen, } + -- redirect os.remove is non posix + if os.getenv('os') == 'Windows_NT' then + local os_remove = os.remove + os_remove_leaf = function(path) + local mode = lfs.attributes(path,"mode") + if mode == nil then + return false + elseif mode == "directory" then + return lfs.rmdir(path) + else -- remove file + return os_remove(path) + end + end + os.remove = elsa.remove + end + require("main") local e = ffi.new('SDL_Event')