Changeset 15391
- Timestamp:
- 10/10/20 21:43:20 (3 years ago)
- Location:
- trunk/abcl
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/Extensions.java
r14877 r15391 319 319 File file = File.createTempFile(prefix, suffix, null); 320 320 if (file != null) 321 return new Pathname(file.getPath());321 return Pathname.create(file.getPath()); 322 322 } catch (IllegalArgumentException e) { 323 323 // "Failed to create temporary file due to argument problems." … … 348 348 dir.delete(); 349 349 if (dir.mkdirs()) { 350 return new Pathname(dir + "/");350 return Pathname.create(dir + "/"); 351 351 } 352 352 } catch (Throwable t) { -
trunk/abcl/src/org/armedbear/lisp/FaslClassLoader.java
r14015 r15391 106 106 final LispThread thread = LispThread.currentThread(); 107 107 108 Pathname name = new Pathname(resourceName.substring("org/armedbear/lisp/".length()));108 Pathname name = Pathname.create(resourceName.substring("org/armedbear/lisp/".length())); 109 109 LispObject truenameFasl = Symbol.LOAD_TRUENAME_FASL.symbolValue(thread); 110 110 LispObject truename = Symbol.LOAD_TRUENAME.symbolValue(thread); -
trunk/abcl/src/org/armedbear/lisp/Interpreter.java
r14591 r15391 156 156 if (!initialDirectory.endsWith(File.separator)) 157 157 initialDirectory = initialDirectory.concat(File.separator); 158 Symbol.DEFAULT_PATHNAME_DEFAULTS.setSymbolValue( new Pathname(initialDirectory));158 Symbol.DEFAULT_PATHNAME_DEFAULTS.setSymbolValue(Pathname.create(initialDirectory)); 159 159 } 160 160 … … 331 331 if (i + 1 < args.length) { 332 332 if (arg.equals("--load")) 333 Load.load(Pathname.mergePathnames( new Pathname(args[i + 1]),333 Load.load(Pathname.mergePathnames(Pathname.create(args[i + 1]), 334 334 checkPathname(Symbol.DEFAULT_PATHNAME_DEFAULTS.getSymbolValue())), 335 335 false, false, true); -
trunk/abcl/src/org/armedbear/lisp/JarStream.java
r13440 r15391 63 63 super(Symbol.JAR_STREAM); 64 64 Debug.assertTrue(direction == Keyword.INPUT); 65 Debug.assertTrue(pathname. name!= NIL);65 Debug.assertTrue(pathname.getName() != NIL); 66 66 isInputStream = true; 67 67 -
trunk/abcl/src/org/armedbear/lisp/JavaClassLoader.java
r14363 r15391 87 87 public byte[] getFunctionClassBytes(String name) { 88 88 Pathname pathname 89 = new Pathname(name.substring("org/armedbear/lisp/".length())90 89 = Pathname.create(name.substring("org/armedbear/lisp/".length()) 90 + "." + Lisp._COMPILE_FILE_CLASS_EXTENSION_.symbolValue().getStringValue()); 91 91 return readFunctionBytes(pathname); 92 92 } … … 327 327 jcl.addURL(((Pathname) jar).toURL()); 328 328 } else if (jar instanceof AbstractString) { 329 jcl.addURL( new Pathname(jar.toString()).toURL());329 jcl.addURL(Pathname.create(jar.toString()).toURL()); 330 330 } else { 331 331 error(new TypeError(jar + " must be a pathname designator")); … … 338 338 LispObject list = NIL; 339 339 for(URL u : ((URLClassLoader) o).getURLs()) { 340 list = list.push( new Pathname(u));340 list = list.push(Pathname.create(u)); 341 341 } 342 342 return new Cons(new JavaObject(o), list.nreverse()); -
trunk/abcl/src/org/armedbear/lisp/Lisp.java
r15389 r15391 1359 1359 public static final LispObject loadCompiledFunction(final String namestring) 1360 1360 { 1361 Pathname name = new Pathname(namestring);1361 Pathname name = Pathname.create(namestring); 1362 1362 byte[] bytes = readFunctionBytes(name); 1363 1363 if (bytes != null) -
trunk/abcl/src/org/armedbear/lisp/Load.java
r14914 r15391 58 58 { 59 59 final LispThread thread = LispThread.currentThread(); 60 return load( new Pathname(filename),60 return load(Pathname.create(filename), 61 61 Symbol.LOAD_VERBOSE.symbolValue(thread) != NIL, 62 62 Symbol.LOAD_PRINT.symbolValue(thread) != NIL, … … 70 70 if (truename instanceof Pathname) { 71 71 Pathname t = (Pathname)truename; 72 if (t. name!= NIL73 && t. name!= null) {72 if (t.getName() != NIL 73 && t.getName() != null) { 74 74 return t; 75 75 } 76 76 } 77 77 final String COMPILE_FILE_TYPE = Lisp._COMPILE_FILE_TYPE_.symbolValue().getStringValue(); 78 if (name. type== NIL79 && (name. name != NIL || name.name!= null)) {80 Pathname lispPathname = new Pathname(name);81 lispPathname. type = new SimpleString("lisp");78 if (name.getType() == NIL 79 && (name.getName() != NIL || name.getName() != null)) { 80 Pathname lispPathname = Pathname.create(name); 81 lispPathname.setType(new SimpleString("lisp")); 82 82 lispPathname.invalidateNamestring(); 83 83 LispObject lisp = Pathname.truename(lispPathname, false); 84 Pathname abclPathname = new Pathname(name);85 abclPathname. type = new SimpleString(COMPILE_FILE_TYPE);84 Pathname abclPathname = Pathname.create(name); 85 abclPathname.setType(new SimpleString(COMPILE_FILE_TYPE)); 86 86 abclPathname.invalidateNamestring(); 87 87 LispObject abcl = Pathname.truename(abclPathname, false); … … 103 103 } 104 104 if (name.isJar()) { 105 if (name. type.equals(NIL)) {106 name. type = COMPILE_FILE_INIT_FASL_TYPE;105 if (name.getType().equals(NIL)) { 106 name.setType(COMPILE_FILE_INIT_FASL_TYPE); 107 107 name.invalidateNamestring(); 108 108 Pathname result = findLoadableFile(name); … … 110 110 return result; 111 111 } 112 name. type = new SimpleString(COMPILE_FILE_TYPE);112 name.setType(new SimpleString(COMPILE_FILE_TYPE)); 113 113 name.invalidateNamestring(); 114 114 result = findLoadableFile(name); … … 174 174 if (Utilities.checkZipFile(truename)) { 175 175 String n = truename.getNamestring(); 176 String name = Pathname.uriEncode(truename. name.getStringValue());176 String name = Pathname.uriEncode(truename.getName().getStringValue()); 177 177 if (n.startsWith("jar:")) { 178 178 n = "jar:" + n + "!/" + name + "." … … 185 185 + COMPILE_FILE_INIT_FASL_TYPE; 186 186 } 187 if (!((mergedPathname = new Pathname(n)) instanceof Pathname)) {187 if (!((mergedPathname = Pathname.create(n)) instanceof Pathname)) { 188 188 return error(new FileError((MessageFormat.format("Failed to address JAR-PATHNAME truename {0} for name {1}", truename.princToString(), name)), truename)); 189 189 } … … 192 192 if (initTruename == null || initTruename.equals(NIL)) { 193 193 // Maybe the enclosing JAR has been renamed? 194 Pathname p = new Pathname(mergedPathname);195 p. name = Keyword.WILD;194 Pathname p = Pathname.create(mergedPathname); 195 p.setName(Keyword.WILD); 196 196 p.invalidateNamestring(); 197 197 LispObject result = Pathname.MATCH_WILD_JAR_PATHNAME.execute(p); … … 294 294 Pathname pathname = null; 295 295 Pathname truename = null; 296 pathname = new Pathname(filename);296 pathname = Pathname.create(filename); 297 297 LispObject bootPath = Site.getLispHome(); 298 298 Pathname mergedPathname; … … 325 325 } 326 326 if (!bootPath.equals(NIL)) { 327 Pathname urlPathname = new Pathname(url);327 Pathname urlPathname = Pathname.create(url); 328 328 loadableFile = findLoadableFile(urlPathname); 329 329 truename = (Pathname)Pathname.truename(loadableFile); … … 339 339 // Look for a init FASL inside a packed FASL 340 340 if (truename != null 341 && truename. type.princToString().equals(COMPILE_FILE_TYPE) && Utilities.checkZipFile(truename)) {342 Pathname init = new Pathname(truename.getNamestring());343 init. type = COMPILE_FILE_INIT_FASL_TYPE;344 init. name = new SimpleString("__loader__");341 && truename.getType().princToString().equals(COMPILE_FILE_TYPE) && Utilities.checkZipFile(truename)) { 342 Pathname init = Pathname.create(truename.getNamestring()); 343 init.setType(COMPILE_FILE_INIT_FASL_TYPE); 344 init.setName(new SimpleString("__loader__")); 345 345 LispObject t = Pathname.truename(init); 346 346 if (t instanceof Pathname) { … … 526 526 if (!truename.equals(NIL)) { 527 527 if (truename instanceof Pathname) { 528 truePathname = new Pathname((Pathname)truename);528 truePathname = Pathname.create((Pathname)truename); 529 529 } else if (truename instanceof AbstractString) { 530 truePathname = new Pathname(truename.getStringValue());530 truePathname = Pathname.create(truename.getStringValue()); 531 531 } else { 532 532 Debug.assertTrue(false); 533 533 } 534 String type = truePathname. type.getStringValue();534 String type = truePathname.getType().getStringValue(); 535 535 if (type.equals(Lisp._COMPILE_FILE_TYPE_.symbolValue(thread).getStringValue()) 536 536 || type.equals(COMPILE_FILE_INIT_FASL_TYPE.toString())) { 537 Pathname truenameFasl = new Pathname(truePathname);537 Pathname truenameFasl = Pathname.create(truePathname); 538 538 thread.bindSpecial(Symbol.LOAD_TRUENAME_FASL, truenameFasl); 539 539 } 540 if (truePathname. type.getStringValue()540 if (truePathname.getType().getStringValue() 541 541 .equals(COMPILE_FILE_INIT_FASL_TYPE.getStringValue()) 542 542 && truePathname.isJar()) { 543 if (truePathname. device.cdr() != NIL ) {543 if (truePathname.getDevice().cdr() != NIL ) { 544 544 // We set *LOAD-TRUENAME* to the argument that 545 545 // a user would pass to LOAD. 546 Pathname enclosingJar = (Pathname)truePathname. device.cdr().car();547 truePathname. device = new Cons(truePathname.device.car(), NIL);548 truePathname. host = NIL;549 truePathname. directory = enclosingJar.directory;550 if (truePathname. directory.car().equals(Keyword.RELATIVE)) {551 truePathname. directory.setCar(Keyword.ABSOLUTE);546 Pathname enclosingJar = (Pathname)truePathname.getDevice().cdr().car(); 547 truePathname.setDevice(new Cons(truePathname.getDevice().car(), NIL)); 548 truePathname.setHost(NIL); 549 truePathname.setDirectory(enclosingJar.getDirectory()); 550 if (truePathname.getDirectory().car().equals(Keyword.RELATIVE)) { 551 truePathname.getDirectory().setCar(Keyword.ABSOLUTE); 552 552 } 553 truePathname. name = enclosingJar.name;554 truePathname. type = enclosingJar.type;553 truePathname.setName(enclosingJar.getName()); 554 truePathname.setType(enclosingJar.getType()); 555 555 truePathname.invalidateNamestring(); 556 556 } else { … … 559 559 // cases but this currently passes the tests. 560 560 if (!(truePathname.device.car() instanceof AbstractString)) { 561 assert truePathname. device.car() instanceof Pathname;562 Pathname p = new Pathname((Pathname)truePathname.device.car());561 assert truePathname.getDevice().car() instanceof Pathname; 562 Pathname p = Pathname.create((Pathname)truePathname.getDevice().car()); 563 563 truePathname 564 564 = (Pathname) probe_file.PROBE_FILE.execute(p); -
trunk/abcl/src/org/armedbear/lisp/LogicalPathname.java
r14793 r15391 38 38 import java.util.HashMap; 39 39 import java.util.StringTokenizer; 40 import java.text.MessageFormat; 40 41 41 42 public final class LogicalPathname extends Pathname 42 43 { 43 private static final String LOGICAL_PATHNAME_CHARS = 44 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-;*."; 45 46 private static final HashMap map = new HashMap(); 47 48 protected LogicalPathname() 49 { 50 } 51 52 protected LogicalPathname(Pathname p) { 53 super(p); 54 } 55 56 public LogicalPathname(String host, String rest) 57 { 58 final int limit = rest.length(); 59 for (int i = 0; i < limit; i++) { 60 char c = rest.charAt(i); 61 if (LOGICAL_PATHNAME_CHARS.indexOf(c) < 0) { 62 error(new ParseError("The character #\\" + c + " is not valid in a logical pathname.")); 63 return; 64 } 65 } 66 67 this.host = new SimpleString(host); 68 69 // "The device component of a logical pathname is always :UNSPECIFIC; 70 // no other component of a logical pathname can be :UNSPECIFIC." 71 device = Keyword.UNSPECIFIC; 72 73 int semi = rest.lastIndexOf(';'); 74 if (semi >= 0) { 75 // Directory. 76 String d = rest.substring(0, semi + 1); 77 directory = parseDirectory(d); 78 rest = rest.substring(semi + 1); 44 public static final String LOGICAL_PATHNAME_CHARS 45 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-;*."; 46 private static final HashMap map 47 = new HashMap(); 48 49 static public boolean isValidLogicalPathname(String namestring) { 50 if (!isValidURL(namestring)) { 51 String host = getHostString(namestring); 52 if (host != null 53 && LOGICAL_PATHNAME_TRANSLATIONS.get(new SimpleString(host)) != null) { 54 return true; 55 } 56 } 57 return false; 58 } 59 60 public static LogicalPathname create(String namestring) { 61 // parse host out then call create(host, rest); 62 if (LogicalPathname.isValidLogicalPathname(namestring)) { 63 String h = LogicalPathname.getHostString(namestring); 64 return LogicalPathname.create(h, 65 namestring.substring(namestring.indexOf(':') + 1)); 66 } 67 return null; // Ugh. I bet this is gonna cause problems. Tighten entrance points 68 } 69 70 public static LogicalPathname create(String host, String rest) { 71 // This may be "too late" in the creation chain to be meaningful? 72 SimpleString h = new SimpleString(host); 73 if (LOGICAL_PATHNAME_TRANSLATIONS.get(h) == null) { 74 // Logical pathnames are only valid when it's host exists 75 String message = MessageFormat.format("'{0}' is not a defined logical host", host); 76 error(new SimpleError(message)); 77 } 78 LogicalPathname result = new LogicalPathname(); 79 final int limit = rest.length(); 80 for (int i = 0; i < limit; i++) { 81 char c = rest.charAt (i); 82 if (LOGICAL_PATHNAME_CHARS.indexOf(c) < 0) { 83 error(new ParseError("The character #\\" + c + " is not valid in a logical pathname.")); 84 85 } 86 } 87 88 result.setHost(h); 89 90 // "The device component of a logical pathname is always :UNSPECIFIC; 91 // no other component of a logical pathname can be :UNSPECIFIC." 92 result.setDevice(Keyword.UNSPECIFIC); 93 94 int semi = rest.lastIndexOf(';'); 95 if (semi >= 0) { 96 // Directory. 97 String d = rest.substring(0, semi + 1); 98 result.setDirectory(parseDirectory(d)); 99 rest = rest.substring(semi + 1); 100 } else { 101 // "If a relative-directory-marker precedes the directories, the 102 // directory component parsed is as relative; otherwise, the 103 // directory component is parsed as absolute." 104 result.setDirectory(new Cons(Keyword.ABSOLUTE)); 105 } 106 107 int dot = rest.indexOf('.'); 108 if (dot >= 0) { 109 String n = rest.substring(0, dot); 110 if (n.equals("*")) { 111 result.setName(Keyword.WILD); 112 } else { 113 result.setName(new SimpleString(n.toUpperCase())); 114 } 115 rest = rest.substring(dot + 1); 116 dot = rest.indexOf('.'); 117 if (dot >= 0) { 118 String t = rest.substring(0, dot); 119 if (t.equals("*")) { 120 result.setType(Keyword.WILD); 79 121 } else { 80 // "If a relative-directory-marker precedes the directories, the 81 // directory component parsed is as relative; otherwise, the 82 // directory component is parsed as absolute." 83 directory = new Cons(Keyword.ABSOLUTE); 84 } 85 86 int dot = rest.indexOf('.'); 87 if (dot >= 0) { 88 String n = rest.substring(0, dot); 89 if (n.equals("*")) 90 name = Keyword.WILD; 91 else 92 name = new SimpleString(n.toUpperCase()); 93 rest = rest.substring(dot + 1); 94 dot = rest.indexOf('.'); 95 if (dot >= 0) { 96 String t = rest.substring(0, dot); 97 if (t.equals("*")) 98 type = Keyword.WILD; 99 else 100 type = new SimpleString(t.toUpperCase()); 101 // What's left is the version. 102 String v = rest.substring(dot + 1); 103 if (v.equals("*")) 104 version = Keyword.WILD; 105 else if (v.equals("NEWEST") || v.equals("newest")) 106 version = Keyword.NEWEST; 107 else 108 version = PACKAGE_CL.intern("PARSE-INTEGER").execute(new SimpleString(v)); 109 } else { 110 String t = rest; 111 if (t.equals("*")) 112 type = Keyword.WILD; 113 else 114 type = new SimpleString(t.toUpperCase()); 115 } 122 result.setType(new SimpleString(t.toUpperCase())); 123 } 124 // What's left is the version. 125 String v = rest.substring(dot + 1); 126 if (v.equals("*")) { 127 result.setVersion(Keyword.WILD); 128 } else if (v.equals("NEWEST") || v.equals("newest")) { 129 result.setVersion(Keyword.NEWEST); 116 130 } else { 117 String n = rest; 118 if (n.equals("*")) 119 name = Keyword.WILD; 120 else if (n.length() > 0) 121 name = new SimpleString(n.toUpperCase()); 122 } 123 } 124 125 private static final String LOGICAL_PATHNAME_COMPONENT_CHARS = 126 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-"; 127 128 public static final SimpleString canonicalizeStringComponent(AbstractString s) 129 130 { 131 final int limit = s.length(); 132 for (int i = 0; i < limit; i++) { 133 char c = s.charAt(i); 134 if (LOGICAL_PATHNAME_COMPONENT_CHARS.indexOf(c) < 0) { 135 error(new ParseError("Invalid character #\\" + c + 136 " in logical pathname component \"" + s + 137 '"')); 138 // Not reached. 139 return null; 140 } 141 } 142 return new SimpleString(s.getStringValue().toUpperCase()); 143 } 144 145 public static Pathname translateLogicalPathname(LogicalPathname pathname) 146 147 { 148 return (Pathname) Symbol.TRANSLATE_LOGICAL_PATHNAME.execute(pathname); 149 } 150 151 private static final LispObject parseDirectory(String s) 152 153 { 154 LispObject result; 155 if (s.charAt(0) == ';') { 156 result = new Cons(Keyword.RELATIVE); 157 s = s.substring(1); 158 } else 159 result = new Cons(Keyword.ABSOLUTE); 160 StringTokenizer st = new StringTokenizer(s, ";"); 161 while (st.hasMoreTokens()) { 162 String token = st.nextToken(); 163 LispObject obj; 164 if (token.equals("*")) 165 obj = Keyword.WILD; 166 else if (token.equals("**")) 167 obj = Keyword.WILD_INFERIORS; 168 else if (token.equals("..")) { 169 if (result.car() instanceof AbstractString) { 170 result = result.cdr(); 171 continue; 172 } 173 obj= Keyword.UP; 174 } else 175 obj = new SimpleString(token.toUpperCase()); 176 result = new Cons(obj, result); 177 } 178 return result.nreverse(); 179 } 180 181 @Override 182 public LispObject typeOf() 183 { 184 return Symbol.LOGICAL_PATHNAME; 185 } 186 187 @Override 188 public LispObject classOf() 189 { 190 return BuiltInClass.LOGICAL_PATHNAME; 191 } 192 193 @Override 194 public LispObject typep(LispObject type) 195 { 196 if (type == Symbol.LOGICAL_PATHNAME) 197 return T; 198 if (type == BuiltInClass.LOGICAL_PATHNAME) 199 return T; 200 return super.typep(type); 201 } 202 203 @Override 204 protected String getDirectoryNamestring() 205 { 206 StringBuilder sb = new StringBuilder(); 207 // "If a pathname is converted to a namestring, the symbols NIL and 208 // :UNSPECIFIC cause the field to be treated as if it were empty. That 209 // is, both NIL and :UNSPECIFIC cause the component not to appear in 210 // the namestring." 19.2.2.2.3.1 211 if (directory != NIL) { 212 LispObject temp = directory; 213 LispObject part = temp.car(); 214 if (part == Keyword.ABSOLUTE) { 215 } else if (part == Keyword.RELATIVE) 216 sb.append(';'); 217 else 218 error(new FileError("Unsupported directory component " + part.princToString() + ".", 219 this)); 220 temp = temp.cdr(); 221 while (temp != NIL) { 222 part = temp.car(); 223 if (part instanceof AbstractString) 224 sb.append(part.getStringValue()); 225 else if (part == Keyword.WILD) 226 sb.append('*'); 227 else if (part == Keyword.WILD_INFERIORS) 228 sb.append("**"); 229 else if (part == Keyword.UP) 230 sb.append(".."); 231 else 232 error(new FileError("Unsupported directory component " + part.princToString() + ".", 233 this)); 234 sb.append(';'); 235 temp = temp.cdr(); 236 } 237 } 238 return sb.toString(); 239 } 240 241 @Override 242 public String printObject() 243 { 244 final LispThread thread = LispThread.currentThread(); 245 boolean printReadably = (Symbol.PRINT_READABLY.symbolValue(thread) != NIL); 246 boolean printEscape = (Symbol.PRINT_ESCAPE.symbolValue(thread) != NIL); 247 StringBuilder sb = new StringBuilder(); 248 if (printReadably || printEscape) 249 sb.append("#P\""); 250 sb.append(host.getStringValue()); 251 sb.append(':'); 252 if (directory != NIL) 253 sb.append(getDirectoryNamestring()); 254 if (name != NIL) { 255 if (name == Keyword.WILD) 256 sb.append('*'); 257 else 258 sb.append(name.getStringValue()); 259 } 260 if (type != NIL) { 261 sb.append('.'); 262 if (type == Keyword.WILD) 263 sb.append('*'); 264 else 265 sb.append(type.getStringValue()); 266 } 267 if (version.integerp()) { 268 sb.append('.'); 269 int base = Fixnum.getValue(Symbol.PRINT_BASE.symbolValue(thread)); 270 if (version instanceof Fixnum) 271 sb.append(Integer.toString(((Fixnum)version).value, base).toUpperCase()); 272 else if (version instanceof Bignum) 273 sb.append(((Bignum)version).value.toString(base).toUpperCase()); 274 } else if (version == Keyword.WILD) { 275 sb.append(".*"); 276 } else if (version == Keyword.NEWEST) { 277 sb.append(".NEWEST"); 278 } 279 if (printReadably || printEscape) 280 sb.append('"'); 281 return sb.toString(); 282 } 131 result.setVersion(PACKAGE_CL.intern("PARSE-INTEGER").execute(new SimpleString(v))); 132 } 133 } else { 134 String t = rest; 135 if (t.equals("*")) { 136 result.setType(Keyword.WILD); 137 } else { 138 result.setType(new SimpleString(t.toUpperCase())); 139 } 140 } 141 } else { 142 String n = rest; 143 if (n.equals("*")) { 144 result.setName(Keyword.WILD); 145 } else if (n.length() > 0) { 146 result.setName(new SimpleString(n.toUpperCase())); 147 } 148 } 149 return result; 150 } 151 152 public static final SimpleString canonicalizeStringComponent(AbstractString s) { 153 final int limit = s.length(); 154 for (int i = 0; i < limit; i++) { 155 char c = s.charAt(i); 156 if (LOGICAL_PATHNAME_CHARS.indexOf(c) < 0) { 157 error(new ParseError("Invalid character #\\" + c + 158 " in logical pathname component \"" + s + 159 '"')); 160 // Not reached. 161 return null; 162 } 163 } 164 return new SimpleString(s.getStringValue().toUpperCase()); 165 } 166 167 public static Pathname translateLogicalPathname(LogicalPathname pathname) { 168 return (Pathname) Symbol.TRANSLATE_LOGICAL_PATHNAME.execute(pathname); 169 } 170 171 private static final LispObject parseDirectory(String s) { 172 LispObject result; 173 if (s.charAt(0) == ';') { 174 result = new Cons(Keyword.RELATIVE); 175 s = s.substring(1); 176 } else 177 result = new Cons(Keyword.ABSOLUTE); 178 StringTokenizer st = new StringTokenizer(s, ";"); 179 while (st.hasMoreTokens()) { 180 String token = st.nextToken(); 181 LispObject obj; 182 if (token.equals("*")) 183 obj = Keyword.WILD; 184 else if (token.equals("**")) 185 obj = Keyword.WILD_INFERIORS; 186 else if (token.equals("..")) { 187 if (result.car() instanceof AbstractString) { 188 result = result.cdr(); 189 continue; 190 } 191 obj= Keyword.UP; 192 } else 193 obj = new SimpleString(token.toUpperCase()); 194 result = new Cons(obj, result); 195 } 196 return result.nreverse(); 197 } 198 199 @Override 200 public LispObject typeOf() { 201 return Symbol.LOGICAL_PATHNAME; 202 } 203 204 @Override 205 public LispObject classOf() { 206 return BuiltInClass.LOGICAL_PATHNAME; 207 } 208 209 @Override 210 public LispObject typep(LispObject type) { 211 if (type == Symbol.LOGICAL_PATHNAME) 212 return T; 213 if (type == BuiltInClass.LOGICAL_PATHNAME) 214 return T; 215 return super.typep(type); 216 } 217 218 @Override 219 protected String getDirectoryNamestring() { 220 StringBuilder sb = new StringBuilder(); 221 // "If a pathname is converted to a namestring, the symbols NIL and 222 // :UNSPECIFIC cause the field to be treated as if it were empty. That 223 // is, both NIL and :UNSPECIFIC cause the component not to appear in 224 // the namestring." 19.2.2.2.3.1 225 if (getDirectory() != NIL) { 226 LispObject temp = getDirectory(); 227 LispObject part = temp.car(); 228 if (part == Keyword.ABSOLUTE) { 229 } else if (part == Keyword.RELATIVE) 230 sb.append(';'); 231 else 232 error(new FileError("Unsupported directory component " + part.princToString() + ".", 233 this)); 234 temp = temp.cdr(); 235 while (temp != NIL) { 236 part = temp.car(); 237 if (part instanceof AbstractString) 238 sb.append(part.getStringValue()); 239 else if (part == Keyword.WILD) 240 sb.append('*'); 241 else if (part == Keyword.WILD_INFERIORS) 242 sb.append("**"); 243 else if (part == Keyword.UP) 244 sb.append(".."); 245 else 246 error(new FileError("Unsupported directory component " + part.princToString() + ".", 247 this)); 248 sb.append(';'); 249 temp = temp.cdr(); 250 } 251 } 252 return sb.toString(); 253 } 254 255 @Override 256 public String printObject() { 257 final LispThread thread = LispThread.currentThread(); 258 boolean printReadably = (Symbol.PRINT_READABLY.symbolValue(thread) != NIL); 259 boolean printEscape = (Symbol.PRINT_ESCAPE.symbolValue(thread) != NIL); 260 StringBuilder sb = new StringBuilder(); 261 if (printReadably || printEscape) 262 sb.append("#P\""); 263 sb.append(getHost().getStringValue()); 264 sb.append(':'); 265 if (getDirectory() != NIL) 266 sb.append(getDirectoryNamestring()); 267 if (getName() != NIL) { 268 if (getName() == Keyword.WILD) 269 sb.append('*'); 270 else 271 sb.append(getName().getStringValue()); 272 } 273 if (getType() != NIL) { 274 sb.append('.'); 275 if (getType() == Keyword.WILD) 276 sb.append('*'); 277 else 278 sb.append(getType().getStringValue()); 279 } 280 if (getVersion().integerp()) { 281 sb.append('.'); 282 int base = Fixnum.getValue(Symbol.PRINT_BASE.symbolValue(thread)); 283 if (getVersion() instanceof Fixnum) 284 sb.append(Integer.toString(((Fixnum)getVersion()).value, base).toUpperCase()); 285 else if (getVersion() instanceof Bignum) 286 sb.append(((Bignum)getVersion()).value.toString(base).toUpperCase()); 287 } else if (getVersion() == Keyword.WILD) { 288 sb.append(".*"); 289 } else if (getVersion() == Keyword.NEWEST) { 290 sb.append(".NEWEST"); 291 } 292 if (printReadably || printEscape) 293 sb.append('"'); 294 return sb.toString(); 295 } 283 296 284 297 // ### canonicalize-logical-host host => canonical-host … … 324 337 if (Pathname.LOGICAL_PATHNAME_TRANSLATIONS.get(new SimpleString(h)) != null) { 325 338 // A defined logical pathname host. 326 return new LogicalPathname(h, s.substring(s.indexOf(':') + 1));339 return LogicalPathname.create(h, s.substring(s.indexOf(':') + 1)); 327 340 } 328 341 } … … 331 344 } 332 345 346 // "one or more uppercase letters, digits, and hyphens" 347 protected static String getHostString(String s) { 348 int colon = s.indexOf(':'); 349 if (colon >= 0) { 350 return s.substring(0, colon).toUpperCase(); 351 } else { 352 return null; 353 } 354 } 355 333 356 public long getLastModified() { 334 357 Pathname p = translateLogicalPathname(this); -
trunk/abcl/src/org/armedbear/lisp/Pathname.java
r15360 r15391 50 50 public class Pathname extends LispObject implements Serializable { 51 51 52 protected static Pathname create(Pathname p) { 53 return new Pathname(p); 54 } 55 56 protected static Pathname create() { 57 return new Pathname(); 58 } 59 60 public static Pathname create(String s) { 61 // TODO distinguish between logical hosts and schemes for URLs 62 // which we can meaningfully parse. 63 if (!isValidURL(s)) { 64 if (LogicalPathname.isValidLogicalPathname(s)) { 65 return LogicalPathname.create(s); 66 } 67 } 68 return new Pathname(s); 69 } 70 71 public static Pathname create(String s, String host) { 72 return LogicalPathname.create(s, host); 73 } 74 75 public static Pathname create(URL url) { 76 return new Pathname(url); 77 } 78 79 public static Pathname create(URI uri) { 80 return new Pathname(uri); 81 } 82 protected LispObject host = NIL; 83 public LispObject getHost() { 84 return host; 85 } 86 public LispObject setHost(LispObject host) { 87 this.host = host; 88 return this; 89 } 90 91 protected LispObject device = NIL; 92 public final LispObject getDevice() { 93 return device; 94 } 95 public LispObject setDevice(LispObject device) { 96 this.device = device; 97 return this; 98 } 99 100 protected LispObject directory = NIL; 101 public LispObject getDirectory() { 102 return directory; 103 } 104 public LispObject setDirectory(LispObject directory) { 105 this.directory = directory; 106 return this; 107 } 108 109 protected LispObject name = NIL; 110 public LispObject getName() { 111 return name; 112 } 113 public LispObject setName(LispObject name) { 114 this.name = name; 115 return this; 116 } 117 118 /** A string, NIL, :WILD or :UNSPECIFIC. */ 119 protected LispObject type = NIL; 120 public LispObject getType() { 121 return type; 122 } 123 public LispObject setType(LispObject type) { 124 this.type = type; 125 return this; 126 } 127 128 /** A positive integer, or NIL, :WILD, :UNSPECIFIC, or :NEWEST. */ 129 protected LispObject version = NIL; 130 public LispObject getVersion() { 131 return version; 132 } 133 134 public LispObject setVersion(LispObject version) { 135 this.version = version; 136 return this; 137 } 138 139 52 140 /** The path component separator used by internally generated 53 141 * path namestrings. … … 55 143 public final static char separator = '/'; 56 144 57 protected LispObject host = NIL; 58 protected LispObject device = NIL; 59 protected LispObject directory = NIL; 60 protected LispObject name = NIL; 61 // A string, NIL, :WILD or :UNSPECIFIC. 62 protected LispObject type = NIL; 63 // A positive integer, or NIL, :WILD, :UNSPECIFIC, or :NEWEST. 64 protected LispObject version = NIL; 65 66 private volatile String namestring; 145 private volatile String namestring; 67 146 68 147 /** The protocol for changing any instance field (i.e. 'host', … … 99 178 } 100 179 180 // If not protected, then inheriting classes cannot invoke their constructors 101 181 protected Pathname() {} 102 182 103 183 /** Copy constructor which shares no structure with the original. */ 104 pr otectedPathname(Pathname p) {184 private Pathname(Pathname p) { 105 185 if (p.host != NIL) { 106 186 if (p.host instanceof SimpleString) { 107 host = new SimpleString(((SimpleString)p. host).getStringValue());187 host = new SimpleString(((SimpleString)p.getHost()).getStringValue()); 108 188 } else if (p.host instanceof Symbol) { 109 189 host = p.host; 110 190 } else if (p.host instanceof Cons) { 111 host = new Cons((Cons)p. host);191 host = new Cons((Cons)p.getHost()); 112 192 } else { 113 193 Debug.assertTrue(false); … … 116 196 if (p.device != NIL) { 117 197 if (p.device instanceof SimpleString) { 118 device = new SimpleString(((SimpleString)p. device).getStringValue());198 device = new SimpleString(((SimpleString)p.getDevice()).getStringValue()); 119 199 } else if (p.device instanceof Cons) { 120 200 Cons jars = (Cons)p.device; … … 122 202 LispObject first = jars.car(); 123 203 if (first instanceof Pathname) { 124 ((Cons)device).car = new Pathname((Pathname)first);204 ((Cons)device).car = Pathname.create((Pathname)first); 125 205 } else { 126 206 Debug.assertTrue(false); … … 128 208 if (!jars.cdr().equals(NIL)) { 129 209 if (jars.cdr() instanceof Cons) { 130 ((Cons)device).cdr = new Cons( new Pathname((Pathname)jars.cdr().car()), NIL);210 ((Cons)device).cdr = new Cons(Pathname.create((Pathname)jars.cdr().car()), NIL); 131 211 } else { 132 212 Debug.assertTrue(false); … … 159 239 if (p.name != NIL) { 160 240 if (p.name instanceof SimpleString) { 161 name = new SimpleString(((SimpleString)p. name).getStringValue());241 name = new SimpleString(((SimpleString)p.getName()).getStringValue()); 162 242 } else if (p.name instanceof Symbol) { 163 243 name = p.name; … … 168 248 if (p.type != NIL) { 169 249 if (p.type instanceof SimpleString) { 170 type = new SimpleString(((SimpleString)p. type).getStringValue());250 type = new SimpleString(((SimpleString)p.getType()).getStringValue()); 171 251 } else if (p.type instanceof Symbol) { 172 252 type = p.type; … … 186 266 } 187 267 188 p ublicPathname(String s) {268 private Pathname(String s) { 189 269 init(s); 190 270 } … … 209 289 } 210 290 211 p ublicPathname(URL url) {291 private Pathname(URL url) { 212 292 // URL handling is now buried in init(String), as the URI 213 293 // escaping mechanism didn't interact well with '+' and other … … 216 296 } 217 297 218 p ublicPathname(URI uri) {298 private Pathname(URI uri) { 219 299 init(uri.toString()); 220 300 } … … 232 312 if (s.equals(".") || s.equals("./") 233 313 || (Utilities.isPlatformWindows && s.equals(".\\"))) { 234 directory = new Cons(Keyword.RELATIVE);314 setDirectory(new Cons(Keyword.RELATIVE)); 235 315 return; 236 316 } 237 317 if (s.equals("..") || s.equals("../")) { 238 directory = list(Keyword.RELATIVE, Keyword.UP);318 setDirectory(list(Keyword.RELATIVE, Keyword.UP)); 239 319 return; 240 320 } … … 257 337 } 258 338 259 host = new SimpleString(s.substring(2, shareIndex));260 device = new SimpleString(s.substring(shareIndex + 1, dirIndex));261 262 Pathname p = new Pathname(s.substring(dirIndex));263 directory = p.directory;264 name = p.name;265 type = p.type;266 version = p.version;339 setHost(new SimpleString(s.substring(2, shareIndex))); 340 setDevice(new SimpleString(s.substring(shareIndex + 1, dirIndex))); 341 342 Pathname p = Pathname.create(s.substring(dirIndex)); 343 setDirectory(p.getDirectory()); 344 setName(p.getName()); 345 setType(p.getType()); 346 setVersion(p.getVersion()); 267 347 invalidateNamestring(); 268 348 return; … … 282 362 jar = "jar:file:" + s.substring(i + jarSeparator.length()); 283 363 s = s.substring("jar:".length(), i + jarSeparator.length()); 284 Pathname p = new Pathname(s);285 jars = jars.push(p. device.car());364 Pathname p = Pathname.create(s); 365 jars = jars.push(p.getDevice().car()); 286 366 } 287 367 if (jar.startsWith("jar:file:")) { … … 309 389 // We allow "jar:file:baz.jar!/" to construct a relative 310 390 // path for jar files, so MERGE-PATHNAMES means something. 311 jarPathname = new Pathname(uri.getSchemeSpecificPart());391 jarPathname = Pathname.create(uri.getSchemeSpecificPart()); 312 392 } else { 313 jarPathname = new Pathname((new File(path)).getPath());393 jarPathname = Pathname.create((new File(path)).getPath()); 314 394 } 315 395 } else { 316 jarPathname = new Pathname("");396 jarPathname = Pathname.create(""); 317 397 } 318 398 jars = jars.push(jarPathname); … … 321 401 try { 322 402 url = new URL(jar.substring("jar:".length(), jar.length() - 2)); 323 Pathname p = new Pathname(url);403 Pathname p = Pathname.create(url); 324 404 jars = jars.push(p); 325 405 } catch (MalformedURLException e) { … … 330 410 } 331 411 jars = jars.nreverse(); 332 device = jars;412 setDevice(jars); 333 413 invalidateNamestring(); 334 414 return; … … 347 427 + ex.getMessage())); 348 428 } 349 Pathname d = new Pathname(url);350 if ( deviceinstanceof Cons) {429 Pathname d = Pathname.create(url); 430 if (getDevice() instanceof Cons) { 351 431 LispObject[] jars = d.copyToArray(); 352 432 // XXX Is this ever reached? If so, need to append lists 353 433 Debug.assertTrue(false); 354 434 } else { 355 device = d.device;435 setDevice(d.getDevice()); 356 436 } 357 437 s = "/" + s.substring(separatorIndex + jarSeparator.length()); 358 Pathname p = new Pathname("file:" + s); // Use URI escaping rules359 directory = p.directory;360 name = p.name;361 type = p.type;362 version = p.version;438 Pathname p = Pathname.create("file:" + s); // Use URI escaping rules 439 setDirectory(p.getDirectory()); 440 setName(p.getName()); 441 setType(p.getType()); 442 setVersion(p.getVersion()); 363 443 return; 364 444 } … … 397 477 path += "/"; 398 478 } 399 final Pathname p = new Pathname(path);400 this. host = p.host;401 this. device = p.device;402 this. directory = p.directory;403 this. name = p.name;404 this. type = p.type;405 this. version = p.version;479 final Pathname p = Pathname.create(path); 480 this.setHost(p.getHost()); 481 this.setDevice(p.getDevice()); 482 this.setDirectory(p.getDirectory()); 483 this.setName(p.getName()); 484 this.setType(p.getType()); 485 this.setVersion(p.getVersion()); 406 486 return; 407 487 } … … 423 503 } 424 504 425 host = NIL;426 host = host.push(SCHEME);427 host = host.push(new SimpleString(scheme));505 setHost(NIL); 506 setHost(getHost().push(SCHEME)); 507 setHost(getHost().push(new SimpleString(scheme))); 428 508 429 509 if (authority != null) { 430 host = host.push(AUTHORITY);431 host = host.push(new SimpleString(authority));432 } 433 434 device = NIL;510 setHost(getHost().push(AUTHORITY)); 511 setHost(getHost().push(new SimpleString(authority))); 512 } 513 514 setDevice(NIL); 435 515 436 516 // URI encode necessary characters … … 441 521 String query = uri.getRawQuery(); 442 522 if (query != null) { 443 host = host.push(QUERY);444 host = host.push(new SimpleString(query));523 setHost(getHost().push(QUERY)); 524 setHost(getHost().push(new SimpleString(query))); 445 525 } 446 526 String fragment = uri.getRawFragment(); 447 527 if (fragment != null) { 448 host = host.push(FRAGMENT);449 host = host.push(new SimpleString(fragment));450 } 451 Pathname p = new Pathname(path != null ? path : "");452 453 directory = p.directory;454 name = p.name;455 type = p.type;528 setHost(getHost().push(FRAGMENT)); 529 setHost(getHost().push(new SimpleString(fragment))); 530 } 531 Pathname p = Pathname.create(path != null ? path : ""); 532 533 setDirectory(p.getDirectory()); 534 setName(p.getName()); 535 setType(p.getType()); 456 536 457 host = host.nreverse();537 setHost(getHost().nreverse()); 458 538 invalidateNamestring(); 459 539 return; … … 477 557 if (Utilities.isPlatformWindows) { 478 558 if (s.length() >= 2 && s.charAt(1) == ':') { 479 device = new SimpleString(s.charAt(0));559 setDevice(new SimpleString(s.charAt(0))); 480 560 s = s.substring(2); 481 561 } … … 495 575 s = ""; 496 576 } 497 directory = parseDirectory(d);577 setDirectory(parseDirectory(d)); 498 578 } 499 579 if (s.startsWith(".") … … 501 581 && (s.indexOf(".", 1) == -1 502 582 || s.substring(s.length() -1).equals("."))) { 503 name = new SimpleString(s);583 setName(new SimpleString(s)); 504 584 return; 505 585 } … … 515 595 if (n != null) { 516 596 if (n.equals("*")) { 517 name = Keyword.WILD;518 } else { 519 name = new SimpleString(n);597 setName(Keyword.WILD); 598 } else { 599 setName(new SimpleString(n)); 520 600 } 521 601 } 522 602 if (t != null) { 523 603 if (t.equals("*")) { 524 type = Keyword.WILD;525 } else { 526 type = new SimpleString(t);604 setType(Keyword.WILD); 605 } else { 606 setType(new SimpleString(t)); 527 607 } 528 608 } … … 564 644 public LispObject getParts() { 565 645 LispObject parts = NIL; 566 parts = parts.push(new Cons("HOST", host));567 parts = parts.push(new Cons("DEVICE", device));568 parts = parts.push(new Cons("DIRECTORY", directory));569 parts = parts.push(new Cons("NAME", name));570 parts = parts.push(new Cons("TYPE", type));571 parts = parts.push(new Cons("VERSION", version));646 parts = parts.push(new Cons("HOST", getHost())); 647 parts = parts.push(new Cons("DEVICE", getDevice())); 648 parts = parts.push(new Cons("DIRECTORY", getDirectory())); 649 parts = parts.push(new Cons("NAME", getName())); 650 parts = parts.push(new Cons("TYPE", getType())); 651 parts = parts.push(new Cons("VERSION", getVersion())); 572 652 return parts.nreverse(); 573 653 } … … 618 698 } 619 699 620 public final LispObject getDevice() {621 return device;622 }623 624 700 public String getNamestring() { 625 701 if (namestring != null) { 626 702 return namestring; 627 703 } 628 if ( name == NIL && type!= NIL) {704 if (getName() == NIL && getType() != NIL) { 629 705 Debug.assertTrue(namestring == null); 630 706 return null; 631 707 } 632 if ( directoryinstanceof AbstractString) {708 if (getDirectory() instanceof AbstractString) { 633 709 Debug.assertTrue(false); 634 710 } … … 638 714 // is, both NIL and :UNSPECIFIC cause the component not to appear in 639 715 // the namestring." 19.2.2.2.3.1 640 if ( host!= NIL) {641 Debug.assertTrue( hostinstanceof AbstractString716 if (getHost() != NIL) { 717 Debug.assertTrue(getHost() instanceof AbstractString 642 718 || isURL()); 643 719 if (isURL()) { 644 LispObject scheme = Symbol.GETF.execute( host, SCHEME, NIL);645 LispObject authority = Symbol.GETF.execute( host, AUTHORITY, NIL);720 LispObject scheme = Symbol.GETF.execute(getHost(), SCHEME, NIL); 721 LispObject authority = Symbol.GETF.execute(getHost(), AUTHORITY, NIL); 646 722 Debug.assertTrue(scheme != NIL); 647 723 sb.append(scheme.getStringValue()); … … 652 728 } 653 729 } else if (this instanceof LogicalPathname) { 654 sb.append( host.getStringValue());730 sb.append(getHost().getStringValue()); 655 731 sb.append(':'); 656 732 } else { 657 733 // A UNC path 658 sb.append("//").append( host.getStringValue()).append("/");734 sb.append("//").append(getHost().getStringValue()).append("/"); 659 735 } 660 736 } 661 737 boolean uriEncoded = false; 662 if ( device== NIL) {663 } else if ( device== Keyword.UNSPECIFIC) {738 if (getDevice() == NIL) { 739 } else if (getDevice() == Keyword.UNSPECIFIC) { 664 740 } else if (isJar()) { 665 LispObject[] jars = ((Cons) device).copyToArray();741 LispObject[] jars = ((Cons) getDevice()).copyToArray(); 666 742 StringBuilder prefix = new StringBuilder(); 667 743 for (int i = 0; i < jars.length; i++) { … … 686 762 } 687 763 sb = prefix.append(sb); 688 } else if ( deviceinstanceof AbstractString) {689 sb.append( device.getStringValue());764 } else if (getDevice() instanceof AbstractString) { 765 sb.append(getDevice().getStringValue()); 690 766 if (this instanceof LogicalPathname 691 || host== NIL) {767 || getHost() == NIL) { 692 768 sb.append(':'); // non-UNC paths 693 769 } … … 708 784 sb.append(directoryNamestring); 709 785 } 710 if ( nameinstanceof AbstractString) {711 String n = name.getStringValue();786 if (getName() instanceof AbstractString) { 787 String n = getName().getStringValue(); 712 788 if (n.indexOf('/') >= 0) { 713 789 Debug.assertTrue(namestring == null); … … 719 795 sb.append(n); 720 796 } 721 } else if ( name== Keyword.WILD) {797 } else if (getName() == Keyword.WILD) { 722 798 sb.append('*'); 723 799 } 724 if ( type != NIL && type!= Keyword.UNSPECIFIC) {800 if (getType() != NIL && getType() != Keyword.UNSPECIFIC) { 725 801 sb.append('.'); 726 if ( typeinstanceof AbstractString) {727 String t = type.getStringValue();802 if (getType() instanceof AbstractString) { 803 String t = getType().getStringValue(); 728 804 // Allow Windows shortcuts to include TYPE 729 805 if (!(t.endsWith(".lnk") && Utilities.isPlatformWindows)) { … … 738 814 sb.append(t); 739 815 } 740 } else if ( type== Keyword.WILD) {816 } else if (getType() == Keyword.WILD) { 741 817 sb.append('*'); 742 818 } else { … … 746 822 747 823 if (isURL()) { 748 LispObject o = Symbol.GETF.execute( host, QUERY, NIL);824 LispObject o = Symbol.GETF.execute(getHost(), QUERY, NIL); 749 825 if (o != NIL) { 750 826 sb.append("?"); 751 827 sb.append(o.getStringValue()); 752 828 } 753 o = Symbol.GETF.execute( host, FRAGMENT, NIL);829 o = Symbol.GETF.execute(getHost(), FRAGMENT, NIL); 754 830 if (o != NIL) { 755 831 sb.append("#"); … … 759 835 760 836 if (this instanceof LogicalPathname) { 761 if ( version.integerp()) {837 if (getVersion().integerp()) { 762 838 sb.append('.'); 763 839 int base = Fixnum.getValue(Symbol.PRINT_BASE.symbolValue()); 764 if ( versioninstanceof Fixnum) {765 sb.append(Integer.toString(((Fixnum) version).value, base).toUpperCase());766 } else if ( versioninstanceof Bignum) {767 sb.append(((Bignum) version).value.toString(base).toUpperCase());768 } 769 } else if ( version== Keyword.WILD) {840 if (getVersion() instanceof Fixnum) { 841 sb.append(Integer.toString(((Fixnum) getVersion()).value, base).toUpperCase()); 842 } else if (getVersion() instanceof Bignum) { 843 sb.append(((Bignum) getVersion()).value.toString(base).toUpperCase()); 844 } 845 } else if (getVersion() == Keyword.WILD) { 770 846 sb.append(".*"); 771 } else if ( version== Keyword.NEWEST) {847 } else if (getVersion() == Keyword.NEWEST) { 772 848 sb.append(".NEWEST"); 773 849 } … … 788 864 // is, both NIL and :UNSPECIFIC cause the component not to appear in 789 865 // the namestring." 19.2.2.2.3.1 790 if ( directory != NIL && directory!= Keyword.UNSPECIFIC) {866 if (getDirectory() != NIL && getDirectory() != Keyword.UNSPECIFIC) { 791 867 final char separatorChar = '/'; 792 LispObject temp = directory;868 LispObject temp = getDirectory(); 793 869 LispObject part = temp.car(); 794 870 temp = temp.cdr(); … … 829 905 */ 830 906 protected String asEntryPath() { 831 Pathname p = new Pathname();832 p. directory = directory;833 p. name = name;834 p. type = type;907 Pathname p = Pathname.create(); 908 p.setDirectory(getDirectory()); 909 p.setName(getName()); 910 p.setType(getType()); 835 911 p.invalidateNamestring(); 836 912 String path = p.getNamestring(); … … 906 982 @Override 907 983 public int sxhash() { 908 return (( host.sxhash()909 ^ device.sxhash()910 ^ directory.sxhash()911 ^ name.sxhash()912 ^ type.sxhash()) & 0x7fffffff);984 return ((getHost().sxhash() 985 ^ getDevice().sxhash() 986 ^ getDirectory().sxhash() 987 ^ getName().sxhash() 988 ^ getType().sxhash()) & 0x7fffffff); 913 989 } 914 990 … … 926 1002 // We have a namestring. Check for pathname components that 927 1003 // can't be read from the namestring. 928 if (( host!= NIL && !isURL())929 || version!= NIL)1004 if ((getHost() != NIL && !isURL()) 1005 || getVersion() != NIL) 930 1006 { 931 1007 useNamestring = false; 932 } else if ( nameinstanceof AbstractString) {933 String n = name.getStringValue();1008 } else if (getName() instanceof AbstractString) { 1009 String n = getName().getStringValue(); 934 1010 if (n.equals(".") || n.equals("..")) { 935 1011 useNamestring = false; … … 965 1041 966 1042 sb.append("PATHNAME (with no namestring) "); 967 if ( host!= NIL) {1043 if (getHost() != NIL) { 968 1044 sb.append(":HOST "); 969 sb.append( host.printObject());1045 sb.append(getHost().printObject()); 970 1046 sb.append(" "); 971 1047 } 972 if ( device!= NIL) {1048 if (getDevice() != NIL) { 973 1049 sb.append(":DEVICE "); 974 sb.append( device.printObject());1050 sb.append(getDevice().printObject()); 975 1051 sb.append(" "); 976 1052 } 977 if ( directory!= NIL) {1053 if (getDirectory() != NIL) { 978 1054 sb.append(":DIRECTORY "); 979 sb.append( directory.printObject());1055 sb.append(getDirectory().printObject()); 980 1056 sb.append(" "); 981 1057 } 982 if ( name!= NIL) {1058 if (getName() != NIL) { 983 1059 sb.append(":NAME "); 984 sb.append( name.printObject());1060 sb.append(getName().printObject()); 985 1061 sb.append(" "); 986 1062 } 987 if ( type!= NIL) {1063 if (getType() != NIL) { 988 1064 sb.append(":TYPE "); 989 sb.append( type.printObject());1065 sb.append(getType().printObject()); 990 1066 sb.append(" "); 991 1067 } 992 if ( version!= NIL) {1068 if (getVersion() != NIL) { 993 1069 sb.append(":VERSION "); 994 sb.append( version.printObject());1070 sb.append(getVersion().printObject()); 995 1071 sb.append(" "); 996 1072 } … … 1010 1086 1011 1087 public static Pathname parseNamestring(String s) { 1012 return new Pathname(s);1088 return Pathname.create(s); 1013 1089 } 1014 1090 … … 1029 1105 URL url = new URL(s); 1030 1106 } catch (MalformedURLException e) { 1031 // Generating an exception is a heavy operation, 1032 // we want to try hard not to get into this branch, without 1033 // implementing the URL class ourselves 1034 return false; 1107 return false; 1035 1108 } 1036 1109 return true; … … 1063 1136 String s = namestring.getStringValue(); 1064 1137 if (!isValidURL(s)) { 1065 String h = getHostString(s);1138 String h = LogicalPathname.getHostString(s); 1066 1139 if (h != null && LOGICAL_PATHNAME_TRANSLATIONS.get(new SimpleString(h)) != null) { 1067 1140 // A defined logical pathname host. 1068 return new LogicalPathname(h, s.substring(s.indexOf(':') + 1));1069 } 1070 } 1071 return new Pathname(s);1141 return LogicalPathname.create(h, s.substring(s.indexOf(':') + 1)); 1142 } 1143 } 1144 return Pathname.create(s); 1072 1145 } 1073 1146 … … 1079 1152 1080 1153 // Look for a logical pathname host in the namestring. 1081 String h = getHostString(s);1154 String h = LogicalPathname.getHostString(s); 1082 1155 if (h != null) { 1083 1156 if (!h.equals(host.getStringValue())) { … … 1093 1166 if (LOGICAL_PATHNAME_TRANSLATIONS.get(host) != null) { 1094 1167 // A defined logical pathname host. 1095 return new LogicalPathname(host.getStringValue(), s);1168 return LogicalPathname.create(host.getStringValue(), s); 1096 1169 } 1097 1170 error(new LispError(host.princToString() + " is not defined as a logical pathname host.")); 1098 1171 // Not reached. 1099 1172 return null; 1100 }1101 1102 // "one or more uppercase letters, digits, and hyphens"1103 protected static String getHostString(String s) {1104 int colon = s.indexOf(':');1105 if (colon >= 0) {1106 return s.substring(0, colon).toUpperCase();1107 } else {1108 return null;1109 }1110 1173 } 1111 1174 … … 1126 1189 public LispObject execute(LispObject first, LispObject second) { 1127 1190 checkCaseArgument(second); // FIXME Why is this ignored? 1128 return coerceToPathname(first). host;1191 return coerceToPathname(first).getHost(); 1129 1192 } 1130 1193 } … … 1138 1201 public LispObject execute(LispObject first, LispObject second) { 1139 1202 checkCaseArgument(second); // FIXME Why is this ignored? 1140 return coerceToPathname(first). device;1203 return coerceToPathname(first).getDevice(); 1141 1204 } 1142 1205 } … … 1150 1213 public LispObject execute(LispObject first, LispObject second) { 1151 1214 checkCaseArgument(second); // FIXME Why is this ignored? 1152 return coerceToPathname(first). directory;1215 return coerceToPathname(first).getDirectory(); 1153 1216 } 1154 1217 } … … 1162 1225 public LispObject execute(LispObject first, LispObject second) { 1163 1226 checkCaseArgument(second); // FIXME Why is this ignored? 1164 return coerceToPathname(first). name;1227 return coerceToPathname(first).getName(); 1165 1228 } 1166 1229 } … … 1174 1237 public LispObject execute(LispObject first, LispObject second) { 1175 1238 checkCaseArgument(second); // FIXME Why is this ignored? 1176 return coerceToPathname(first). type;1239 return coerceToPathname(first).getType(); 1177 1240 } 1178 1241 } … … 1189 1252 @Override 1190 1253 public LispObject execute(LispObject arg) { 1191 return coerceToPathname(arg). version;1254 return coerceToPathname(arg).getVersion(); 1192 1255 } 1193 1256 } … … 1269 1332 third = coerceToPathname(third); 1270 1333 if (third instanceof LogicalPathname) { 1271 second = ((LogicalPathname) third). host;1334 second = ((LogicalPathname) third).getHost(); 1272 1335 } else { 1273 1336 return thread.setValues(parseNamestring(namestring), … … 1311 1374 return null; 1312 1375 } 1313 return new Pathname(namestring);1376 return Pathname.create(namestring); 1314 1377 } 1315 1378 … … 1383 1446 if (defaults != null) { 1384 1447 if (!hostSupplied) { 1385 host = defaults. host;1448 host = defaults.getHost(); 1386 1449 } 1387 1450 if (!directorySupplied) { 1388 directory = defaults. directory;1451 directory = defaults.getDirectory(); 1389 1452 } 1390 1453 if (!deviceSupplied) { 1391 device = defaults. device;1454 device = defaults.getDevice(); 1392 1455 } 1393 1456 if (!nameSupplied) { 1394 name = defaults. name;1457 name = defaults.getName(); 1395 1458 } 1396 1459 if (!typeSupplied) { 1397 type = defaults. type;1460 type = defaults.getType(); 1398 1461 } 1399 1462 if (!versionSupplied) { 1400 version = defaults. version;1463 version = defaults.getVersion(); 1401 1464 } 1402 1465 } … … 1411 1474 // Not a defined logical pathname host -- A UNC path 1412 1475 //warning(new LispError(host.printObject() + " is not defined as a logical pathname host.")); 1413 p = new Pathname();1476 p = Pathname.create(); 1414 1477 logical = false; 1415 p. host = host;1478 p.setHost(host); 1416 1479 } else { 1417 p = new LogicalPathname();1480 p = LogicalPathname.create(); 1418 1481 logical = true; 1419 p. host = logicalHost;1420 } 1421 p. device = Keyword.UNSPECIFIC;1482 p.setHost(logicalHost); 1483 } 1484 p.setDevice(Keyword.UNSPECIFIC); 1422 1485 } else { 1423 p = new Pathname();1486 p = Pathname.create(); 1424 1487 logical = false; 1425 1488 } … … 1431 1494 } 1432 1495 } else { 1433 p.device = device;1496 p.setDevice(device); 1434 1497 } 1435 1498 } … … 1447 1510 directory = directory.cdr(); 1448 1511 } 1449 p. directory = d.nreverse();1512 p.setDirectory(d.nreverse()); 1450 1513 } else if (directory == Keyword.WILD || directory == Keyword.WILD_INFERIORS) { 1451 p.directory = directory;1514 p.setDirectory(directory); 1452 1515 } else { 1453 1516 error(new LispError("Invalid directory component for logical pathname: " + directory.princToString())); 1454 1517 } 1455 1518 } else { 1456 p.directory = directory;1519 p.setDirectory(directory); 1457 1520 } 1458 1521 } 1459 1522 if (name != NIL) { 1460 1523 if (logical && name instanceof AbstractString) { 1461 p.name = LogicalPathname.canonicalizeStringComponent((AbstractString) name);1524 p.setName(LogicalPathname.canonicalizeStringComponent((AbstractString) name)); 1462 1525 } else if (name instanceof AbstractString) { 1463 p.name = validateStringComponent((AbstractString) name);1464 } else { 1465 p.name = name;1526 p.setName(validateStringComponent((AbstractString) name)); 1527 } else { 1528 p.setName(name); 1466 1529 } 1467 1530 } 1468 1531 if (type != NIL) { 1469 1532 if (logical && type instanceof AbstractString) { 1470 p.type = LogicalPathname.canonicalizeStringComponent((AbstractString) type);1471 } else { 1472 p.type = type;1533 p.setType(LogicalPathname.canonicalizeStringComponent((AbstractString) type)); 1534 } else { 1535 p.setType(type); 1473 1536 } 1474 1537 } 1475 1538 1476 p. version = version;1539 p.setVersion(version); 1477 1540 p.validateDirectory(true); 1478 1541 return p; … … 1496 1559 1497 1560 private final boolean validateDirectory(boolean signalError) { 1498 LispObject temp = directory;1561 LispObject temp = getDirectory(); 1499 1562 if (temp == Keyword.UNSPECIFIC) { 1500 1563 return true; … … 1579 1642 s = s.concat(File.separator); 1580 1643 } 1581 return new Pathname(s);1644 return Pathname.create(s); 1582 1645 } 1583 1646 case 1: … … 1614 1677 Debug.assertTrue(directory != null); // We should only be listing directories 1615 1678 1616 if (pathname. device.cdr() instanceof Cons) {1679 if (pathname.getDevice().cdr() instanceof Cons) { 1617 1680 return error(new FileError("Unimplemented directory listing of JAR within JAR.", pathname)); 1618 1681 } … … 1630 1693 SimpleString wildcardDirectory = new SimpleString(directory + "/"); 1631 1694 1632 ZipFile jar = ZipCache.get((Pathname)pathname. device.car());1695 ZipFile jar = ZipCache.get((Pathname)pathname.getDevice().car()); 1633 1696 LispObject matches; 1634 1697 for (Enumeration<? extends ZipEntry> entries = jar.entries(); … … 1648 1711 namestring = namestring.substring(0, namestring.lastIndexOf("!/") + 2) 1649 1712 + entry.getName(); 1650 Pathname p = new Pathname(namestring);1713 Pathname p = Pathname.create(namestring); 1651 1714 result = new Cons(p, result); 1652 1715 } … … 1680 1743 } 1681 1744 URI pathURI = (new File(path)).toURI(); 1682 p = new Pathname(pathURI);1745 p = Pathname.create(pathURI); 1683 1746 result = new Cons(p, result); 1684 1747 } … … 1719 1782 return new FileError("Not a wild pathname.", pathname); 1720 1783 } 1721 Pathname jarPathname = new Pathname(pathname);1722 jarPathname. directory = NIL;1723 jarPathname. name = NIL;1724 jarPathname. type = NIL;1784 Pathname jarPathname = Pathname.create(pathname); 1785 jarPathname.setDirectory(NIL); 1786 jarPathname.setName(NIL); 1787 jarPathname.setType(NIL); 1725 1788 jarPathname.invalidateNamestring(); 1726 1789 LispObject jarTruename = truename(jarPathname, false); … … 1735 1798 final SimpleString wildcard = new SimpleString(wild); 1736 1799 1737 if (pathname. device.cdr() instanceof Cons) {1738 ZipFile outerJar = ZipCache.get((Pathname)pathname. device.car());1739 String entryPath = ((Pathname)pathname. device.cdr().car()).getNamestring(); //???1800 if (pathname.getDevice().cdr() instanceof Cons) { 1801 ZipFile outerJar = ZipCache.get((Pathname)pathname.getDevice().car()); 1802 String entryPath = ((Pathname)pathname.getDevice().cdr().car()).getNamestring(); //??? 1740 1803 if (entryPath.startsWith("/")) { 1741 1804 entryPath = entryPath.substring(1); … … 1762 1825 namestring = namestring.substring(0, namestring.lastIndexOf("!/") + 2) 1763 1826 + entry.getName(); 1764 Pathname p = new Pathname(namestring);1827 Pathname p = Pathname.create(namestring); 1765 1828 result = new Cons(p, result); 1766 1829 } … … 1771 1834 } 1772 1835 } else { 1773 ZipFile jar = ZipCache.get((Pathname)pathname. device.car());1836 ZipFile jar = ZipCache.get((Pathname)pathname.getDevice().car()); 1774 1837 for (Enumeration<? extends ZipEntry> entries = jar.entries(); 1775 1838 entries.hasMoreElements();) … … 1784 1847 namestring = namestring.substring(0, namestring.lastIndexOf("!/") + 2) 1785 1848 + entry.getName(); 1786 Pathname p = new Pathname(namestring);1849 Pathname p = Pathname.create(namestring); 1787 1850 result = new Cons(p, result); 1788 1851 } … … 1795 1858 public boolean isAbsolute() { 1796 1859 if (!directory.equals(NIL) || !(directory == null)) { 1797 if ( directoryinstanceof Cons) {1798 if (((Cons) directory).car().equals(Keyword.ABSOLUTE)) {1860 if (getDirectory() instanceof Cons) { 1861 if (((Cons)getDirectory()).car().equals(Keyword.ABSOLUTE)) { 1799 1862 return true; 1800 1863 } … … 1821 1884 1822 1885 public boolean isJar() { 1823 return ( deviceinstanceof Cons);1886 return (getDevice() instanceof Cons); 1824 1887 } 1825 1888 … … 1842 1905 1843 1906 public boolean isURL() { 1844 return ( hostinstanceof Cons);1907 return (getHost() instanceof Cons); 1845 1908 } 1846 1909 1847 1910 public boolean isWild() { 1848 if ( host == Keyword.WILD || host== Keyword.WILD_INFERIORS) {1911 if (getHost() == Keyword.WILD || getHost() == Keyword.WILD_INFERIORS) { 1849 1912 return true; 1850 1913 } 1851 if ( device == Keyword.WILD || device== Keyword.WILD_INFERIORS) {1914 if (getDevice() == Keyword.WILD || getDevice() == Keyword.WILD_INFERIORS) { 1852 1915 return true; 1853 1916 } 1854 if ( directoryinstanceof Cons) {1855 if (memq(Keyword.WILD, directory)) {1917 if (getDirectory() instanceof Cons) { 1918 if (memq(Keyword.WILD, getDirectory())) { 1856 1919 return true; 1857 1920 } 1858 if (memq(Keyword.WILD_INFERIORS, directory)) {1921 if (memq(Keyword.WILD_INFERIORS, getDirectory())) { 1859 1922 return true; 1860 1923 } 1861 Cons d = (Cons) directory;1924 Cons d = (Cons) getDirectory(); 1862 1925 while (true) { 1863 1926 if (d.car() instanceof AbstractString) { … … 1873 1936 } 1874 1937 } 1875 if ( name == Keyword.WILD || name== Keyword.WILD_INFERIORS) {1938 if (getName() == Keyword.WILD || getName() == Keyword.WILD_INFERIORS) { 1876 1939 return true; 1877 1940 } 1878 if ( nameinstanceof AbstractString) {1879 if ( name.printObject().contains("*")) {1941 if (getName() instanceof AbstractString) { 1942 if (getName().printObject().contains("*")) { 1880 1943 return true; 1881 1944 } 1882 1945 } 1883 if ( type == Keyword.WILD || type== Keyword.WILD_INFERIORS) {1946 if (getType() == Keyword.WILD || getType() == Keyword.WILD_INFERIORS) { 1884 1947 return true; 1885 1948 } 1886 if ( typeinstanceof AbstractString) {1887 if ( type.printObject().contains("*")) {1949 if (getType() instanceof AbstractString) { 1950 if (getType().printObject().contains("*")) { 1888 1951 return true; 1889 1952 } 1890 1953 } 1891 if ( version == Keyword.WILD || version== Keyword.WILD_INFERIORS) {1954 if (getVersion() == Keyword.WILD || getVersion() == Keyword.WILD_INFERIORS) { 1892 1955 return true; 1893 1956 } … … 1914 1977 } 1915 1978 if (second == Keyword.DIRECTORY) { 1916 if (pathname. directoryinstanceof Cons) {1917 if (memq(Keyword.WILD, pathname. directory)) {1979 if (pathname.getDirectory() instanceof Cons) { 1980 if (memq(Keyword.WILD, pathname.getDirectory())) { 1918 1981 return T; 1919 1982 } 1920 if (memq(Keyword.WILD_INFERIORS, pathname. directory)) {1983 if (memq(Keyword.WILD_INFERIORS, pathname.getDirectory())) { 1921 1984 return T; 1922 1985 } … … 1926 1989 LispObject value; 1927 1990 if (second == Keyword.HOST) { 1928 value = pathname. host;1991 value = pathname.getHost(); 1929 1992 } else if (second == Keyword.DEVICE) { 1930 value = pathname. device;1993 value = pathname.getDevice(); 1931 1994 } else if (second == Keyword.NAME) { 1932 value = pathname. name;1995 value = pathname.getName(); 1933 1996 } else if (second == Keyword.TYPE) { 1934 value = pathname. type;1997 value = pathname.getType(); 1935 1998 } else if (second == Keyword.VERSION) { 1936 value = pathname. version;1999 value = pathname.getVersion(); 1937 2000 } else { 1938 2001 return program_error("Unrecognized keyword " … … 1993 2056 { 1994 2057 Pathname result; 1995 Pathname p = new Pathname(pathname);2058 Pathname p = Pathname.create(pathname); 1996 2059 Pathname d; 1997 2060 1998 2061 if (pathname instanceof LogicalPathname) { 1999 result = new LogicalPathname();2000 d = new Pathname(defaultPathname);2062 result = LogicalPathname.create(); 2063 d = Pathname.create(defaultPathname); 2001 2064 } else { 2002 result = new Pathname();2065 result = Pathname.create(); 2003 2066 if (defaultPathname instanceof LogicalPathname) { 2004 2067 d = LogicalPathname.translateLogicalPathname((LogicalPathname) defaultPathname); 2005 2068 } else { 2006 d = new Pathname(defaultPathname);2007 } 2008 } 2009 if (pathname. host!= NIL) {2010 result.host = p.host;2069 d = Pathname.create(defaultPathname); 2070 } 2071 } 2072 if (pathname.getHost() != NIL) { 2073 result.setHost(p.getHost()); 2011 2074 } else { 2012 result.host = d.host;2013 } 2014 2015 if (pathname. device!= NIL) { // XXX if device represent JARs we want to merge2016 result.device = p.device;2075 result.setHost(d.getHost()); 2076 } 2077 2078 if (pathname.getDevice() != NIL) { // XXX if device represent JARs we want to merge 2079 result.setDevice(p.getDevice()); 2017 2080 } else { 2018 2081 if (!p.isURL()) { … … 2022 2085 // relative DIRECTORY, then on non-MSDOG, set its 2023 2086 // device to :UNSPECIFIC. 2024 if (pathname. host== NIL2025 && pathname. device== NIL2087 if (pathname.getHost() == NIL 2088 && pathname.getDevice() == NIL 2026 2089 && d.isJar() 2027 2090 && !Utilities.isPlatformWindows) { 2028 if (pathname. directory!= NIL2029 && pathname. directory.car() == Keyword.ABSOLUTE) {2030 result.device = Keyword.UNSPECIFIC;2091 if (pathname.getDirectory() != NIL 2092 && pathname.getDirectory().car() == Keyword.ABSOLUTE) { 2093 result.setDevice(Keyword.UNSPECIFIC); 2031 2094 } else { 2032 result.device = d.device;2095 result.setDevice(d.getDevice()); 2033 2096 } 2034 2097 } else { 2035 result.device = d.device;2098 result.setDevice(d.getDevice()); 2036 2099 } 2037 2100 } … … 2039 2102 2040 2103 if (pathname.isJar()) { 2041 Cons jars = (Cons)result. device;2104 Cons jars = (Cons)result.getDevice(); 2042 2105 LispObject jar = jars.car; 2043 2106 if (jar instanceof Pathname) { 2044 Pathname defaults = new Pathname(d);2107 Pathname defaults = Pathname.create(d); 2045 2108 if (defaults.isJar()) { 2046 defaults.device = NIL;2109 defaults.setDevice(NIL); 2047 2110 } 2048 2111 Pathname o = mergePathnames((Pathname)jar, defaults); 2049 if (o. directoryinstanceof Cons2050 && ((Cons)o. directory).length() == 1) { // i.e. (:ABSOLUTE) or (:RELATIVE)2051 o.directory = NIL;2112 if (o.getDirectory() instanceof Cons 2113 && ((Cons)o.getDirectory()).length() == 1) { // i.e. (:ABSOLUTE) or (:RELATIVE) 2114 o.setDirectory(NIL); 2052 2115 } 2053 2116 ((Cons)result.device).car = o; 2054 2117 } 2055 result. directory = p.directory;2118 result.setDirectory(p.getDirectory()); 2056 2119 } else { 2057 result.directory = mergeDirectories(p.directory, d.directory);2058 } 2059 2060 if (pathname. name!= NIL) {2061 result.name = p.name;2120 result.setDirectory(mergeDirectories(p.getDirectory(), d.getDirectory())); 2121 } 2122 2123 if (pathname.getName() != NIL) { 2124 result.setName(p.getName()); 2062 2125 } else { 2063 result.name = d.name;2064 } 2065 if (pathname. type!= NIL) {2066 result.type = p.type;2126 result.setName(d.getName()); 2127 } 2128 if (pathname.getType() != NIL) { 2129 result.setType(p.getType()); 2067 2130 } else { 2068 result.type = d.type;2131 result.setType(d.getType()); 2069 2132 } 2070 2133 // CLtLv2 MERGE-PATHNAMES … … 2085 2148 // version missing, the default version is used." 2086 2149 2087 if (p. version!= NIL) {2088 result.version = p.version;2089 } else if (p. name== NIL) {2090 if (defaultPathname. version== NIL) {2091 result.version = defaultVersion;2092 } else { 2093 result.version = defaultPathname.version;2150 if (p.getVersion() != NIL) { 2151 result.setVersion(p.getVersion()); 2152 } else if (p.getName() == NIL) { 2153 if (defaultPathname.getVersion() == NIL) { 2154 result.setVersion(defaultVersion); 2155 } else { 2156 result.setVersion(defaultPathname.getVersion()); 2094 2157 } 2095 2158 } else if (defaultVersion == NIL) { 2096 result.version = p.version;2159 result.setVersion(p.getVersion()); 2097 2160 } 2098 if (result. version== NIL) {2099 result.version = defaultVersion;2161 if (result.getVersion() == NIL) { 2162 result.setVersion(defaultVersion); 2100 2163 } 2101 2164 2102 2165 if (pathname instanceof LogicalPathname) { 2103 2166 // When we're returning a logical 2104 result. device = Keyword.UNSPECIFIC;2105 if (result. directory.listp()) {2106 LispObject original = result. directory;2167 result.setDevice(Keyword.UNSPECIFIC); 2168 if (result.getDirectory().listp()) { 2169 LispObject original = result.getDirectory(); 2107 2170 LispObject canonical = NIL; 2108 2171 while (original != NIL) { … … 2114 2177 original = original.cdr(); 2115 2178 } 2116 result. directory = canonical.nreverse();2117 } 2118 if (result. nameinstanceof AbstractString) {2119 result.name = LogicalPathname.canonicalizeStringComponent((AbstractString) result.name);2120 } 2121 if (result. typeinstanceof AbstractString) {2122 result.type = LogicalPathname.canonicalizeStringComponent((AbstractString) result.type);2179 result.setDirectory(canonical.nreverse()); 2180 } 2181 if (result.getName() instanceof AbstractString) { 2182 result.setName(LogicalPathname.canonicalizeStringComponent((AbstractString) result.getName())); 2183 } 2184 if (result.getType() instanceof AbstractString) { 2185 result.setType(LogicalPathname.canonicalizeStringComponent((AbstractString) result.getType())); 2123 2186 } 2124 2187 } … … 2205 2268 } else { 2206 2269 try { 2207 result = new Pathname(file.getCanonicalPath());2270 result = Pathname.create(file.getCanonicalPath()); 2208 2271 } catch (IOException e) { 2209 2272 return error(new FileError(e.getMessage(), pathname)); … … 2211 2274 } 2212 2275 if (Utilities.isPlatformUnix) { 2213 result. device = Keyword.UNSPECIFIC;2276 result.setDevice(Keyword.UNSPECIFIC); 2214 2277 } 2215 2278 return result; … … 2219 2282 // If there is no type, query or fragment, we check to 2220 2283 // see if there is URL available "underneath". 2221 if (pathname. name!= NIL2222 && pathname. type== NIL2223 && Symbol.GETF.execute(pathname. host, QUERY, NIL) == NIL2224 && Symbol.GETF.execute(pathname. host, FRAGMENT, NIL) == NIL) {2225 Pathname p = new Pathname(pathname.getNamestring() + "/");2284 if (pathname.getName() != NIL 2285 && pathname.getType() == NIL 2286 && Symbol.GETF.execute(pathname.getHost(), QUERY, NIL) == NIL 2287 && Symbol.GETF.execute(pathname.getHost(), FRAGMENT, NIL) == NIL) { 2288 Pathname p = Pathname.create(pathname.getNamestring() + "/"); 2226 2289 if (p.getInputStream() != null) { 2227 2290 return p; … … 2233 2296 jarfile: { 2234 2297 // Possibly canonicalize jar file directory 2235 Cons jars = (Cons) pathname. device;2298 Cons jars = (Cons) pathname.getDevice(); 2236 2299 LispObject o = jars.car(); 2237 2300 if (!(o instanceof Pathname)) { … … 2367 2430 // XXX We only return the bytes of an entry in a JAR 2368 2431 Debug.assertTrue(entryPath != null); 2369 ZipFile jarFile = ZipCache.get((Pathname) device.car());2432 ZipFile jarFile = ZipCache.get((Pathname)getDevice().car()); 2370 2433 Debug.assertTrue(jarFile != null); 2371 2434 // Is this a JAR within a JAR? 2372 if ( device.cdr() instanceof Cons) {2373 Pathname inner = (Pathname) device.cdr().car();2435 if (getDevice().cdr() instanceof Cons) { 2436 Pathname inner = (Pathname) getDevice().cdr().car(); 2374 2437 InputStream input = Utilities.getInputStream(jarFile, inner); 2375 2438 ZipInputStream zipInputStream = new ZipInputStream(input); … … 2430 2493 // 4. Entry in JAR in JAR 2431 2494 String entryPath = asEntryPath(); 2432 Cons d = (Cons) device;2495 Cons d = (Cons)getDevice(); 2433 2496 if (d.cdr().equals(NIL)) { 2434 2497 if (entryPath.length() == 0) { … … 2440 2503 // 3. Entry in JAR 2441 2504 final ZipEntry entry 2442 = ZipCache.get((Pathname) device.car()).getEntry(entryPath);2505 = ZipCache.get((Pathname)getDevice().car()).getEntry(entryPath); 2443 2506 if (entry == null) { 2444 2507 return 0; … … 2596 2659 Pathname p = coerceToPathname(arg); 2597 2660 StringBuilder sb = new StringBuilder(); 2598 if (p. nameinstanceof AbstractString) {2599 sb.append(p. name.getStringValue());2600 } else if (p. name== Keyword.WILD) {2661 if (p.getName() instanceof AbstractString) { 2662 sb.append(p.getName().getStringValue()); 2663 } else if (p.getName() == Keyword.WILD) { 2601 2664 sb.append('*'); 2602 2665 } else { 2603 2666 return NIL; 2604 2667 } 2605 if (p. typeinstanceof AbstractString) {2668 if (p.getType() instanceof AbstractString) { 2606 2669 sb.append('.'); 2607 sb.append(p. type.getStringValue());2608 } else if (p. type== Keyword.WILD) {2670 sb.append(p.getType().getStringValue()); 2671 } else if (p.getType() == Keyword.WILD) { 2609 2672 sb.append(".*"); 2610 2673 } … … 2624 2687 @Override 2625 2688 public LispObject execute(LispObject arg) { 2626 return coerceToPathname(arg). host; // XXX URL-PATHNAME2689 return coerceToPathname(arg).getHost(); // XXX URL-PATHNAME 2627 2690 } 2628 2691 } … … 2742 2805 } 2743 2806 } 2744 return new Pathname(namestring);2807 return Pathname.create(namestring); 2745 2808 } catch (IOException e) { 2746 2809 error(new LispError(e.getMessage())); … … 2750 2813 } 2751 2814 2815 // BEGIN REMOVE ME use standard Factory pattern create() method instead 2816 public static Pathname make(String s) { 2817 Pathname p = Pathname.create(); 2818 p.init(s); 2819 return p; 2820 } 2821 2822 public static Pathname makeFrom(Pathname p) { 2823 return Pathname.create(p); 2824 } 2825 2826 public static Pathname makeFrom(Pathname p, String s) { 2827 p.init(s); 2828 return p; 2829 } 2830 // END REMOVE ME 2752 2831 } 2753 2832 -
trunk/abcl/src/org/armedbear/lisp/Site.java
r13095 r15391 50 50 s += fileSeparator; 51 51 } 52 LISP_HOME = new Pathname(s);52 LISP_HOME = Pathname.create(s); 53 53 return; 54 54 } … … 58 58 LISP_HOME = NIL; 59 59 } else { 60 Pathname p = new Pathname(url);61 p. name = NIL;62 p. type = NIL;60 Pathname p = Pathname.create(url); 61 p.setName(NIL); 62 p.setType(NIL); 63 63 p.invalidateNamestring(); 64 64 LISP_HOME = p; -
trunk/abcl/src/org/armedbear/lisp/delete_file.java
r13440 r15391 78 78 Thread.yield(); 79 79 } 80 Pathname truename = new Pathname(file.getAbsolutePath());80 Pathname truename = Pathname.create(file.getAbsolutePath()); 81 81 StringBuilder sb = new StringBuilder("Unable to delete "); 82 82 sb.append(file.isDirectory() ? "directory " : "file "); -
trunk/abcl/src/org/armedbear/lisp/unzip.java
r14892 r15391 65 65 Pathname zipFile = coerceToPathname(first); 66 66 Pathname directory = coerceToPathname(second); 67 directory. name = NIL;68 directory. type = NIL;67 directory.setName(NIL); 68 directory.setType(NIL); 69 69 directory.invalidateNamestring(); 70 70 return unzipToDirectory(zipFile, directory); … … 110 110 out.close(); 111 111 in.close(); 112 result = result.push( new Pathname(filename));112 result = result.push(Pathname.create(filename)); 113 113 } 114 114 } catch (IOException e) { -
trunk/abcl/test/src/org/armedbear/lisp/PathnameTest.java
r14624 r15391 29 29 System.out.println(e.getMessage()); 30 30 } 31 Pathname pathname = new Pathname(url);31 Pathname pathname = Pathname.create(url); 32 32 assertNotNull(pathname); 33 33 assertNotNull(pathname.getNamestring()); 34 assertNotNull(pathname. name);35 assertNotNull(pathname. type);36 assertNotNull(pathname. directory);34 assertNotNull(pathname.getName()); 35 assertNotNull(pathname.getType()); 36 assertNotNull(pathname.getDirectory()); 37 37 } 38 38 … … 60 60 @Test 61 61 public void copyConstructor() { 62 Pathname orig = new Pathname("/a/b/c/d/e/foo.lisp");63 Pathname copy = new Pathname(orig.getNamestring());62 Pathname orig = Pathname.create("/a/b/c/d/e/foo.lisp"); 63 Pathname copy = Pathname.create(orig.getNamestring()); 64 64 assertTrue(orig.getNamestring().equals(copy.getNamestring())); 65 65 } … … 67 67 @Test 68 68 public void mergePathnames1() { 69 Pathname p = new Pathname("a/b/c/d/foo.lisp");70 Pathname d = new Pathname("/foo/bar/there");69 Pathname p = Pathname.create("a/b/c/d/foo.lisp"); 70 Pathname d = Pathname.create("/foo/bar/there"); 71 71 Pathname r = Pathname.mergePathnames(p, d); 72 72 String s = r.getNamestring(); … … 76 76 @Test 77 77 public void mergePathnames2() { 78 Pathname p = new Pathname("/a/b/c/d/foo.lisp");79 Pathname d = new Pathname("/foo/bar/there");78 Pathname p = Pathname.create("/a/b/c/d/foo.lisp"); 79 Pathname d = Pathname.create("/foo/bar/there"); 80 80 Pathname r = Pathname.mergePathnames(p, d); 81 81 assertTrue(r.getNamestring().equals("/a/b/c/d/foo.lisp")); … … 89 89 args = args.nreverse(); 90 90 Pathname p = Pathname.makePathname(args); 91 Pathname d = new Pathname("/foo/bar.abcl");91 Pathname d = Pathname.create("/foo/bar.abcl"); 92 92 Pathname r = Pathname.mergePathnames(p, d); 93 93 assertTrue(r.getNamestring().equals("/foo/bar.abcl-tmp")); … … 96 96 @Test 97 97 public void mergePathnames4() { 98 Pathname p = new Pathname("jar:file:foo.jar!/bar.abcl");99 Pathname d = new Pathname("/a/b/c/");98 Pathname p = Pathname.create("jar:file:foo.jar!/bar.abcl"); 99 Pathname d = Pathname.create("/a/b/c/"); 100 100 Pathname r = Pathname.mergePathnames(p, d); 101 101 String s = r.getNamestring(); … … 104 104 @Test 105 105 public void constructorFileDirectory() { 106 Pathname p = new Pathname("file://tmp/");106 Pathname p = Pathname.create("file://tmp/"); 107 107 assertTrue(p.getNamestring().endsWith("/")); 108 108 } 109 109 @Test 110 110 public void constructorFileWindowsDevice() { 111 Pathname p = new Pathname("file:c://tmp/");111 Pathname p = Pathname.create("file:c://tmp/"); 112 112 LispObject device = p.getDevice(); 113 113 if (Utilities.isPlatformWindows) { -
trunk/abcl/test/src/org/armedbear/lisp/UtilitiesTest.java
r12424 r15391 42 42 public void getZipInputStreamZipEntry() throws FileNotFoundException, IOException { 43 43 JarFile jar = new JarFile(zipFile); 44 Pathname pathname = new Pathname("a/b/bar.abcl");44 Pathname pathname = Pathname.create("a/b/bar.abcl"); 45 45 InputStream entryInputStream = Utilities.getInputStream(jar, pathname); 46 46 assertNotNull(entryInputStream);
Note: See TracChangeset
for help on using the changeset viewer.