# Stolen from # https://github.com/pyrmont/ecstatic/blob/master/src/ecstatic/utilities.janet (defn mkpath [dirpath cache] (when (not (empty? dirpath)) (let [path @""] (each dir (string/split "/" dirpath) (if (not (empty? path)) (buffer/push-string path "/")) (buffer/push-string path dir) (let [s (string path)] (unless (in cache s) (os/mkdir s) (put cache s true))))))) (defn copy-file [source dest cache] (case ((os/stat source) :mode) :directory (mkpath dest cache) (spit dest (slurp source))))