summaryrefslogtreecommitdiff
path: root/add_books
diff options
context:
space:
mode:
Diffstat (limited to 'add_books')
-rwxr-xr-xadd_books41
1 files changed, 41 insertions, 0 deletions
diff --git a/add_books b/add_books
new file mode 100755
index 0000000..9c38ec0
--- /dev/null
+++ b/add_books
@@ -0,0 +1,41 @@
+#|
+#!/usr/bin/env sh
+exec chibi-scheme -A `dirname $0` $0 $@
+|#
+
+(import
+ (scheme base)
+ (srfi 1)
+ (chibi)
+ (chibi filesystem)
+ (chibi io)
+ (chibi pathname)
+ (chibi sxml))
+
+(define outdir "www")
+(define bookdir "../books/out/")
+(define valid '("book-simple.pdf" "web.html" "web-simple.html" "cover.png"))
+
+(define (copy-books)
+ "Copy books"
+ (directory-fold-tree
+ bookdir
+ #f
+ #f
+ (lambda (file acc)
+ (let ((output (make-path outdir "books" (path-relative-to file bookdir))))
+ (if (member (path-strip-directory file) valid)
+ (begin
+ (display "Loading: ")
+ (display file)
+ (display " to:")
+ (display output)
+ (newline)
+ (create-directory* (path-directory output))
+ (call-with-output-file output
+ (lambda (x)
+ (send-file file x)))))))
+ #\null))
+
+
+(copy-books)