util.lua (600B)
1 local std = require("lib.std") 2 local symbol = require("lib.symbol") 3 4 local M = {} 5 6 function M.cc(tbl, sep) 7 return table.concat(tbl, sep or "") 8 end 9 10 function M.year(y) 11 return y or os.date("%Y") 12 end 13 14 function M.copyright(link, holder) 15 return symbol.legal.copyright .. " " .. std.external(link, holder) 16 end 17 18 function M.license(name) 19 return symbol.legal.registered .. " " .. name 20 end 21 22 function M.ls(dir) 23 local p = io.popen('ls -A -1 -- ' .. string.format('%q', dir)) 24 if not p then 25 return nil 26 end 27 local t = {} 28 for line in p:lines() do 29 t[#t + 1] = line 30 end 31 p:close() 32 return t 33 end 34 35 return M