From 9baa4dbc1723bf60b20d0a78780437d46815451b Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Wed, 25 Dec 2024 15:11:11 -0800 Subject: [PATCH] Add RmdirP --- path.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 path.go diff --git a/path.go b/path.go new file mode 100644 index 0000000..bcd19ba --- /dev/null +++ b/path.go @@ -0,0 +1,16 @@ +package ch + +import ( + "os" + "path/filepath" +) + +func RmdirP(path string) error { + err := os.Remove(path) + if err != nil { + return err + } + dir, _ := filepath.Split(path) + _ = RmdirP(dir) // We only care about errors for the first directory we always expect atleast one to fail + return nil +}