Changeset 15392
- Timestamp:
- 10/10/20 21:43:22 (3 years ago)
- Location:
- trunk/abcl/src/org/armedbear/lisp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/LogicalPathname.java
r15391 r15392 47 47 = new HashMap(); 48 48 49 // A logical host is represented as the string that names it. 50 // (defvar *logical-pathname-translations* (make-hash-table :test 'equal)) 51 public static HashTable TRANSLATIONS 52 = HashTable.newEqualHashTable(LOGICAL_PATHNAME_CHARS.length(), NIL, NIL); 53 private static final Symbol _TRANSLATIONS_ 54 = exportSpecial("*LOGICAL-PATHNAME-TRANSLATIONS*", PACKAGE_SYS, TRANSLATIONS); 55 49 56 static public boolean isValidLogicalPathname(String namestring) { 50 57 if (!isValidURL(namestring)) { 51 58 String host = getHostString(namestring); 52 59 if (host != null 53 && L OGICAL_PATHNAME_TRANSLATIONS.get(new SimpleString(host)) != null) {60 && LogicalPathname.TRANSLATIONS.get(new SimpleString(host)) != null) { 54 61 return true; 55 62 } 56 63 } 57 64 return false; 65 } 66 67 protected LogicalPathname() { 68 } 69 70 // Used in Pathname._makePathname to indicate type for namestring 71 public static LogicalPathname create() { 72 return new LogicalPathname(); 58 73 } 59 74 60 75 public static LogicalPathname create(String namestring) { 61 76 // parse host out then call create(host, rest); 77 LogicalPathname result = null; 62 78 if (LogicalPathname.isValidLogicalPathname(namestring)) { 63 79 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 80 result 81 = LogicalPathname.create(h, namestring.substring(namestring.indexOf(':') + 1)); 82 return result; 83 } 84 error(new FileError("Failed to find a valid logical Pathname host in '" + namestring + "'", 85 NIL)); // ??? return NIL as we don't have a 86 // PATHNAME. Maybe signal a different 87 // condition? 88 return (LogicalPathname)UNREACHED; 68 89 } 69 90 … … 71 92 // This may be "too late" in the creation chain to be meaningful? 72 93 SimpleString h = new SimpleString(host); 73 if (L OGICAL_PATHNAME_TRANSLATIONS.get(h) == null) {94 if (LogicalPathname.TRANSLATIONS.get(h) == null) { 74 95 // Logical pathnames are only valid when it's host exists 75 96 String message = MessageFormat.format("'{0}' is not a defined logical host", host); … … 335 356 h + '"')); 336 357 } 337 if ( Pathname.LOGICAL_PATHNAME_TRANSLATIONS.get(new SimpleString(h)) != null) {358 if (LogicalPathname.TRANSLATIONS.get(new SimpleString(h)) != null) { 338 359 // A defined logical pathname host. 339 360 return LogicalPathname.create(h, s.substring(s.indexOf(':') + 1)); -
trunk/abcl/src/org/armedbear/lisp/Pathname.java
r15391 r15392 1077 1077 return unreadableString(sb.toString()); 1078 1078 } 1079 // A logical host is represented as the string that names it.1080 // (defvar *logical-pathname-translations* (make-hash-table :test 'equal))1081 public static HashTable LOGICAL_PATHNAME_TRANSLATIONS =1082 HashTable.newEqualHashTable(64, NIL, NIL);1083 private static final Symbol _LOGICAL_PATHNAME_TRANSLATIONS_ =1084 exportSpecial("*LOGICAL-PATHNAME-TRANSLATIONS*", PACKAGE_SYS,1085 LOGICAL_PATHNAME_TRANSLATIONS);1086 1079 1087 1080 public static Pathname parseNamestring(String s) { … … 1137 1130 if (!isValidURL(s)) { 1138 1131 String h = LogicalPathname.getHostString(s); 1139 if (h != null && LOGICAL_PATHNAME_TRANSLATIONS.get(new SimpleString(h)) != null) { 1132 if (h != null 1133 && LogicalPathname.TRANSLATIONS.get(new SimpleString(h)) != null) { 1140 1134 // A defined logical pathname host. 1141 1135 return LogicalPathname.create(h, s.substring(s.indexOf(':') + 1)); … … 1164 1158 s = s.substring(s.indexOf(':') + 1); 1165 1159 } 1166 if (L OGICAL_PATHNAME_TRANSLATIONS.get(host) != null) {1160 if (LogicalPathname.TRANSLATIONS.get(host) != null) { 1167 1161 // A defined logical pathname host. 1168 1162 return LogicalPathname.create(host.getStringValue(), s); … … 1356 1350 @Override 1357 1351 public LispObject execute(LispObject[] args) { 1358 return _makePathname(args); 1352 LispObject result = _makePathname(args); 1353 return result; 1359 1354 } 1360 1355 } … … 1362 1357 // Used by the #p reader. 1363 1358 public static final Pathname makePathname(LispObject args) { 1364 return_makePathname(args.copyToArray());1359 return (Pathname) _makePathname(args.copyToArray()); 1365 1360 } 1366 1361 … … 1378 1373 1379 1374 1380 static final Pathname _makePathname(LispObject[] args) { 1375 // ??? changed to return a LispObject, as we wish to return a 1376 // meaningful Java type (Pathname for files, LogicalPathnames for you knowâŠ) 1377 static final LispObject _makePathname(LispObject[] args) { 1381 1378 if (args.length % 2 != 0) { 1382 1379 program_error("Odd number of keyword arguments."); … … 1464 1461 } 1465 1462 } 1466 final Pathname p; 1467 final boolean logical; 1463 Pathname p; 1468 1464 LispObject logicalHost = NIL; 1469 1465 if (host != NIL) { … … 1471 1467 logicalHost = LogicalPathname.canonicalizeStringComponent((AbstractString) host); 1472 1468 } 1473 if (L OGICAL_PATHNAME_TRANSLATIONS.get(logicalHost) == null) {1469 if (LogicalPathname.TRANSLATIONS.get(logicalHost) == null) { 1474 1470 // Not a defined logical pathname host -- A UNC path 1475 1471 //warning(new LispError(host.printObject() + " is not defined as a logical pathname host.")); 1476 1472 p = Pathname.create(); 1477 logical = false;1478 1473 p.setHost(host); 1479 1474 } else { 1480 1475 p = LogicalPathname.create(); 1481 logical = true;1482 1476 p.setHost(logicalHost); 1483 1477 } … … 1485 1479 } else { 1486 1480 p = Pathname.create(); 1487 logical = false;1488 1481 } 1489 1482 if (device != NIL) { 1490 if ( logical) {1483 if (p instanceof LogicalPathname) { 1491 1484 // "The device component of a logical pathname is always :UNSPECIFIC." 1492 1485 if (device != Keyword.UNSPECIFIC) { … … 1498 1491 } 1499 1492 if (directory != NIL) { 1500 if ( logical) {1493 if (p instanceof LogicalPathname) { 1501 1494 if (directory.listp()) { 1502 1495 LispObject d = NIL; … … 1521 1514 } 1522 1515 if (name != NIL) { 1523 if ( logical&& name instanceof AbstractString) {1516 if (p instanceof LogicalPathname && name instanceof AbstractString) { 1524 1517 p.setName(LogicalPathname.canonicalizeStringComponent((AbstractString) name)); 1525 1518 } else if (name instanceof AbstractString) { … … 1530 1523 } 1531 1524 if (type != NIL) { 1532 if ( logical&& type instanceof AbstractString) {1525 if (p instanceof LogicalPathname && type instanceof AbstractString) { 1533 1526 p.setType(LogicalPathname.canonicalizeStringComponent((AbstractString) type)); 1534 1527 } else { … … 1539 1532 p.setVersion(version); 1540 1533 p.validateDirectory(true); 1534 1541 1535 return p; 1542 1536 } -
trunk/abcl/src/org/armedbear/lisp/file_error_pathname.java
r12288 r15392 50 50 } 51 51 52 private static final file_error_pathname FILE_ERROR_PATHNAME =53 52 private static final file_error_pathname FILE_ERROR_PATHNAME 53 = new file_error_pathname(); 54 54 }
Note: See TracChangeset
for help on using the changeset viewer.