Changeset 4436


Ignore:
Timestamp:
10/17/03 17:31:38 (19 years ago)
Author:
piso
Message:

Moved getFile() to Utilities.java.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/probe_file.java

    r4048 r4436  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: probe_file.java,v 1.6 2003-09-25 13:17:54 piso Exp $
     5 * $Id: probe_file.java,v 1.7 2003-10-17 17:31:38 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2929    // ### probe-file
    3030    // 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    {
    3233        public LispObject execute(LispObject arg) throws ConditionThrowable
    3334        {
    34             File file = getFile(arg);
     35            File file = Utilities.getFile(arg);
    3536            if (!file.exists())
    3637                return NIL;
     
    5152        public LispObject execute(LispObject arg) throws ConditionThrowable
    5253        {
    53             File file = getFile(arg);
     54            File file = Utilities.getFile(arg);
    5455            if (!file.isDirectory())
    5556                return NIL;
     
    7071        public LispObject execute(LispObject arg) throws ConditionThrowable
    7172        {
    72             File file = getFile(arg);
     73            File file = Utilities.getFile(arg);
    7374            return file.isDirectory() ? T : NIL;
    7475        }
    7576    };
    76 
    77     private static File getFile(LispObject pathspec) throws ConditionThrowable
    78     {
    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         else
    85             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     }
    10877}
Note: See TracChangeset for help on using the changeset viewer.