master
jem 5 years ago
parent 5ad40301bf
commit bb53615ed5

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

@ -26,22 +26,31 @@
(.isDirectory (io/file path)))) (.isDirectory (io/file path))))
(deftest test-get-file-paths-recursive (deftest test-get-file-paths-recursive
(is (=
[]
(sut/get-file-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-file-paths-recursive "" "templates/themes/bootstrap4-test" ["js/dummy.js"])))
(is (= (is (=
["/css/dummy.css" ["js/subdir"
"css"
"/html/404.html"
"/html/403.html"
"/html"
"html"
"js/subdir/subdummy.js"
"js/subdir/test.js" "js/subdir/test.js"
"js/subdir" "js/subdir/subdummy.js"]
"js/dummy.js" (sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" ["js/subdir"])))
"js"] (is (=
(sut/get-file-paths-recursive "" "templates/themes/bootstrap4-test" [""]))))) ["."
"./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 ; (deftest test-delete-file-recursive
; (is ; (is

Loading…
Cancel
Save