Changeset 12533


Ignore:
Timestamp:
03/14/10 19:09:04 (11 years ago)
Author:
Mark Evenson
Message:

Backport r12531 for :ABSOLUTE directory components for jar pathnames.

Location:
branches/0.19.x/abcl
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/0.19.x/abcl/doc/design/pathnames/abcl-jar-url.text

    r12503 r12533  
    33
    44Mark Evenson
    5 Created: 09 JAN 2010
    6 Modified: 22 FEB 2010
     5Created:  09 JAN 2010
     6Modified: 14 MAR 2010
    77
    88Notes towards sketching an implementation of "jar:" references to be
     
    9090    innermost.
    9191   
     92*   The DIRECTORY component of a JAR PATHNAME should be a list starting
     93    with the :ABSOLUTE keyword.  Even though hierarchial entries in
     94    jar files are stored in the form "foo/bar/a.lisp" not
     95    "/foo/bar/a.lisp", the meaning of DIRECTORY component better
     96    represented as an absolute path.
     97
     98BNF
     99---
     100
     101An incomplete BNF of the syntax of JAR PATHNAME would be:
     102
     103  JAR-PATHNAME ::= "jar:" URL "!/" [ ENTRY ]
     104
     105  URL ::= <URL parsable via java.net.URL.URL()>
     106        | JAR-FILE-PATHNAME
     107 
     108  JAR-FILE-PATHNAME ::= "jar:" "file:" JAR-NAMESTRING "!/" [ ENTRY ]
     109
     110  JAR-NAMESTRING  ::=  ABSOLUTE-FILE-NAMESTRING
     111                     | RELATIVE-FILE-NAMESTRING
     112
     113  ENTRY ::= [ DIRECTORY "/"]* FILE
     114
     115
     116### Notes
     117
     1181.  ABSOLUTE-FILE-NAMESTRING and RELATIVE-FILE-NAMESTRING use the
     119local filesystem conventions, meaning that on Windows this could
     120contain '\' as the directory separator, while an ENTRY always uses '/'
     121to separate directories within the jar proper.
    92122
    93123
     
    147177    }
    148178    pathname {
    149       directory: (:RELATIVE "b")
     179      directory: (:RELATIVE "b" "c")
    150180      name: "foo"
    151181      type: "abcl"
     
    159189// UC5 -- JAR Entry in a JAR Entry
    160190pathname: {
    161   namestring: "jar:jar:file:a/foo/baz.jar!/foo.abcl!/a/b/bar-1.cls"
     191  namestring: "jar:jar:file:a/foo/baz.jar!/c/d/foo.abcl!/a/b/bar-1.cls"
    162192  device: (
    163193    pathname: {
    164       device: "jar:file:"
     194      directory: (:RELATIVE "a" "foo")
    165195      name: "baz"
    166196      type: "jar"
    167197    }
    168198    pathname: {
     199      directory: (:RELATIVE "c" "d")
    169200      name: "foo"
    170201      type: "abcl"
    171202    }
    172203  )
     204  directory: (:ABSOLUTE "a" "b")
    173205  name: "bar-1"
    174206  type: "cls"
     
    181213    "http://example.org/abcl.jar"
    182214    pathname: {
    183       directory: (:relative "org" "armedbear" "lisp")
     215      directory: (:RELATIVE "org" "armedbear" "lisp")
    184216      name: "Version"
    185217      type: "class"
     
    222254     type: "jar"
    223255   )
    224    directory: (:RELATIVE "c" "d")
     256   directory: (:ABSOLUTE "c" "d")
    225257   name: "foo"
    226258   type: "lisp
  • branches/0.19.x/abcl/src/org/armedbear/lisp/Pathname.java

    r12513 r12533  
    288288                device = d.device;
    289289            }
    290             s = s.substring(separatorIndex + jarSeparator.length());
     290            s = "/" + s.substring(separatorIndex + jarSeparator.length());
    291291            Pathname p = new Pathname(s);
    292292            directory = p.directory;
     
    524524            Debug.assertTrue(false);
    525525        }
    526         sb.append(getDirectoryNamestring());
     526        String directoryNamestring = getDirectoryNamestring();
     527        if (isJar()) {
     528            if (directoryNamestring.startsWith(File.separator)) {
     529                sb.append(directoryNamestring.substring(1));
     530            }
     531        } else {
     532            sb.append(directoryNamestring);
     533        }
    527534        if (name instanceof AbstractString) {
    528535            String n = name.getStringValue();
     
    627634        p.type = type;
    628635        String path = p.getNamestring();
     636        StringBuilder result = new StringBuilder();
    629637        if (Utilities.isPlatformWindows) {
    630       StringBuilder result = new StringBuilder();
    631638      for (int i = 0; i < path.length(); i++) {
    632639    char c = path.charAt(i);
     
    638645      }
    639646      return result.toString();
    640         }
    641         return path;
     647        } else  {
     648            result.append(path);
     649        }
     650        // Entries in jar files are always relative, but Pathname
     651        // directories are :ABSOLUTE.
     652        if (result.length() > 1
     653          && result.substring(0, 1).equals("/")) {
     654            return result.substring(1);
     655        }
     656        return result.toString();
    642657    }
    643658
     
    15811596        }
    15821597
    1583         // A JAR always has relative directories
    1584         if (result.isJar()
    1585             && result.directory instanceof Cons
    1586             && result.directory.car().equals(Keyword.ABSOLUTE)) {
    1587             if (result.directory.cdr().equals(NIL)) {
    1588                 result.directory = NIL;
    1589             } else {
    1590                 ((Cons)result.directory).car = Keyword.RELATIVE;
    1591             }
    1592         }
     1598        // A JAR always has absolute directories
     1599        // if (result.isJar()
     1600        //     && result.directory instanceof Cons
     1601        //     && result.directory.car().equals(Keyword.ABSOLUTE)) {
     1602        //     if (result.directory.cdr().equals(NIL)) {
     1603        //         result.directory = NIL;
     1604        //     } else {
     1605        //         ((Cons)result.directory).car = Keyword.RELATIVE;
     1606        //     }
     1607        // }
    15931608
    15941609        if (pathname.name != NIL) {
     
    16991714        if (pathname.isWild()) {
    17001715            return error(new FileError("Bad place for a wild pathname.",
    1701               pathname));
     1716                                       pathname));
    17021717        }
    17031718        if (!(pathname.device instanceof Cons)) {
  • branches/0.19.x/abcl/src/org/armedbear/lisp/ZipCache.java

    r12504 r12533  
    160160                Date date = null;
    161161                try {
     162                    if (dateString == null) {
     163                        throw new ParseException("Failed to get HEAD for " + url, 0);
     164                    }
    162165                    date = RFC_1123.parse(dateString);
    163166                    long current = date.getTime();
  • branches/0.19.x/abcl/test/lisp/abcl/jar-file.lisp

    r12486 r12533  
    131131;;; wrapped in PROGN for easy disabling without a network connection
    132132;;; XXX come up with a better abstraction
     133
    133134(progn
    134135  (deftest jar-file.load.11
     
    245246       (pathname-directory p) (pathname-name p) (pathname-type p)))
    246247  "baz" "jar"
    247    nil "foo" "abcl")
     248   (:absolute) "foo" "abcl")
    248249   
    249250(deftest jar-file.pathname.3
     
    267268  (:relative "a") "baz" "jar"
    268269  (:relative "b" "c") "foo" "abcl"
    269   (:relative "this" "that") "foo-20" "cls")
     270  (:absolute "this" "that") "foo-20" "cls")
    270271
    271272(deftest jar-file.pathname.5
     
    279280  (:relative "a" "foo" ) "baz" "jar"
    280281  (:relative "b" "c") "foo" "abcl"
    281   (:relative "armed" "bear") "bar-1" "cls")
     282  (:absolute "armed" "bear") "bar-1" "cls")
    282283
    283284(deftest jar-file.pathname.6
     
    289290       (pathname-directory p) (pathname-name p) (pathname-type p)))
    290291  "http://example.org/abcl.jar"
    291   (:relative "org" "armedbear" "lisp") "Version" "class")
     292  (:absolute "org" "armedbear" "lisp") "Version" "class")
    292293
    293294(deftest jar-file.pathname.7
     
    317318       (pathname-directory d) (pathname-name d) (pathname-type d)
    318319       (pathname-directory p) (pathname-name p) (pathname-type p)))
    319   (:RELATIVE "a" "b") "foo" "jar"
    320   (:RELATIVE "c" "d") "foo" "lisp")
     320  (:relative "a" "b") "foo" "jar"
     321  (:absolute "c" "d") "foo" "lisp")
    321322
    322323     
Note: See TracChangeset for help on using the changeset viewer.