Windows: Temporarily fix crash on break computer

Check if `os.execute` is available before attempting to use it (is not
available on Windows). This is not a real fix as it results in empty
directories being left behind in the computer files. The only actual fix
to this issue is an official `rmdir` Minetest API.
master
octacian 2017-06-27 13:59:08 -07:00
parent dc6c24e669
commit 6cf860b0b1
No known key found for this signature in database
GPG Key ID: E84291D11A3509B5
1 changed files with 6 additions and 2 deletions

View File

@ -67,8 +67,10 @@ function builtin.mkdir(path)
if not io.open(path) then
if minetest.mkdir then
minetest.mkdir(path) -- create directory if minetest.mkdir is available
else
elseif os.execute then
os.execute('mkdir "'..path..'"') -- create directory with os mkdir command
else
return false
end
return true
end
@ -97,7 +99,9 @@ function builtin.rmdir(path)
local ok, msg = os.remove(dpath)
if not ok then
os.execute("rmdir "..dpath)
if os.execute then
os.execute("rmdir "..dpath)
end
end
end