01: /*
02: * probe_file.java
03: *
04: * Copyright (C) 2003-2004 Peter Graves
05: * $Id: probe_file.java,v 1.13 2004/01/08 17:42:02 piso Exp $
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License
09: * as published by the Free Software Foundation; either version 2
10: * of the License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20: */
21:
22: package org.armedbear.lisp;
23:
24: import java.io.File;
25: import java.io.IOException;
26:
27: public final class probe_file extends Lisp {
28: // ### probe-file
29: // probe-file pathspec => truename
30: private static final Primitive1 PROBE_FILE = new Primitive1(
31: "probe-file", "pathspec") {
32: public LispObject execute(LispObject arg)
33: throws ConditionThrowable {
34: return Pathname.truename(arg, false);
35: }
36: };
37:
38: // ### truename
39: // truename filespec => truename
40: private static final Primitive1 TRUENAME = new Primitive1(
41: "truename", "filespec") {
42: public LispObject execute(LispObject arg)
43: throws ConditionThrowable {
44: return Pathname.truename(arg, true);
45: }
46: };
47:
48: // ### probe-directory
49: // probe-directory pathspec => truename
50: private static final Primitive1 PROBE_DIRECTORY = new Primitive1(
51: "probe-directory", PACKAGE_EXT, true) {
52: public LispObject execute(LispObject arg)
53: throws ConditionThrowable {
54: Pathname pathname = Pathname.coerceToPathname(arg);
55: if (pathname.isWild())
56: signal(new FileError("Bad place for a wild pathname."));
57: File file = Utilities.getFile(pathname);
58: return file.isDirectory() ? Utilities
59: .getDirectoryPathname(file) : NIL;
60: }
61: };
62:
63: // ### file-directory-p
64: // file-directory-p pathspec => generalized-boolean
65: private static final Primitive1 FILE_DIRECTORY_P = new Primitive1(
66: "file-directory-p", PACKAGE_EXT, true) {
67: public LispObject execute(LispObject arg)
68: throws ConditionThrowable {
69: Pathname pathname = Pathname.coerceToPathname(arg);
70: if (pathname.isWild())
71: signal(new FileError("Bad place for a wild pathname."));
72: File file = Utilities.getFile(pathname);
73: return file.isDirectory() ? T : NIL;
74: }
75: };
76: }
|