  
   (defn ^File create-file [base-dir codec file-key]
     "Create and return a File object with the name based on the file key codec and base dir"
-       (File. base-dir (str file-key 
+       (File. (clojure.java.io/file base-dir)
+              (str file-key 
                             (codec-extension codec)
                             "_" (System/nanoTime))))
       

	                                      (last s1)]))))

  
  (defn close-and-roll [{:keys [file ^OutputStream out] :as file-data} i]
    "Close the output stream and rename the file by removing the last _[number] suffix"
    (try
      (do 
        (.flush out)
        (.close out))
      (catch Exception e (error e e)))
    (let [file2 (File. (.getParent file)
                       (add-file-name-index
                         (clj-str/join "" (interpose "_" (-> (.getName file) (clj-str/split #"_") drop-last)))
                         i))]
      (if (.exists file2)

       (catch Exception e (do
                            (error e e)
                            (>!! error-ch e))))
     (.set ^AtomicReference (:updated file-data) (System/currentTimeMillis)))
  
  (defn write [{:keys [star error-ch] :as conn} file-key writer-f]
    "Writes the data in a thread safe manner to the file output stream based on the file-key
