Lua中的文件操作部分
在lua中內(nèi)含了io,file模塊,直接調(diào)用該模塊中函數(shù)即可。下面列出可用的函數(shù)集合。(細(xì)節(jié)見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]) 設(shè)置buf區(qū)為文件映射 | ||
|
file:seek([whence],[,offset]) | ||
操作系統(tǒng)相關(guān)函數(shù)
| os.clock() | 當(dāng)前cpu時(shí)間 | |
| os.date() | 日期 | |
| os.difftime (t2, t1) | t2-t1的時(shí)間,單位為秒 | |
| os.execute ([command]) | shell命令 | |
| os.exit ([code]) | 退出 | |
| os.getenv (varname) | 獲取環(huán)境 | |
| os.remove (filename) | 刪文件,目錄(須空) | |
| os.rename (oldname, newname) | 改名 | |
| os.setlocale (locale [, category]) | 改類型 | |
| os.time ([table]) | 時(shí)間 | |
| os.tmpname () | ||


