0
听起来像一个简单的任务,也许它是。但是我刚刚采用这种方法 - 有没有更好的方法?clojure:将一个目录的内容复制到另一个目录
(require '[clojure.string :as string])
(defn mk-path [& args]
(string/join "/" args))
(defn move-contents-to-dir [dir1 dir2]
"Move all the contents of dir1 into dir2, which will be created if not existing."
(doseq [file (file-seq (io/file dir1))]
(let [base-removed (string/replace (str file)
(re-pattern (str "^" (str dir1)))
"")
new-path (mk-path dir2 base-removed)]
(io/make-parents new-path)
(when (not (.isDirectory file))
(io/copy file (io/file new-path))))))