Changeset 4436
- Timestamp:
- 10/17/03 17:31:38 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/lisp/probe_file.java
r4048 r4436 3 3 * 4 4 * Copyright (C) 2003 Peter Graves 5 * $Id: probe_file.java,v 1. 6 2003-09-25 13:17:54piso Exp $5 * $Id: probe_file.java,v 1.7 2003-10-17 17:31:38 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 29 29 // ### probe-file 30 30 // probe-file pathspec => truename 31 private static final Primitive1 PROBE_FILE = new Primitive1("probe-file") { 31 private static final Primitive1 PROBE_FILE = new Primitive1("probe-file") 32 { 32 33 public LispObject execute(LispObject arg) throws ConditionThrowable 33 34 { 34 File file = getFile(arg);35 File file = Utilities.getFile(arg); 35 36 if (!file.exists()) 36 37 return NIL; … … 51 52 public LispObject execute(LispObject arg) throws ConditionThrowable 52 53 { 53 File file = getFile(arg);54 File file = Utilities.getFile(arg); 54 55 if (!file.isDirectory()) 55 56 return NIL; … … 70 71 public LispObject execute(LispObject arg) throws ConditionThrowable 71 72 { 72 File file = getFile(arg);73 File file = Utilities.getFile(arg); 73 74 return file.isDirectory() ? T : NIL; 74 75 } 75 76 }; 76 77 private static File getFile(LispObject pathspec) throws ConditionThrowable78 {79 String namestring;80 if (pathspec instanceof LispString)81 namestring = ((LispString)pathspec).getValue();82 else if (pathspec instanceof Pathname)83 namestring = ((Pathname)pathspec).getNamestring();84 else85 throw new ConditionThrowable(new TypeError(pathspec,86 "pathname designator"));87 if (isNamestringAbsolute(namestring))88 return new File(namestring);89 return new File(90 LispString.getValue(_DEFAULT_PATHNAME_DEFAULTS_.symbolValue()),91 namestring);92 }93 94 private static boolean isNamestringAbsolute(String namestring)95 {96 if (System.getProperty("os.name").startsWith("Windows")) {97 if (namestring.length() >= 3) {98 if (namestring.charAt(1) == ':')99 if (namestring.charAt(2) == '\\')100 return true;101 }102 } else if (namestring.length() > 0) {103 if (namestring.charAt(0) == '/')104 return true;105 }106 return false;107 }108 77 }
Note: See TracChangeset
for help on using the changeset viewer.