mirror of
https://github.com/minetest-technic/datastorage.git
synced 2025-01-01 21:47:30 +01:00
Use minetest.mkdir when available
This commit is contained in:
parent
c5954e4f07
commit
8ce345aaa8
16
init.lua
16
init.lua
@ -15,12 +15,16 @@ function datastorage.save(id)
|
|||||||
if not file then
|
if not file then
|
||||||
-- Most likely the data directory doesn't exist, create it
|
-- Most likely the data directory doesn't exist, create it
|
||||||
-- and try again.
|
-- and try again.
|
||||||
-- Using os.execute like this is not very platform independent
|
if minetest.mkdir then
|
||||||
-- or safe; but most platforms name their directory
|
minetest.mkdir(data_path)
|
||||||
-- creation utility mkdir, and the data path is unlikely to
|
else
|
||||||
-- contain special characters and is only mutabable by the
|
-- Using os.execute like this is not very platform
|
||||||
-- admin.
|
-- independent or safe, but most platforms name their
|
||||||
os.execute('mkdir "'..data_path..'"')
|
-- directory creation utility mkdir, the data path is
|
||||||
|
-- unlikely to contain special characters, and the
|
||||||
|
-- data path is only mutable by the admin.
|
||||||
|
os.execute('mkdir "'..data_path..'"')
|
||||||
|
end
|
||||||
file = io.open(data_path..id, "w")
|
file = io.open(data_path..id, "w")
|
||||||
if not file then return end
|
if not file then return end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user