liminix/pkgs/anoia/fs.fnl

21 lines
480 B
Plaintext
Raw Normal View History

2023-09-08 20:03:18 +00:00
(local lfs (require :lfs))
(fn rmtree [pathname]
(case (lfs.symlinkattributes pathname)
nil true
{:mode "directory"}
(do
(each [f (lfs.dir pathname)]
(when (not (or (= f ".") (= f "..")))
(rmtree ( .. pathname "/" f)))
(lfs.rmdir pathname)))
{:mode "file"}
(os.remove pathname)
{:mode "link"}
(os.remove pathname)
unknown
(error (.. "can't remove " pathname " of kind \"" unknown.mode "\""))))
{ : rmtree }