[armedbear-cvs] r12700 - branches/0.20.x/abcl/src/org/armedbear/lisp

Mark Evenson mevenson at common-lisp.net
Tue May 18 05:17:10 UTC 2010


Author: mevenson
Date: Tue May 18 01:17:07 2010
New Revision: 12700

Log:
Backport r12696: 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:
   branches/0.20.x/abcl/src/org/armedbear/lisp/Pathname.java

Modified: branches/0.20.x/abcl/src/org/armedbear/lisp/Pathname.java
==============================================================================
--- branches/0.20.x/abcl/src/org/armedbear/lisp/Pathname.java	(original)
+++ branches/0.20.x/abcl/src/org/armedbear/lisp/Pathname.java	Tue May 18 01:17:07 2010
@@ -355,7 +355,15 @@
                 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 form URI from "
+                                    + "'" + url + "'"
+                                    + " because: " + e));
+            }
+            String authority = uri.getAuthority();
             Debug.assertTrue(authority != null);
 
             host = NIL;
@@ -367,15 +375,6 @@
             device = NIL;
             
             // URI encode necessary characters
-            URI uri = null;
-            try { 
-                uri = url.toURI().normalize();
-            } catch (URISyntaxException e) {
-                error(new LispError("Could not URI escape characters in "
-                                    + "'" + url + "'"
-                                    + " because: " + e));
-            }
-
             String path = uri.getRawPath();
             if (path == null) {
                 path = "";
@@ -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