This commit is contained in:
jem 2019-12-13 16:53:24 +01:00
parent 5ad40301bf
commit bb53615ed5
2 changed files with 46 additions and 30 deletions

View file

@ -68,16 +68,23 @@
paths :- [s/Str]]
(loop [paths paths
result []]
(when (not (empty? paths))
(if (not (empty? paths))
(do
(let [path-to-work-with (first paths)
path-content (.list (io/file (file-from-cp-or-filesystem
file-to-work-with (io/file (file-from-cp-or-filesystem
fs-prefix
(str base-path "/" path-to-work-with))))
file-list (filter #(.isFile (io/file %)) path-content)
dir-list (filter #(not (.isFile %)) path-content)]
(println path-content)
;(println file-list)
(into result file-list)))))
(str base-path "/" path-to-work-with)))
result (into result [path-to-work-with])]
(cond
(nil? file-to-work-with) []
(.isFile file-to-work-with) (recur (drop 1 paths) result)
:else
(recur (into (drop 1 paths)
(map #(str path-to-work-with "/" %)
(.list file-to-work-with)))
result)
)))
result)))
(defn copy-file
[source-file

View file

@ -27,21 +27,30 @@
(deftest test-get-file-paths-recursive
(is (=
["js/dummy.js"]
(sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" ["js/dummy.js"]))
[]
(sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" ["not-existing"])))
(is (=
["/css/dummy.css"
"css"
"/html/404.html"
"/html/403.html"
"/html"
"html"
"js/subdir/subdummy.js"
["js/dummy.js"]
(sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" ["js/dummy.js"])))
(is (=
["js/subdir"
"js/subdir/test.js"
"js/subdir"
"js/dummy.js"
"js"]
(sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" [""])))))
"js/subdir/subdummy.js"]
(sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" ["js/subdir"])))
(is (=
["."
"./css"
"./css/dummy.css"
"./js"
"./js/subdir"
"./js/subdir/test.js"
"./js/subdir/subdummy.js"
"./js/dummy.js"
"./html"
"./html/403.html"
"./html/404.html"]
(sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" ["."])))
)
; (deftest test-delete-file-recursive
; (is