KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > armedbear > lisp > probe_file


1 /*
2  * probe_file.java
3  *
4  * Copyright (C) 2003-2004 Peter Graves
5  * $Id: probe_file.java,v 1.13 2004/01/08 17:42:02 piso Exp $
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * 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 JavaDoc;
25 import java.io.IOException JavaDoc;
26
27 public final class probe_file extends Lisp
28 {
29     // ### probe-file
30
// probe-file pathspec => truename
31
private static final Primitive1 PROBE_FILE =
32         new Primitive1("probe-file", "pathspec")
33     {
34         public LispObject execute(LispObject arg) throws ConditionThrowable
35         {
36             return Pathname.truename(arg, false);
37         }
38     };
39
40     // ### truename
41
// truename filespec => truename
42
private static final Primitive1 TRUENAME =
43         new Primitive1("truename", "filespec")
44     {
45         public LispObject execute(LispObject arg) throws ConditionThrowable
46         {
47             return Pathname.truename(arg, true);
48         }
49     };
50
51     // ### probe-directory
52
// probe-directory pathspec => truename
53
private static final Primitive1 PROBE_DIRECTORY =
54         new Primitive1("probe-directory", PACKAGE_EXT, true)
55     {
56         public LispObject execute(LispObject arg) throws ConditionThrowable
57         {
58             Pathname pathname = Pathname.coerceToPathname(arg);
59             if (pathname.isWild())
60                 signal(new FileError("Bad place for a wild pathname."));
61             File JavaDoc file = Utilities.getFile(pathname);
62             return file.isDirectory() ? Utilities.getDirectoryPathname(file) : NIL;
63         }
64     };
65
66     // ### file-directory-p
67
// file-directory-p pathspec => generalized-boolean
68
private static final Primitive1 FILE_DIRECTORY_P =
69         new Primitive1("file-directory-p", PACKAGE_EXT, true)
70     {
71         public LispObject execute(LispObject arg) throws ConditionThrowable
72         {
73             Pathname pathname = Pathname.coerceToPathname(arg);
74             if (pathname.isWild())
75                 signal(new FileError("Bad place for a wild pathname."));
76             File JavaDoc file = Utilities.getFile(pathname);
77             return file.isDirectory() ? T : NIL;
78         }
79     };
80 }
81
Popular Tags