diff options
-rw-r--r-- | lualibs-os.lua | 26 |
1 files changed, 17 insertions, 9 deletions
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")) |