added a create? argument to get-dest-directory

svn: r10105
This commit is contained in:
Eli Barzilay 2008-06-03 01:47:31 +00:00
parent ae77624f28
commit 24d6e488ce
3 changed files with 14 additions and 8 deletions

View File

@ -18,7 +18,10 @@
[refer-to-existing-files #f]
[root-path #f])
(define/public (get-dest-directory) dest-dir)
(define/public (get-dest-directory [create? #f])
(when (and dest-dir create? (not (directory-exists? dest-dir)))
(make-directory* dest-dir))
dest-dir)
(define/public (get-substitutions) null)
@ -402,7 +405,7 @@
(string->path fn)
fn)
(let ([src-dir (path-only fn)]
[dest-dir (get-dest-directory)]
[dest-dir (get-dest-directory #t)]
[fn (file-name-from-path fn)])
(let ([src-file (build-path (or src-dir (current-directory)) fn)]
[dest-file (build-path (or dest-dir (current-directory)) fn)])
@ -421,7 +424,6 @@
(and (equal? s d)
(or (eof-object? s) (loop)))))))))))
(when (file-exists? dest-file) (delete-file dest-file))
(make-directory* (path-only dest-file))
(copy-file src-file dest-file))
(path->string fn)))))

View File

@ -998,11 +998,15 @@
(define/override (get-suffix) #"")
(define/override (get-dest-directory)
(define/override (get-dest-directory [create? #f])
(or (and (current-subdirectory)
(build-path (or (super get-dest-directory) (current-directory))
(current-subdirectory)))
(super get-dest-directory)))
(let ([d (build-path (or (super get-dest-directory)
(current-directory))
(current-subdirectory))])
(when (and create? (not (directory-exists? d)))
(make-directory* d))
d))
(super get-dest-directory create?)))
(define/override (derive-filename d)
(let ([fn (format "~a.html"

View File

@ -21,7 +21,7 @@
(define-runtime-path search-script "search.js")
(define (make-script user-dir? renderer sec ri)
(define dest-dir (send renderer get-dest-directory))
(define dest-dir (send renderer get-dest-directory #t))
(define span-classes null)
;; To make the index smaller, html contents is represented as one of these:
;; - a string