Lua標(biāo)準(zhǔn)庫(kù)-操作系統(tǒng)處理
這個(gè)庫(kù)通過(guò)表os實(shí)現(xiàn)
1、os.clock ()
功能:返回一個(gè)程序使用CPU時(shí)間的一個(gè)近似值
2、os.date ([format [, time]])
功能:返回一個(gè)按format格式化日期、時(shí)間的字串或表
若設(shè)置time參數(shù),則按time指定的時(shí)間格式化,否則按當(dāng)前時(shí)間格式化
參數(shù):
format:
"!":按格林尼治時(shí)間進(jìn)行格式化。
"*t":將返一個(gè)帶year(4位),month(1-12), day (1--31), hour (0-23), min (0-59), sec (0-61), wday (星期幾, 星期天為1), yday (年內(nèi)天數(shù)), and isdst (是否為日光節(jié)約時(shí)間true/false)的帶鍵名的表; 若沒(méi)有"*t"則返回一個(gè)按C的strftime函數(shù)格式化的字符串
若不帶參數(shù),則按當(dāng)前系統(tǒng)的設(shè)置返回格式化的字符串 os.date() <=> os.date("%c")
3、os.difftime (t2, t1)
功能:返回t1到t2相差的秒數(shù)
4、os.execute ([command])
功能:相當(dāng)于C的system函數(shù),返回系統(tǒng)狀態(tài)碼
5、os.exit ([code])
功能:相當(dāng)于C的exit函數(shù),終止主程序,code為返回值
6、os.getenv (varname)
功能:返回當(dāng)前進(jìn)程的環(huán)境變量varname的值,若變量沒(méi)有定義時(shí)返回nil
7、os.remove (filename)
功能:刪除文件或一個(gè)空目錄,若函數(shù)調(diào)用失敗則返加nil加錯(cuò)誤信息
8、os.rename (oldname, newname)
功能:更改一個(gè)文件或目錄名,若函數(shù)調(diào)用失敗則返加nil加錯(cuò)誤信息
9、os.setlocale (locale [, category])
功能:設(shè)置程序的當(dāng)前設(shè)置,函數(shù)返回***的值,失敗則返回nil
參數(shù):
locale:一個(gè)指定當(dāng)前設(shè)置的字串
"":一個(gè)空字串,當(dāng)前設(shè)置被視為本地設(shè)置
"c":當(dāng)前設(shè)置被視為標(biāo)準(zhǔn)c設(shè)置
nil:返回category指示設(shè)置名的當(dāng)前值
category:一個(gè)描述要更改的設(shè)置名
"all"[默認(rèn)], "collate", "ctype", "monetary", "numeric", "time"
10、os.time ([table])
功能:按table的內(nèi)容返回一個(gè)時(shí)間值(數(shù)字),若不帶參數(shù)則返回當(dāng)前時(shí)間
table的字段:
year, month, day, hour, min, sec, isdst
11、os.tmpname()
功能:返回一個(gè)臨時(shí)文件名