Merge pull request #4 from payonel/non_posix_rmdir

use lfs.rmdir for os.remove of dirs when os is not posix compliant
This commit is contained in:
James Coon 2015-08-25 23:48:53 -06:00
commit e33eab3e9f

View File

@ -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')