{Begin Chapter Streams and Files}
{Title Streams and Files}
{Text

{index *PRIMARY* Streams}
{index *PRIMARY* Files}

Interlisp-D can perform input/output operations on a large variety of physical devices, including local disk drives, floppy disk drives, the keyboard and display screen, and remote file server computers accessed over a network.  While the low-level details of how all these devices perform input/output vary considerably, the Interlisp-D language provides the programmer a small, common set of abstract operations whose use is largely independent of the physical input/output medium involved{emdash}operations such as {it read}, {it print}, {it change font}, or {it go to a new line}.  By merely changing the targeted I/O device, a single program can be used to produce output on the display, a file, or a printer.

The underlying data abstraction that permits this flexibility is the {it stream}.  A stream is a data object (an instance of the data type {lisp STREAM}) that encapsulates all of the information about an input/output connection to a particular I/O device.  Each of Interlisp-D's general-purpose I/O functions takes a stream as one of its arguments.  The general-purpose function then performs action specific to the stream's device to carry out the requested operation.  Not every device is capable of implementing every I/O operation, while some devices offer additional functionality by way of special functions for that device alone.  Such restrictions and extensions are noted in the documentation of each device.

The vast majority of the streams commonly used in Interlisp-D fall into two interesting categories: the {it file stream} and the {it image stream}.

{index *PRIMARY* File devices}

A file is an ordered collection of data, usually a sequence of characters or bytes, stored on a file device in a manner that allows the data to be retrieved at a later time.  Floppy disks, hard disks, and remote file servers are among the devices used to store files.  Files are identified by a "file name",{index File Names} which specifies the device on which the file resides and a name unique to a specific file on that device.  Input or output to a file is performed by obtaining a stream to the file, using {fn OPENSTREAM} ({PageRef fn OPENSTREAM}).  In addition, there are functions that manipulate the files themselves, rather than their data content.

{index Image streams}

An image stream is an output stream to a display device, such as the display screen or a printer.  In addition to the standard output operations, such as print, an image stream implements a variety of graphics operations, such as drawing lines and displaying characters in multiple fonts.  Unlike a file, the "content" of an image stream cannot be retrieved.  Image streams are described on {PageRef Term Image Streams}.

The creation of other kinds of streams, such as network byte-stream connections, is described in the chapters peculiar to those kinds of streams.  The operations common to streams in general are described on {PageRef Term Input/Output Functions}.  This chapter describes operations specific to file devices: how to name files, how to open streams to files, and how to manipulate files on their devices.

{Include FileStreams}

{Include FileNames}

{Include FileOther}

{Include Directories}

{Include FileServers}


}{End Chapter Streams and Files}