local io, os, error = io, os, error
local io, os, error = io, os, errorlocal file = {}function file.exists(path)
local file = io.open(path, 'rb')
if file then
file:close()
end
return file ~= nil
endReturn the content of the file by reading the given path and mode.
path is a string.mode is a string.function file.read(path, mode)
mode = mode or '*a'
local file, err = io.open(path, 'rb')
if err then
error(err)
end
local content = file:read(mode)
file:close()
return content
endWrite to the file with the given path, content and mode.
path is a string.content is a string.mode is a string.function file.write(path, content, mode)
mode = mode or 'w'
local file, err = io.open(path, mode)
if err then
error(err)
end
file:write(content)
file:close()
endCopy the file by reading the src and writing it to the dest.
src is a string.dest is a string.function file.copy(src, dest)
local content = file.read(src)
file.write(dest, content)
endfunction file.move(src, dest)
os.rename(src, dest)
endfunction file.remove(path)
os.remove(path)
endreturn file