SoUI 0.5版本占坑
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
942 B

local sleep = require 'ffi.sleep'
local function task(f, ...)
for i = 1, 99 do
if pcall(f, ...) then
return
end
sleep(10)
end
f(...)
end
local mt = {}
mt.__index = mt
function mt:save()
if fs.exists(self.path) then
task(fs.remove_all, self.path)
end
task(fs.create_directories, self.path)
return true
end
function mt:close()
end
function mt:extract(name, path)
return fs.copy_file(self.path / name, path, true)
end
function mt:has_file(name)
return fs.exists(self.path / name)
end
function mt:remove_file(name)
fs.remove(self.path / name)
end
function mt:load_file(name)
return io.load(self.path / name)
end
function mt:save_file(name, buf, filetime)
fs.create_directories((self.path / name):remove_filename())
io.save(self.path / name, buf)
return true
end
return function (input)
return setmetatable({ path = input }, mt)
end