The Standard ML Basis Library


The BinIO structure

The structure BinIO provides input/output of binary data (8-bit bytes). The semantics of the various I/O operations can be found in the description of the IMPERATIVE_IO signature. The openIn and openOut functions allow the creation of binary streams to read an write file data. Certain operating systems may provide other ways to open files in operating-system-specific structures.


Synopsis

signature BIN_IO
structure BinIO : BIN_IO

Interface

include IMPERATIVE_IO
  where type StreamIO.vector = Word8Vector.vector
  where type StreamIO.elem = Word8.word
val openIn : string -> instream
val openOut : string -> outstream
val openAppend : string -> outstream

Description

openIn name
openOut name
Open the file named name for input and output, respectively. If name is a relative pathname, the file opened depends on the current working directory. On openOut, the file is created if it does not already exist and truncated to length zero otherwise. Raises Io if a stream cannot be opened on the given file or, in the case of openIn, the file name does not exist.

openAppend name
opens the file named name for output in append mode, creating it if it does not already exist. If the file already exists, set position at end of file. Raises Io if a stream cannot be opened on the given file.

Beyond having the initial file position be at the end of the file, any additional properties are system and implementation dependent. On operating systems (e.g., Unix) that support ``atomic append mode,'' each (flushed) output operation to the file will be appended to the end, even if there are other processes writing to the file simultaneously. However, due to buffering, these writes need not be atomic, i.e., output from a different process may interleave the output of a single write using the stream library. On certain other operating systems, having the file open for writing prevents any other process from opening the file for writing.


See Also

IMPERATIVE_IO, TextIO, OS.Path

[ INDEX | TOP | Parent | Root ]

Last Modified January 9, 1997
Comments to John Reppy.
Copyright © 1997 Bell Labs, Lucent Technologies