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 |
|
66 return M |
52 return M |