Skip to content

Instantly share code, notes, and snippets.

@pmonks
Created June 10, 2020 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmonks/0cabacfe71f06c295cf87f417e299f25 to your computer and use it in GitHub Desktop.
Save pmonks/0cabacfe71f06c295cf87f417e299f25 to your computer and use it in GitHub Desktop.
A tree seq on java.io.Files that doesn't follow symlinks (requires Java 1.7+)
(defn file-seq
"A tree seq on java.io.Files that doesn't follow symlinks"
[dir]
(tree-seq
(fn [^java.io.File f] (and (.isDirectory f) (not (java.nio.file.Files/isSymbolicLink (.toPath f)))))
(fn [^java.io.File d] (seq (.listFiles d)))
dir))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment