Changeset 15445
- Timestamp:
- 10/29/20 16:54:39 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/Pathname.java
r15442 r15445 1404 1404 } 1405 1405 1406 String s = pathname.getNamestring(); 1407 if (s != null) { 1408 File f = new File(s); 1409 if (f.isDirectory()) { 1410 try { 1411 File[] files = f.listFiles(); 1412 if (files == null) { 1413 return error(new FileError("Unable to list directory " 1414 + pathname.princToString() + ".", 1415 pathname)); 1416 } 1417 for (int i = files.length; i-- > 0;) { 1418 File file = files[i]; 1419 String path; 1420 if (resolveSymlinks == NIL) { 1421 path = file.getAbsolutePath(); 1422 } else { 1423 path = file.getCanonicalPath(); 1424 } 1425 if (file.isDirectory() 1426 && !path.endsWith("/")) { 1427 path += "/"; 1428 } 1429 Pathname p; 1430 p = (Pathname)Pathname.create(path); 1431 result = new Cons(p, result); 1432 } 1433 } catch (IOException e) { 1434 return error(new FileError("Unable to list directory " 1406 File f = pathname.getFile(); 1407 if (f.isDirectory()) { 1408 try { 1409 File[] files = f.listFiles(); 1410 if (files == null) { 1411 return error(new FileError("Unable to list directory " 1435 1412 + pathname.princToString() + ".", 1436 1413 pathname)); 1437 } catch (SecurityException e) {1438 return error(new FileError("Unable to list directory: " + e, pathname));1439 1414 } 1415 for (int i = files.length; i-- > 0;) { 1416 File file = files[i]; 1417 String path; 1418 if (resolveSymlinks == NIL) { 1419 path = file.getAbsolutePath(); 1420 } else { 1421 path = file.getCanonicalPath(); 1422 } 1423 if (file.isDirectory() 1424 && !path.endsWith("/")) { 1425 path += "/"; 1426 } 1427 Pathname p; 1428 p = (Pathname)Pathname.create(path); 1429 result = new Cons(p, result); 1430 } 1431 } catch (IOException e) { 1432 return error(new FileError("Unable to list directory " 1433 + pathname.princToString() + ".", 1434 pathname)); 1435 } catch (SecurityException e) { 1436 return error(new FileError("Unable to list directory: " + e, pathname)); 1440 1437 } 1441 1438 } … … 1863 1860 */ 1864 1861 public static LispObject truename(Pathname pathname, 1865 1862 boolean errorIfDoesNotExist) { 1866 1863 if (pathname == null || pathname.equals(NIL)) { 1867 1864 return doTruenameExit(pathname, errorIfDoesNotExist); … … 1879 1876 NIL); 1880 1877 final File file = result.getFile(); 1881 if (file.exists()) { 1878 if (file != null 1879 && file.exists()) { 1882 1880 if (file.isDirectory()) { 1883 1881 result = Pathname.getDirectoryPathname(file); … … 2089 2087 } 2090 2088 } 2091 2092 public URL toURL() {2093 try {2094 if (isURL()) {2095 return new URL(getNamestring());2096 } else {2097 return toFile().toURI().toURL();2098 }2099 } catch (MalformedURLException e) {2100 error(new LispError(getNamestring() + " is not a valid URL"));2101 return null; // not reached2102 }2103 }2104 2105 public File toFile() {2106 if(!isURL()) {2107 return new File(getNamestring());2108 } else {2109 throw new RuntimeException(this + " does not represent a file");2110 }2111 }2112 2089 2113 2090 static {
Note: See TracChangeset
for help on using the changeset viewer.