       (.listFiles dir)))
 
 (defn old-files [files time-limit-hours]
-  (let [now (System/currentTimeMillis)
-        before (- now (* time-limit-hours MS-PER-HOUR))]
-    (filter #(< (.lastModified %) before) files)))
-    
+  (filter #(old-file? % time-limit-hours) files))
+
 (defn old-dlls [dir time-limit-hours]
   (old-files (device-adapter-dlls dir) time-limit-hours))
 

  (:require [clojure.xml])
  (:gen-class))

(def micromanager (file* "../.."))

(def MS-PER-HOUR (* 60 60 1000))


        one-hour-ago (doto (Calendar/getInstance)
                       (.add Calendar/HOUR -1))]
    (.format format (.getTime one-hour-ago))))

(defn result-file [bits mode]
  (File. micromanager (str "/results" bits ".txt")))

(defn old-file? [file time-limit-hours]
  (let [now (System/currentTimeMillis)
        before (- now (* time-limit-hours MS-PER-HOUR))]
    (< (.lastModified file) before)))

(defn vs-log-files []
  (->> micromanager
       file-seq
       (filter #(= "BuildLog.htm" (.getName %)))
       (filter #(.contains (.getAbsolutePath %) "Release"))
       (filter #(not (old-file? % 1)))))

(defn vs-log-text [f]
  (->> (slurp f :encoding "utf-16")
       (re-seq #"(?s)<pre>(.*?)</pre>")
       (drop 2)
       (map second)
       (apply str)))

(defn contains-errors? [log-text]
  (if (re-find #"\n[^\n]+\b([1-9]|[0-9][1-9]|[0-9][0-9][1-9])\b\serror\(s\)[^\n]+\n"
               log-text)
    true false))

(defn visual-studio-errors []
  (filter contains-errors? (map vs-log-text (vs-log-files))))

(defn javac-errors [result-text]
  (map first
