delete recursive works
This commit is contained in:
parent
bb53615ed5
commit
fe5b94c61c
2 changed files with 20 additions and 24 deletions
|
@ -25,18 +25,6 @@
|
|||
[ignore-patterns source-list]
|
||||
(filter #(not (re-matches ignore-patterns %)) source-list))
|
||||
|
||||
; (defn delete-file-recursive
|
||||
; [folders]
|
||||
; (when (not (empty? folders))
|
||||
; (let [file-to-work-with (first folders)
|
||||
; ; TODO: .list fehlt noch
|
||||
; file-list (filter #(.isFile %) file-to-work-with)
|
||||
; dir-list (filter #(not (.isFile %)) file-to-work-with)]
|
||||
; (doseq [file file-list] (io/delete-file file))
|
||||
; (when (not (empty? dir-list))
|
||||
; (recur (drop 1 dir-list)))
|
||||
; (io/delete-file file-to-work-with))))
|
||||
|
||||
(defn file-from-cp
|
||||
[resource-path]
|
||||
(let [file-from-cp (io/file (io/resource resource-path))]
|
||||
|
@ -62,7 +50,7 @@
|
|||
from-fs
|
||||
(file-from-cp resource-path))))
|
||||
|
||||
(s/defn get-file-paths-recursive :- [s/Str]
|
||||
(s/defn get-resource-paths-recursive :- [s/Str]
|
||||
[fs-prefix :- s/Str
|
||||
base-path :- s/Str
|
||||
paths :- [s/Str]]
|
||||
|
@ -86,6 +74,14 @@
|
|||
)))
|
||||
result)))
|
||||
|
||||
(s/defn delete-resource-recursive!
|
||||
[path :- s/Str]
|
||||
(let [resource-paths
|
||||
(reverse (get-resource-paths-recursive "" path [""]))]
|
||||
(println resource-paths)
|
||||
(doseq [path resource-paths]
|
||||
(io/delete-file path))))
|
||||
|
||||
(defn copy-file
|
||||
[source-file
|
||||
target-file]
|
||||
|
|
|
@ -25,18 +25,18 @@
|
|||
(and (verify-file-exists path)
|
||||
(.isDirectory (io/file path))))
|
||||
|
||||
(deftest test-get-file-paths-recursive
|
||||
(deftest test-get-resource-paths-recursive
|
||||
(is (=
|
||||
[]
|
||||
(sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" ["not-existing"])))
|
||||
(sut/get-resource-paths-recursive "" "templates/themes/bootstrap4-test" ["not-existing"])))
|
||||
(is (=
|
||||
["js/dummy.js"]
|
||||
(sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" ["js/dummy.js"])))
|
||||
(sut/get-resource-paths-recursive "" "templates/themes/bootstrap4-test" ["js/dummy.js"])))
|
||||
(is (=
|
||||
["js/subdir"
|
||||
"js/subdir/test.js"
|
||||
"js/subdir/subdummy.js"]
|
||||
(sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" ["js/subdir"])))
|
||||
(sut/get-resource-paths-recursive "" "templates/themes/bootstrap4-test" ["js/subdir"])))
|
||||
(is (=
|
||||
["."
|
||||
"./css"
|
||||
|
@ -49,15 +49,15 @@
|
|||
"./html"
|
||||
"./html/403.html"
|
||||
"./html/404.html"]
|
||||
(sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" ["."])))
|
||||
(sut/get-resource-paths-recursive "" "templates/themes/bootstrap4-test" ["."])))
|
||||
)
|
||||
|
||||
; (deftest test-delete-file-recursive
|
||||
; (is
|
||||
; (do
|
||||
; (.mkdir (io/file target))
|
||||
; (sut/delete-file-recursive (seq (io/file target)))
|
||||
; (not (verify-dir-exists target)))))
|
||||
(deftest test-delete-resource-recursive
|
||||
(is
|
||||
(do
|
||||
(.mkdir (io/file (str "target/tmp" target)))
|
||||
(sut/delete-resource-recursive! (str "target/tmp"target))
|
||||
(not (verify-dir-exists (str "target/tmp" target))))))
|
||||
|
||||
(deftest test-file-from-cp-or-filesystem
|
||||
(is
|
||||
|
|
Loading…
Reference in a new issue