forked from DGNum/liminix
move rmtree to anoia library
This commit is contained in:
parent
eaa45906ff
commit
4e9227dff3
2 changed files with 21 additions and 18 deletions
20
pkgs/anoia/fs.fnl
Normal file
20
pkgs/anoia/fs.fnl
Normal file
|
@ -0,0 +1,20 @@
|
|||
(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 }
|
|
@ -1,23 +1,6 @@
|
|||
(local { : split : merge : mkdir } (require :anoia))
|
||||
(local { : view } (require :fennel))
|
||||
(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 "\""))))
|
||||
|
||||
(local { : rmtree } (require :anoia.fs))
|
||||
|
||||
(local state-directory (assert (os.getenv "SERVICE_STATE")))
|
||||
(mkdir state-directory)
|
||||
|
|
Loading…
Reference in a new issue