1 |
(* bin-io-fn.sml |
(* bin-io.sml |
2 |
* |
* |
3 |
* COPYRIGHT (c) 1995 AT&T Bell Laboratories. |
* COPYRIGHT (c) 1995 AT&T Bell Laboratories. |
4 |
|
* COPYRIGHT (c) 2007 Fellowship of SML/NJ |
5 |
* |
* |
6 |
* QUESTION: what operations should raise exceptions when the stream is |
* QUESTION: what operations should raise exceptions when the stream is |
7 |
* closed? |
* closed? |
12 |
structure Int = IntImp |
structure Int = IntImp |
13 |
structure Position = PositionImp |
structure Position = PositionImp |
14 |
in |
in |
15 |
functor BinIOFn ( |
structure BinIO : BIN_IO = struct |
16 |
|
|
17 |
structure OSPrimIO : OS_PRIM_IO |
structure PIO = BinPrimIO |
|
where PrimIO = BinPrimIO |
|
|
|
|
|
) : BIN_IO = struct |
|
|
|
|
|
structure PIO = OSPrimIO.PrimIO |
|
18 |
structure A = Word8Array |
structure A = Word8Array |
19 |
structure AS = Word8ArraySlice |
structure AS = Word8ArraySlice |
20 |
structure V = Word8Vector |
structure V = Word8Vector |
609 |
|
|
610 |
(** Open files **) |
(** Open files **) |
611 |
fun openIn fname = |
fun openIn fname = |
612 |
mkInstream(StreamIO.mkInstream(OSPrimIO.openRd fname, empty)) |
mkInstream(StreamIO.mkInstream(PIO.openRd fname, empty)) |
613 |
handle ex => raise IO.Io{function="openIn", name=fname, cause=ex} |
handle ex => raise IO.Io{function="openIn", name=fname, cause=ex} |
614 |
fun openOut fname = |
fun openOut fname = |
615 |
mkOutstream(StreamIO.mkOutstream(OSPrimIO.openWr fname, IO.BLOCK_BUF)) |
mkOutstream(StreamIO.mkOutstream(PIO.openWr fname, IO.BLOCK_BUF)) |
616 |
handle ex => raise IO.Io{function="openOut", name=fname, cause=ex} |
handle ex => raise IO.Io{function="openOut", name=fname, cause=ex} |
617 |
fun openAppend fname = |
fun openAppend fname = |
618 |
mkOutstream(StreamIO.mkOutstream(OSPrimIO.openApp fname, IO.NO_BUF)) |
mkOutstream(StreamIO.mkOutstream(PIO.openApp fname, IO.NO_BUF)) |
619 |
handle ex => raise IO.Io{function="openAppend", name=fname, cause=ex} |
handle ex => raise IO.Io{function="openAppend", name=fname, cause=ex} |
620 |
|
|
621 |
end (* BinIOFn *) |
end (* BinIOFn *) |