109 if !filewritable(a:path) |
109 if !filewritable(a:path) |
110 call mkdir(a:path, 'p', 0700) |
110 call mkdir(a:path, 'p', 0700) |
111 endif |
111 endif |
112 endfunc |
112 endfunc |
113 |
113 |
|
114 if has('ruby') |
|
115 func! s:PruneFiles(path, days) abort |
|
116 ruby <<END_RUBY |
|
117 require 'pathname' |
|
118 |
|
119 (path, days) = VIM.evaluate('[a:path, a:days]') |
|
120 sunset = Time.now - (days * 86400) |
|
121 |
|
122 Pathname(path).realpath.each_child do |file| |
|
123 file.delete if file.mtime < sunset |
|
124 end |
|
125 END_RUBY |
|
126 endfunc |
|
127 else |
|
128 func! s:PruneFiles(path, days) abort |
|
129 endfunc |
|
130 endif |
|
131 |
114 func! vimrc#PruneFiles(path, days) abort |
132 func! vimrc#PruneFiles(path, days) abort |
115 let l:path = expand(a:path) |
133 call s:PruneFiles(a:path, a:days) |
116 if isdirectory(l:path) |
|
117 for file in split(globpath(l:path, "*"), "\n") |
|
118 if localtime() > getftime(file) + 86400 * a:days |
|
119 call delete(file) |
|
120 endif |
|
121 endfor |
|
122 endif |
|
123 endfunc |
134 endfunc |
|
135 |