Attemt at tail end recursion
This commit is contained in:
parent
1c7720bdbf
commit
ed46ed1e0e
1 changed files with 21 additions and 1 deletions
|
@ -40,6 +40,25 @@
|
||||||
(file-from-cp resource-path))))
|
(file-from-cp resource-path))))
|
||||||
|
|
||||||
; TODO: fix recursion as we put function calls on callstack here
|
; TODO: fix recursion as we put function calls on callstack here
|
||||||
|
(defn copy-dir-2
|
||||||
|
[source-dir target-dir ignore-patterns]
|
||||||
|
(loop [source-list (.list source-dir)]
|
||||||
|
(when (not (nil? (first source-list)))
|
||||||
|
(let [f (first source-list)
|
||||||
|
target-file (io/file target-dir f)
|
||||||
|
source-file (io/file source-dir f)]
|
||||||
|
(println (str "frsit f: " f))
|
||||||
|
(if (.isFile source-file)
|
||||||
|
(do
|
||||||
|
(println (str "source file: " source-file))
|
||||||
|
(io/make-parents target-file)
|
||||||
|
(io/copy f target-file)
|
||||||
|
(recur (drop 1 source-list)))
|
||||||
|
(do
|
||||||
|
(println source-file)
|
||||||
|
(recur (concat (drop 1 source-list) (.list source-file)))))
|
||||||
|
))))
|
||||||
|
|
||||||
(defn copy-dir
|
(defn copy-dir
|
||||||
[source-dir target-dir ignore-patterns]
|
[source-dir target-dir ignore-patterns]
|
||||||
(let [source-list (.list source-dir)]
|
(let [source-list (.list source-dir)]
|
||||||
|
@ -48,6 +67,7 @@
|
||||||
source-file (io/file source-dir f)]
|
source-file (io/file source-dir f)]
|
||||||
(if (.isFile source-file)
|
(if (.isFile source-file)
|
||||||
(do
|
(do
|
||||||
|
(println source-file)
|
||||||
(io/make-parents target-file)
|
(io/make-parents target-file)
|
||||||
(io/copy f target-file))
|
(io/copy f target-file))
|
||||||
(copy-dir source-file target-file ignore-patterns))))))
|
(copy-dir source-file target-file ignore-patterns))))))
|
||||||
|
|
Loading…
Reference in a new issue