[armedbear-cvs] r12696 - trunk/abcl/src/org/armedbear/lisp

Mark Evenson mevenson at common-lisp.net
Mon May 17 17:27:56 UTC 2010


Author: mevenson
Date: Mon May 17 13:27:55 2010
New Revision: 12696

Log:
TRUENAME for URL-PATHNAME ambigiously either a directory or file now (mostly) normalizes to the directory.

If there is no type, query or fragment in a URL-PATHNAME passed to
TRUENAME, it contains a NAME compoment, there is a resource accessible
(via java.net.URL.openConnection()), and there is a resource similarly
accessible via appending a "/" to the namestring, we return a pathname
that refers to the latter resource.

We do this to overcome the bug that autoloading ABCL from a *LISP-HOME*
that is a URL-PATHNAME fails for calls such as

  (autoload 'jclass-fields "java")

as Load.findLoadableFile() returns a pathname for which java.net.URL
actually opens "<*LISP-HOME*>/java/".  There is no way from the
java.net.URL implementation to determine that this is a directory
without reading from the stream.  The more correct solution would be
to program a restart which if the load fails it would retry with
another possible URL, but we hope that this heuristic will cover the
vast majority of usage as providers of URL references used as a
filesystem usually avoid such ambiguous references.



Modified:
   trunk/abcl/src/org/armedbear/lisp/Pathname.java

Modified: trunk/abcl/src/org/armedbear/lisp/Pathname.java
==============================================================================
--- trunk/abcl/src/org/armedbear/lisp/Pathname.java	(original)
+++ trunk/abcl/src/org/armedbear/lisp/Pathname.java	Mon May 17 13:27:55 2010
@@ -355,12 +355,11 @@
                 return;
             }
             Debug.assertTrue(scheme != null);
-      //      String authority = url.getAuthority();
             URI uri = null;
             try { 
                 uri = url.toURI().normalize();
             } catch (URISyntaxException e) {
-                error(new LispError("Could not URI escape characters in "
+                error(new LispError("Could form URI from "
                                     + "'" + url + "'"
                                     + " because: " + e));
             }
@@ -1977,7 +1976,18 @@
             }
         } else if (pathname.isURL()) {
             if (pathname.getInputStream() != null) {
-                return pathname;
+              // If there is no type, query or fragment, we check to
+              // see if there is URL available "underneath".
+              if (pathname.name != NIL 
+                  && pathname.type == NIL
+                  && Symbol.GETF.execute(pathname.host, QUERY, NIL) == NIL
+                  && Symbol.GETF.execute(pathname.host, FRAGMENT, NIL) == NIL) {
+                Pathname p = new Pathname(pathname.getNamestring() + "/");
+                if (p.getInputStream() != null) {
+                  return p;
+                }
+              }
+              return pathname;
             }
         } else
         jarfile: {




More information about the armedbear-cvs mailing list