From 546e09e0d92be957e892d7f25f5151d3c795d990 Mon Sep 17 00:00:00 2001
From: Matthew Flatt <mflatt@racket-lang.org>
Date: Sun, 25 Jul 2010 10:51:19 -0500
Subject: [PATCH] add collection-file-path and splace collection trees at the
 file level

original commit: 5f1aa418f30f4df086c85ed18dfc5395468b1638
---
 collects/mzlib/file.rkt         |  8 +-------
 collects/mzlib/include.rkt      |  9 +++++----
 collects/mzlib/runtime-path.rkt | 13 +++++++------
 3 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/collects/mzlib/file.rkt b/collects/mzlib/file.rkt
index 2a6aa56..944e1b0 100644
--- a/collects/mzlib/file.rkt
+++ b/collects/mzlib/file.rkt
@@ -39,13 +39,7 @@
       (apply build-path p args)))
 
   (define (find-library name . cp)
-    (let ([dir (with-handlers ([exn:fail:filesystem? (lambda (exn) #f)])
-                 (if (null? cp)
-                     (collection-path "mzlib")
-                     (apply collection-path cp)))])
-      (and dir
-           (let ([file (build-path dir name)])
-             (and (file-exists? file) file)))))
+    (apply collection-file-path name cp))
 
   (define (-call-with-input-file* file thunk . flags)
     (let ([p (apply mz:open-input-file file flags)])
diff --git a/collects/mzlib/include.rkt b/collects/mzlib/include.rkt
index 8050a00..356f326 100644
--- a/collects/mzlib/include.rkt
+++ b/collects/mzlib/include.rkt
@@ -38,10 +38,11 @@
 		   "`lib' keyword is not followed by a sequence of string datums"
 		   stx
 		   fn))
-		(build-path (if (null? (cdr l))
-				(collection-path "mzlib")
-				(apply collection-path (cdr l)))
-			    (car l)))]
+                (apply collection-file-path
+                       (car l)
+                       (if (null? (cdr l))
+                           (list "mzlib")
+                           (cdr l))))]
 	     [else
 	      (raise-syntax-error
 	       #f
diff --git a/collects/mzlib/runtime-path.rkt b/collects/mzlib/runtime-path.rkt
index 82b87f4..e1ec2f8 100644
--- a/collects/mzlib/runtime-path.rkt
+++ b/collects/mzlib/runtime-path.rkt
@@ -78,12 +78,13 @@
                                             (let ([s (cadr p)])
                                               (if (regexp-match? #rx"[./]" s)
                                                   s
-                                                  (string-append s "/main.rkt"))))]
-                        [dir (if (and (null? (cddr p))
-                                      (null? (cdr strs)))
-                                 (collection-path "mzlib")
-                                 (apply collection-path (append (cddr p) (drop-right strs 1))))])
-                   (build-path dir (last strs)))]
+                                                  (string-append s "/main.rkt"))))])
+                   (apply collection-file-path
+                          (last strs)
+                          (if (and (null? (cddr p))
+                                   (null? (cdr strs)))
+                              (list "mzlib")
+                              (append (cddr p) (drop-right strs 1)))))]
                 [else (error 'runtime-path "unknown form: ~e" p)])))
            paths)))