From cca1eef95a689eb483f566b34e2496f2b690ba95 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 7 Apr 2013 19:12:11 +0200 Subject: update l-os --- lualibs-os.lua | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'lualibs-os.lua') diff --git a/lualibs-os.lua b/lualibs-os.lua index 799f449..42f3e48 100644 --- a/lualibs-os.lua +++ b/lualibs-os.lua @@ -157,7 +157,7 @@ function os.launch(str) os.execute(format(launchers[os.name] or launchers.unix,str)) end -if not os.times then +if not os.times then -- ? -- utime = user time -- stime = system time -- cutime = children user time @@ -193,14 +193,10 @@ os.resolvers = os.resolvers or { } -- will become private local resolvers = os.resolvers -local osmt = getmetatable(os) or { __index = function(t,k) t[k] = "unset" return "unset" end } -- maybe nil -local osix = osmt.__index - -osmt.__index = function(t,k) - return (resolvers[k] or osix)(t,k) -end - -setmetatable(os,osmt) +setmetatable(os, { __index = function(t,k) + local r = resolvers[k] + return r and r(t,k) or nil -- no memoize +end }) -- we can use HOSTTYPE on some platforms @@ -448,6 +444,18 @@ end os.which = which os.where = which +function os.today() + return date("!*t") -- table with values +end + +function os.now() + return date("!%Y-%m-%d %H:%M:%S") -- 2011-12-04 14:59:12 +end + +if not os.sleep and socket then + os.sleep = socket.sleep +end + -- print(os.which("inkscape.exe")) -- print(os.which("inkscape")) -- print(os.which("gs.exe")) -- cgit v1.2.3