Changeset 15409


Ignore:
Timestamp:
10/14/20 07:07:16 (2 years ago)
Author:
Mark Evenson
Message:

pathname: various fixed in order to work Windows

Don't use #P reader macro in source as it can throw errors. Use
PATHNAME function instead.

LOAD for URL-PATHNAME working under Windows

TODO work through ramifications of needing to uri-encode whitespace
and other components for URLPathname.

Give up on java.net.{URL,URI} for construction of pathnames, as they
provide no help in uri encoding and fail to account for
MSDOS drive letters.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/JarPathname.java

    r15408 r15409  
    7171    if (p instanceof URLPathname) {
    7272      return JarPathname.create(JAR_URI_PREFIX
    73                                 + ((URLPathname)p).getNamestringAsURI()
     73                                + ((URLPathname)p).getNamestringAsURL()
    7474                                + JAR_URI_SUFFIX);
    7575    } else if (p instanceof Pathname) {
     
    280280
    281281    if (root instanceof URLPathname) {
    282       String ns = ((URLPathname)root).getNamestringAsURI();
     282      String ns = ((URLPathname)root).getNamestringAsURL();
    283283      sb.append(JAR_URI_PREFIX)
    284284        .append(ns)
  • trunk/abcl/src/org/armedbear/lisp/Pathname.java

    r15408 r15409  
    5757      return (JarPathname)JarPathname.create(p.getNamestring());
    5858    } else if (p instanceof URLPathname) {
    59       return (URLPathname)URLPathname.create(((URLPathname)p).getNamestringAsURI());
     59      return (URLPathname)URLPathname.create(((URLPathname)p).getNamestringAsURL());
    6060    } else {
    6161      return new Pathname(p);
     
    16631663    }
    16641664
    1665       if (pathname.getHost() != NIL) {
    1666         result.setHost(p.getHost());
    1667       } else {
    1668         result.setHost(d.getHost());
    1669       }
    1670 
    1671       if (pathname.getDevice() != NIL) {
     1665    if (pathname.getHost().equals(NIL)) {
     1666      result.setHost(d.getHost());
     1667    } else {
     1668      result.setHost(p.getHost());
     1669    }
     1670
     1671      if (!pathname.getDevice().equals(NIL)) {
    16721672        if (!Utilities.isPlatformWindows) {
    16731673          result.setDevice(p.getDevice());
     
    16761676        && p instanceof JarPathname) {
    16771677            result.setDevice(d.getDevice());
    1678           } else { 
     1678          } else {
    16791679            result.setDevice(p.getDevice());
    16801680          }
     
    16941694          }
    16951695        } else {
    1696           result.setDevice(d.getDevice());
     1696    if (p.isLocalFile() && d.isLocalFile()) {
     1697      result.setDevice(d.getDevice());
     1698    } else {
     1699      result.setDevice(p.getDevice());
     1700    }
    16971701        }
    16981702      }
  • trunk/abcl/src/org/armedbear/lisp/URLPathname.java

    r15408 r15409  
    200200      }
    201201    }
     202    if (Utilities.isPlatformWindows
     203  && getDevice() instanceof SimpleString) {
     204      sb.append(getDevice().getStringValue())
     205  .append(":");
     206    }
    202207    String directoryNamestring = getDirectoryNamestring();
    203208    sb.append(directoryNamestring);
     
    226231  }
    227232
    228   public String getNamestringAsURI() {
     233  // TODO URIEncode path components?
     234  public String getNamestringAsURL() {
    229235    LispObject schemeProperty = Symbol.GETF.execute(getHost(), SCHEME, NIL);
    230236    LispObject authorityProperty = Symbol.GETF.execute(getHost(), AUTHORITY, NIL);
     
    247253
    248254    if (!directory.equals("")) {
    249       path = directory + file;
     255      if (Utilities.isPlatformWindows
     256    && getDevice() instanceof SimpleString) {
     257  path = getDevice().getStringValue() + ":" + directory + file;
     258      } else {
     259  path = directory + file;
     260      }
    250261    } else {
    251262      path = file;
     
    262273    }
    263274
    264     try {
    265       URI uri = new URI(scheme, authority, path, query, fragment);
    266       return uri.toString();
    267     } catch (URISyntaxException e) {
    268       simple_error("Failed to construct a URI: ~a", this);
    269       return (String)UNREACHED;
    270     }
     275    StringBuffer result = new StringBuffer(scheme);
     276    result.append(":");
     277    result.append("//");
     278    if (authority != null) {
     279      result.append(authority);
     280    }
     281    if (!path.startsWith("/")) {
     282      result.append("/");
     283    }
     284    result.append(path);
     285
     286    if (query != null) {
     287      result.append("?").append(query);
     288    }
     289
     290    if (fragment != null) {
     291      result.append("#").append(fragment);
     292    }
     293    return result.toString();
    271294  }
    272295
  • trunk/abcl/src/org/armedbear/lisp/abcl-contrib.lisp

    r15398 r15409  
    5757   ;; it would minimally need to check version information.
    5858   (ignore-errors
    59      #p"jar:https://abcl.org/releases/1.7.1/abcl.jar!/")))
     59     (pathname "jar:https://abcl.org/releases/1.7.1/abcl.jar!/"))))
    6060
    6161(defun flatten (list)
     
    114114               :type "jar"))))
    115115      (let ((jar (some predicate entries)))
    116   (when jar
     116  (when (and jar (probe-file jar))
    117117    (return-from find-jar
    118             (make-pathname :device (list jar))))))))
     118            (make-pathname :device (list (probe-file jar)))))))))
    119119
    120120(defun find-system-jar ()
Note: See TracChangeset for help on using the changeset viewer.