From 831d96de844af26180575b7b6c82db513c96a83a Mon Sep 17 00:00:00 2001 From: sam Date: Mon, 21 Dec 2020 00:14:39 -0500 Subject: [PATCH] io module --- mods/io/init.lua | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/mods/io/init.lua b/mods/io/init.lua index 0ff36b4..83ca608 100644 --- a/mods/io/init.lua +++ b/mods/io/init.lua @@ -5,27 +5,41 @@ local hand = {} local hands = {} function io.open(path, mode) - + local proxy, path = vfs.resolve(path) + if not proxy then return nil, "file not found" end end function io.remove(path) - + local proxy, path = vfs.resolve(path) + if not proxy then return false end + return proxy.remove(path) end function io.mkdir(path) - + local proxy, path = vfs.resolve(path) + if not proxy then return false end + return proxy.makeDirectory(path) end 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 function io.isreadonly(path) - + local proxy = vfs.resolve(path) + if not proxy then return false end + return proxy.isReadOnly() end function io.exists(path) - + local proxy, path = vfs.resolve(path) + if not proxy then return false end + return proxy.exists(path) end return io \ No newline at end of file