~subsetpark/bagatto

ref: d6a048f9703c9294c7d61e32cb3831cb6922becf bagatto/src/writers.janet -rw-r--r-- 631 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
18
19
20
21
22
23
24
(import path)

(import src/util)
(import src/threads)

(defn handle-writes
  [output-dir]
  (fn [msg]
    (match msg
      :die (thread/exit)
      
      [:consume [:write path contents]]
      (let [path (if output-dir (path/join output-dir path) path)
            ppath (path/dirname path)]
        (threads/print "[WRITE] " path)
        (util/mkpath ppath)
        (spit path contents))
      
      [:consume [:copy from to]]
      (let [to (if output-dir (path/join output-dir to) to)
            ppath (path/dirname to)]
        (threads/print "[COPY] " to)
        (util/mkpath ppath)
        (util/copy-file from to)))))