next up previous contents
Next: Shells and Pipes Up: External Resources Previous: Consoles   Contents

Files

Files are persistent external sequences of bytes. The interpreter provides an object type File which provides the corresponding protocol extensions to ExternalResource:

newNamed:&mode:
returns a new File with the given name as its locator and also a mode option. No attempt to open the file is automatically made.
open:
returns a file handle for a String that names a path to a file, for read/write access.
openForInput:
returns a handle for reading an existing file of the given name, or Nil if it doesn't exist.
openForOutput:
returns a handle for writing (appending) to a file with the given name.
openNew:
returns a handle for writing (appending) to a new file with the given name. It will create a new file, but if the file exists, Nil will be returned.
withOpenNamed:Do:&mode:
wraps sessionDo: with the ability to create a new File dynamically for the session along with a specified mode.
position
returns the position within the file in byte units.
position:
sets the position within the file to the given integer number of bytes.
size
returns the file size in bytes.
name
returns the file's pathname.
fullName
will always return a complete pathname whereas the regular method may not.
renameTo:
adjusts the file to have the given name.
atEnd
answers whether the file's end has been reached.
create
makes a file with the given name, with empty contents.
exists
answers whether there is a file with the object's pathname.
delete
deletes the file.
Perhaps the most important utility is to load libraries based on path names. load: 'filename' will execute a file with the given path name as Slate source.

File mode objects specify the interaction capabilities requested of the underlying system for the handle. The modes consist of File Read, File Write, File ReadWrite, and File CreateWrite.


next up previous contents
Next: Shells and Pipes Up: External Resources Previous: Consoles   Contents
Brian Rice 2004-08-24