From ed46ed1e0e86b29c6d05e6ddf445057038dd11c4 Mon Sep 17 00:00:00 2001 From: Jan Krebs Date: Fri, 6 Dec 2019 20:10:56 +0100 Subject: [PATCH] Attemt at tail end recursion --- src/cryogen_core/classpath_able_io.clj | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/cryogen_core/classpath_able_io.clj b/src/cryogen_core/classpath_able_io.clj index da2aace..12c287c 100644 --- a/src/cryogen_core/classpath_able_io.clj +++ b/src/cryogen_core/classpath_able_io.clj @@ -40,7 +40,26 @@ (file-from-cp resource-path)))) ; TODO: fix recursion as we put function calls on callstack here -(defn copy-dir +(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 [source-dir target-dir ignore-patterns] (let [source-list (.list source-dir)] (doseq [f source-list] @@ -48,6 +67,7 @@ source-file (io/file source-dir f)] (if (.isFile source-file) (do + (println source-file) (io/make-parents target-file) (io/copy f target-file)) (copy-dir source-file target-file ignore-patterns))))))