Changeset 12700 for branches/0.20.x


Ignore:
Timestamp:
05/18/10 05:17:07 (14 years ago)
Author:
Mark Evenson
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.20.x/abcl/src/org/armedbear/lisp/Pathname.java

    r12697 r12700  
    356356            }
    357357            Debug.assertTrue(scheme != null);
    358             String authority = url.getAuthority();
     358            URI uri = null;
     359            try {
     360                uri = url.toURI().normalize();
     361            } catch (URISyntaxException e) {
     362                error(new LispError("Could not form URI from "
     363                                    + "'" + url + "'"
     364                                    + " because: " + e));
     365            }
     366            String authority = uri.getAuthority();
    359367            Debug.assertTrue(authority != null);
    360368
     
    368376           
    369377            // URI encode necessary characters
    370             URI uri = null;
    371             try {
    372                 uri = url.toURI().normalize();
    373             } catch (URISyntaxException e) {
    374                 error(new LispError("Could not URI escape characters in "
    375                                     + "'" + url + "'"
    376                                     + " because: " + e));
    377             }
    378 
    379378            String path = uri.getRawPath();
    380379            if (path == null) {
     
    19781977        } else if (pathname.isURL()) {
    19791978            if (pathname.getInputStream() != null) {
    1980                 return pathname;
     1979              // If there is no type, query or fragment, we check to
     1980              // see if there is URL available "underneath".
     1981              if (pathname.name != NIL
     1982                  && pathname.type == NIL
     1983                  && Symbol.GETF.execute(pathname.host, QUERY, NIL) == NIL
     1984                  && Symbol.GETF.execute(pathname.host, FRAGMENT, NIL) == NIL) {
     1985                Pathname p = new Pathname(pathname.getNamestring() + "/");
     1986                if (p.getInputStream() != null) {
     1987                  return p;
     1988                }
     1989              }
     1990              return pathname;
    19811991            }
    19821992        } else
Note: See TracChangeset for help on using the changeset viewer.