Last active
March 3, 2017 19:15
-
-
Save danielef/5d2218b2296679c32dbe39351e5ca538 to your computer and use it in GitHub Desktop.
Clojure Walk `path` recursivelly (with recur) and retrieves a vector with all regular files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn files-in-depth | |
"Walk `path` recursivelly and retrieves a vector with all regular files" | |
[path] | |
(loop [files [] acums [path]] | |
(if-not (empty? acums) | |
(if (Files/isDirectory (peek acums) (into-array (LinkOption/values))) | |
(let [stream (Files/newDirectoryStream (peek acums))] | |
(recur files (into (pop acums) (iterator-seq (.iterator stream))))) | |
(recur (conj files (peek acums)) (pop acums))) | |
files))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment