Skip to content

Instantly share code, notes, and snippets.

@pjagielski
Last active August 29, 2015 14:06
Show Gist options
  • Save pjagielski/5864f55e179897819fdd to your computer and use it in GitHub Desktop.
Save pjagielski/5864f55e179897819fdd to your computer and use it in GitHub Desktop.
(ns file-counter.core
(:require [clojure.core.async :refer :all])
(:gen-class))
(defn count-files [count-chn path-chn path]
(doseq [file (.listFiles (java.io.File. path))]
(if (.isFile file)
(println (.getAbsolutePath file))
(>!! path-chn (.getAbsolutePath file)))))
(defn run [path]
(let [count-chn (chan) path-chn (chan)]
(go
(while true
(let [path (<! path-chn)]
(go (count-files count-chn path-chn path)))))
(>!! path-chn path)
(<!! (timeout 10000))))
(run "/tmp")
(defn -main [& args]
(run "/tmp"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment