Changeset 12696


Ignore:
Timestamp:
05/17/10 17:27:55 (12 years ago)
Author:
Mark Evenson
Message:

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
  • trunk/abcl/src/org/armedbear/lisp/Pathname.java

    r12695 r12696  
    356356            }
    357357            Debug.assertTrue(scheme != null);
    358       //      String authority = url.getAuthority();
    359358            URI uri = null;
    360359            try {
    361360                uri = url.toURI().normalize();
    362361            } catch (URISyntaxException e) {
    363                 error(new LispError("Could not URI escape characters in "
     362                error(new LispError("Could form URI from "
    364363                                    + "'" + url + "'"
    365364                                    + " because: " + e));
     
    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.