Changeset 3337


Ignore:
Timestamp:
08/11/03 18:40:40 (18 years ago)
Author:
piso
Message:

Pathname support.

File:
1 edited

Legend:

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

    r3283 r3337  
    33 *
    44 * Copyright (C) 2003 Peter Graves
    5  * $Id: open.java,v 1.1 2003-08-09 23:42:33 piso Exp $
     5 * $Id: open.java,v 1.2 2003-08-11 18:40:40 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    3636            throws LispError
    3737        {
    38             String pathname = LispString.getValue(first);
     38            String namestring;
     39            if (first instanceof LispString)
     40                namestring = ((LispString)first).getValue();
     41            else if (first instanceof Pathname)
     42                namestring = ((Pathname)first).getNamestring();
     43            else
     44                throw new TypeError(first, "pathname designator");
    3945            boolean binary;
    4046            LispObject elementType = second;
     
    4652                throw new LispError(String.valueOf(elementType).concat(
    4753                    " is not a valid stream element type"));
    48             File file = new File(pathname);
     54            File file = new File(namestring);
    4955            LispObject ifExists = third;
    5056            if (ifExists == Keyword.SUPERSEDE) {
     
    5258            } else if (ifExists == Keyword.ERROR) {
    5359                if (file.exists())
    54                     throw new LispError("file already exists: " + pathname);
     60                    throw new LispError("file already exists: " + first);
    5561            } else if (ifExists == NIL) {
    5662                if (file.exists())
     
    6874            }
    6975            catch (FileNotFoundException e) {
    70                 throw new LispError("unable to create file: " + pathname);
     76                throw new LispError("unable to create file: " + first);
    7177            }
    7278        }
     
    7985            throws LispError
    8086        {
    81             String pathname = LispString.getValue(first);
     87            String namestring;
     88            if (first instanceof LispString)
     89                namestring = ((LispString)first).getValue();
     90            else if (first instanceof Pathname)
     91                namestring = ((Pathname)first).getNamestring();
     92            else
     93                throw new TypeError(first, "pathname designator");
    8294            boolean binary;
    8395            LispObject elementType = second;
     
    91103            try {
    92104                if (binary)
    93                     return new BinaryInputStream(new FileInputStream(pathname));
     105                    return new BinaryInputStream(new FileInputStream(namestring));
    94106                else
    95                     return new CharacterInputStream(new FileInputStream(pathname));
     107                    return new CharacterInputStream(new FileInputStream(namestring));
    96108            }
    97109            catch (FileNotFoundException e) {
    98                 throw new LispError(" file not found: " + pathname);
     110                throw new LispError(" file not found: " + first);
    99111            }
    100112        }
Note: See TracChangeset for help on using the changeset viewer.