.config/nvim/lua/config/util.lua

changeset 1157
a237720efee9
parent 1156
0a7162df160d
child 1161
2543467f42da
equal deleted inserted replaced
1156:0a7162df160d 1157:a237720efee9
47 47
48 function M.last_modified_days(fname) 48 function M.last_modified_days(fname)
49 return (os.time() - vim.fn.getftime(fname)) / 86400 49 return (os.time() - vim.fn.getftime(fname)) / 86400
50 end 50 end
51 51
52 function M.prune_files(path, days)
53 local sunset = os.time() - (days * 86400)
54 path = vim.fs.normalize(path)
55
56 if fn.getftype(path) == "" then return end
57
58 for fname, type in vim.fs.dir(path) do
59 local fpath = vim.fs.normalize(path .. "/" .. fname)
60 if type == "file" and fn.getftime(fpath) < sunset then
61 os.remove(fpath)
62 end
63 end
64 end
65
52 return M 66 return M

mercurial