file is a minimal library for working with files in Lua.
The annotated source code is available.
Installation
luarocks build https://raw.github.com/gummesson/file.lua/master/file-dev-1.rockspec
API
file.exists
file.exists(path)
Determines if the file's path
exists. Returns either true
or false
.
Example
file.exists('test.txt')
file.read
file.read(path[, mode])
Returns the content of the file by reading the given path
and mode
.
Example
file.read('test.txt')
file.write
file.write(path, content[, mode])
Writes to the file with the given path
, content
and mode
.
Example
file.write('test.txt', 'Hello world!')
file.copy
file.copy(src, dest)
Copies the file by reading the src
and writing it to the dest
.
Example
file.copy('test.txt', 'test-copy.txt')
file.move
file.move(src, dest)
Moves the file from src
to the dest
.
Example
file.move('test-copy.txt', 'test/test.txt')
file.remove
file.remove(path)
Removes the file from the given path
.
Example
file.remove('test.txt')