liminix

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 4e9227dff3d8bfd3cd7f82e99238acff7ceb2f2f
parent eaa45906ffc5bfbe91fb1ac0cb9dad6434e2b4bc
Author: Daniel Barlow <dan@telent.net>
Date:   Fri,  8 Sep 2023 21:03:18 +0100

move rmtree to anoia library

Diffstat:
Apkgs/anoia/fs.fnl | 20++++++++++++++++++++
Mpkgs/odhcp-script/odhcp6-script.fnl | 19+------------------
2 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/pkgs/anoia/fs.fnl b/pkgs/anoia/fs.fnl @@ -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 } diff --git a/pkgs/odhcp-script/odhcp6-script.fnl b/pkgs/odhcp-script/odhcp6-script.fnl @@ -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)