Lua中的文件操作部分
在lua中內含了io,file模塊,直接調用該模塊中函數即可。下面列出可用的函數集合。(細節見lua文檔)
io.close([file]) |
file:close() |
io.flush() |
file:flush() |
io.input([file]) |
|
io.read(...) |
file:read(...) |
io.lines([filename]) |
file:lines() |
io.open(filename, [,mode]) |
|
io.output([file]) |
|
io.write(...) |
file:write(...) |
io.tmpfile() |
|
io.type(obj) |
|
|
file:setvbuf(mode, [size]) 設置buf區為文件映射 mode =
"no" 立即寫
"full" 滿buf區寫
"line" 寫行 |
|
file:seek([whence],[,offset]) whence =
"set"/"cur"/"end" |
操作系統相關函數
os.clock() |
當前cpu時間 |
os.date() |
日期 |
os.difftime (t2, t1) |
t2-t1的時間,單位為秒 |
os.execute ([command]) |
shell命令 |
os.exit ([code]) |
退出 |
os.getenv (varname) |
獲取環境 |
os.remove (filename) |
刪文件,目錄(須空) |
os.rename (oldname, newname) |
改名 |
os.setlocale (locale [, category]) |
改類型 |
os.time ([table]) |
時間 |
os.tmpname () |
|