io module

This commit is contained in:
sam 2020-12-21 00:14:39 -05:00
parent 13f8190cbf
commit 831d96de84
1 changed files with 20 additions and 6 deletions

View File

@ -5,27 +5,41 @@ local hand = {}
local hands = {} local hands = {}
function io.open(path, mode) function io.open(path, mode)
local proxy, path = vfs.resolve(path)
if not proxy then return nil, "file not found" end
end end
function io.remove(path) function io.remove(path)
local proxy, path = vfs.resolve(path)
if not proxy then return false end
return proxy.remove(path)
end end
function io.mkdir(path) function io.mkdir(path)
local proxy, path = vfs.resolve(path)
if not proxy then return false end
return proxy.makeDirectory(path)
end end
function io.move(path, newpath) function io.move(path, newpath)
local proxy1, path1 = vfs.resolve(path)
local proxy2, path2 = vfs.resolve(path)
if not proxy1 or not proxy2 then return false end
if proxy1 == proxy2 then
proxy1.rename(path1, path2)
end
end end
function io.isreadonly(path) function io.isreadonly(path)
local proxy = vfs.resolve(path)
if not proxy then return false end
return proxy.isReadOnly()
end end
function io.exists(path) function io.exists(path)
local proxy, path = vfs.resolve(path)
if not proxy then return false end
return proxy.exists(path)
end end
return io return io