aboutsummaryrefslogtreecommitdiff
path: root/src/algebra/net.spad.pamphlet
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2008-10-01 09:50:16 +0000
committerdos-reis <gdr@axiomatics.org>2008-10-01 09:50:16 +0000
commit41c41ca859e093f8029bc5c6e9df996df8998530 (patch)
treefc6328409bbd3dec92bf4af92f9a0552fe791e59 /src/algebra/net.spad.pamphlet
parent7390fa59b4e4411c142ecdb13070c5f0ac91d51d (diff)
downloadopen-axiom-41c41ca859e093f8029bc5c6e9df996df8998530.tar.gz
* algebra/files.spad.pamphlet (IOMode): New domain.
* algebra/net.spad.pamphlet (InputBinaryFile): Likewise. (OutputBinaryFile): Likewise. * interp/sys-utility.boot (openBinaryFile): New. (readByteFromFile): Likewise. (writeByteToFile): Likewise. (closeFile): Likewise.
Diffstat (limited to 'src/algebra/net.spad.pamphlet')
-rw-r--r--src/algebra/net.spad.pamphlet91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/algebra/net.spad.pamphlet b/src/algebra/net.spad.pamphlet
index 4a8d4961..ef5f7cec 100644
--- a/src/algebra/net.spad.pamphlet
+++ b/src/algebra/net.spad.pamphlet
@@ -106,6 +106,94 @@ InputOutputByteConduit(): Category ==
@
+
+\subsection{The InputBinaryFile domain}
+
+<<domain INBFILE InputBinaryFile>>=
+)abbrev domain INBFILE InputBinaryFile
+++ Author: Gabriel Dos Reis
+++ Date Created: September 30, 2008
+++ Date Last Modified: September 30, 2008
+++ Description:
+++ This domain provides representation for binary files open
+++ for input operations. `Binary' here means that the conduits
+++ do not interpret their contents.
+InputBinaryFile(): Public == Private where
+ Public == Join(InputByteConduit, CoercibleTo OutputForm) with
+ inputBinaryFile: FileName -> %
+ ++ inputBinaryFile(f) returns an input conduit obtained by
+ ++ opening the file named by `f' as a binary file.
+ inputBinaryFile: String -> %
+ ++ inputBinaryFile(f) returns an input conduit obtained by
+ ++ opening the file named by `f' as a binary file.
+ eof?: % -> Boolean
+ ++ eof?(ifile) holds when end-of-file has been reached
+ ++ for the conduit file `ifile'.
+ isOpen?: % -> Boolean
+ ++ open?(ifile) holds if `ifile' is in open state.
+ Private == add
+ Rep == Record(stream: SExpression, filename: FileName)
+ inputBinaryFile(f: FileName) ==
+ per [openBinaryFile(f::String,input$IOMode)$Lisp,f]
+ inputBinaryFile(f: String) ==
+ per [openBinaryFile(f,input$IOMode)$Lisp,f::FileName]
+ isOpen? ifile ==
+ not null? rep(ifile).stream
+ readByteIfCan! ifile ==
+ isOpen? ifile => readByteFromFile(rep(ifile).stream)$Lisp
+ error "file is not open"
+ eof? ifile ==
+ isOpen? ifile => readByteIfCan! ifile < 0@SingleInteger
+ error "file is not open"
+ close! ifile ==
+ if isOpen? ifile then
+ rep(ifile).stream := closeFile(rep(ifile).stream)$Lisp
+ ifile
+ coerce(ifile: %): OutputForm ==
+ rep(ifile).filename::OutputForm
+@
+
+\subsection{The OutputBinaryFile domain}
+
+<<domain OUTBFILE OutputBinaryFile>>=
+)abbrev domain OUTBFILE OutputBinaryFile
+++ Author: Gabriel Dos Reis
+++ Date Created: September 30, 2008
+++ Date Last Modified: September 30, 2008
+++ Description:
+++ This domain provides representation for binary files open
+++ for output operations. `Binary' here means that the conduits
+++ do not interpret their contents.
+OutputBinaryFile(): Public == Private where
+ Public == Join(OutputByteConduit, CoercibleTo OutputForm) with
+ outputBinaryFile: FileName -> %
+ ++ outputBinaryFile(f) returns an output conduit obtained by
+ ++ opening the file named by `f' as a binary file.
+ outputBinaryFile: String -> %
+ ++ outputBinaryFile(f) returns an output conduit obtained by
+ ++ opening the file named by `f' as a binary file.
+ isOpen?: % -> Boolean
+ ++ open?(ifile) holds if `ifile' is in open state.
+ Private == add
+ Rep == Record(stream: SExpression, filename: FileName)
+ outputBinaryFile(f: FileName) ==
+ per [openBinaryFile(f::String,output$IOMode)$Lisp,f]
+ outputBinaryFile(f: String) ==
+ per [openBinaryFile(f,output$IOMode)$Lisp,f::FileName]
+ isOpen? ifile ==
+ not null? rep(ifile).stream
+ writeByteIfCan!(ifile,b) ==
+ isOpen? ifile => writeByteToFile(rep(ifile).stream,b)$Lisp
+ error "file is not open"
+ close! ifile ==
+ if isOpen? ifile then
+ rep(ifile).stream := closeFile(rep(ifile).stream)$Lisp
+ ifile
+ coerce(ifile: %): OutputForm ==
+ rep(ifile).filename::OutputForm
+@
+
+
\section{The Hostname domain}
<<domain HOSTNAME Hostname>>=
@@ -195,6 +283,9 @@ PortNumber(): Public == Private where
<<category OUTBCON OutputByteConduit>>
<<category IOBCON InputOutputByteConduit>>
+<<domain INBFILE InputBinaryFile>>
+<<domain OUTBFILE OutputBinaryFile>>
+
<<domain HOSTNAME Hostname>>
<<domain PORTNUM PortNumber>>