Changeset 4435


Ignore:
Timestamp:
10/17/03 17:30:50 (19 years ago)
Author:
piso
Message:

isPlatformUnix(), getFile()

File:
1 edited

Legend:

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

    r4100 r4435  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: Utilities.java,v 1.3 2003-09-28 15:58:48 piso Exp $
     5 * $Id: Utilities.java,v 1.4 2003-10-17 17:30:50 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    2222package org.armedbear.lisp;
    2323
    24 public final class Utilities
     24import java.io.File;
     25
     26public final class Utilities extends Lisp
    2527{
    26     private static final boolean isPlatformWindows =
    27         System.getProperty("os.name").startsWith("Windows");
     28    private static final boolean isPlatformUnix;
     29    private static final boolean isPlatformWindows;
     30
     31    static {
     32        String osName = System.getProperty("os.name");
     33        isPlatformUnix = osName.startsWith("Linux") ||
     34            osName.startsWith("Mac OS X") || osName.startsWith("Solaris") ||
     35            osName.startsWith("SunOS") || osName.startsWith("AIX");
     36        isPlatformWindows = osName.startsWith("Windows");
     37    }
     38
     39    public static boolean isPlatformUnix()
     40    {
     41        return isPlatformUnix;
     42    }
    2843
    2944    public static boolean isPlatformWindows()
     
    5974    }
    6075
     76    public static File getFile(LispObject pathspec) throws ConditionThrowable
     77    {
     78        String namestring;
     79        if (pathspec instanceof LispString)
     80            namestring = ((LispString)pathspec).getValue();
     81        else if (pathspec instanceof Pathname)
     82            namestring = ((Pathname)pathspec).getNamestring();
     83        else
     84            throw new ConditionThrowable(new TypeError(pathspec,
     85                                                       "pathname designator"));
     86        if (isFilenameAbsolute(namestring)) {
     87            if (isPlatformUnix()) {
     88                if (namestring.length() > 0 && namestring.charAt(0) == '~') {
     89                    namestring =
     90                        System.getProperty("user.home").concat(namestring.substring(1));
     91                }
     92            }
     93            return new File(namestring);
     94        }
     95        return new File(
     96            LispString.getValue(_DEFAULT_PATHNAME_DEFAULTS_.symbolValue()),
     97            namestring);
     98    }
     99
    61100    public static final char toUpperCase(char c)
    62101    {
Note: See TracChangeset for help on using the changeset viewer.