~subsetpark/bagatto

ref: d6a048f9703c9294c7d61e32cb3831cb6922becf bagatto/src/util.janet -rw-r--r-- 494 bytes
d6a048f9 — Zach Smith More progress logging 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Stolen from
# https://github.com/pyrmont/ecstatic/blob/master/src/ecstatic/utilities.janet
(defn mkpath
  [dirpath]
  (when (not (empty? dirpath))
    (let [path @""]
      (each dir (string/split "/" dirpath)
        (if (not (empty? path))
          (buffer/push-string path "/"))
        (buffer/push-string path dir)
        (os/mkdir (string path))))))

(defn copy-file
  [source dest]
  (case ((os/stat source) :mode)
    :file (spit dest (slurp source))
    :directory (mkpath dest)))