delete recursive works

master
jem 5 years ago
parent bb53615ed5
commit fe5b94c61c

@ -25,18 +25,6 @@
[ignore-patterns source-list] [ignore-patterns source-list]
(filter #(not (re-matches 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 (defn file-from-cp
[resource-path] [resource-path]
(let [file-from-cp (io/file (io/resource resource-path))] (let [file-from-cp (io/file (io/resource resource-path))]
@ -62,7 +50,7 @@
from-fs from-fs
(file-from-cp resource-path)))) (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 [fs-prefix :- s/Str
base-path :- s/Str base-path :- s/Str
paths :- [s/Str]] paths :- [s/Str]]
@ -86,6 +74,14 @@
))) )))
result))) 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 (defn copy-file
[source-file [source-file
target-file] target-file]

@ -25,18 +25,18 @@
(and (verify-file-exists path) (and (verify-file-exists path)
(.isDirectory (io/file path)))) (.isDirectory (io/file path))))
(deftest test-get-file-paths-recursive (deftest test-get-resource-paths-recursive
(is (= (is (=
[] []
(sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" ["not-existing"]))) (sut/get-resource-paths-recursive "" "templates/themes/bootstrap4-test" ["not-existing"])))
(is (= (is (=
["js/dummy.js"] ["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 (= (is (=
["js/subdir" ["js/subdir"
"js/subdir/test.js" "js/subdir/test.js"
"js/subdir/subdummy.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 (= (is (=
["." ["."
"./css" "./css"
@ -49,15 +49,15 @@
"./html" "./html"
"./html/403.html" "./html/403.html"
"./html/404.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 (deftest test-delete-resource-recursive
; (is (is
; (do (do
; (.mkdir (io/file target)) (.mkdir (io/file (str "target/tmp" target)))
; (sut/delete-file-recursive (seq (io/file target))) (sut/delete-resource-recursive! (str "target/tmp"target))
; (not (verify-dir-exists target))))) (not (verify-dir-exists (str "target/tmp" target))))))
(deftest test-file-from-cp-or-filesystem (deftest test-file-from-cp-or-filesystem
(is (is

Loading…
Cancel
Save