add collection-file-path and splace collection trees at the file level

original commit: 5f1aa418f30f4df086c85ed18dfc5395468b1638
This commit is contained in:
Matthew Flatt 2010-07-25 10:51:19 -05:00
parent b9de711d8a
commit 546e09e0d9
3 changed files with 13 additions and 17 deletions

View File

@ -39,13 +39,7 @@
(apply build-path p args))) (apply build-path p args)))
(define (find-library name . cp) (define (find-library name . cp)
(let ([dir (with-handlers ([exn:fail:filesystem? (lambda (exn) #f)]) (apply collection-file-path name cp))
(if (null? cp)
(collection-path "mzlib")
(apply collection-path cp)))])
(and dir
(let ([file (build-path dir name)])
(and (file-exists? file) file)))))
(define (-call-with-input-file* file thunk . flags) (define (-call-with-input-file* file thunk . flags)
(let ([p (apply mz:open-input-file file flags)]) (let ([p (apply mz:open-input-file file flags)])

View File

@ -38,10 +38,11 @@
"`lib' keyword is not followed by a sequence of string datums" "`lib' keyword is not followed by a sequence of string datums"
stx stx
fn)) fn))
(build-path (if (null? (cdr l)) (apply collection-file-path
(collection-path "mzlib") (car l)
(apply collection-path (cdr l))) (if (null? (cdr l))
(car l)))] (list "mzlib")
(cdr l))))]
[else [else
(raise-syntax-error (raise-syntax-error
#f #f

View File

@ -78,12 +78,13 @@
(let ([s (cadr p)]) (let ([s (cadr p)])
(if (regexp-match? #rx"[./]" s) (if (regexp-match? #rx"[./]" s)
s s
(string-append s "/main.rkt"))))] (string-append s "/main.rkt"))))])
[dir (if (and (null? (cddr p)) (apply collection-file-path
(null? (cdr strs))) (last strs)
(collection-path "mzlib") (if (and (null? (cddr p))
(apply collection-path (append (cddr p) (drop-right strs 1))))]) (null? (cdr strs)))
(build-path dir (last strs)))] (list "mzlib")
(append (cddr p) (drop-right strs 1)))))]
[else (error 'runtime-path "unknown form: ~e" p)]))) [else (error 'runtime-path "unknown form: ~e" p)])))
paths))) paths)))