aboutsummaryrefslogtreecommitdiff
path: root/src/interp
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/interp
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/interp')
-rw-r--r--src/interp/sys-utility.boot32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/interp/sys-utility.boot b/src/interp/sys-utility.boot
index 82fb11e2..57fc9a9b 100644
--- a/src/interp/sys-utility.boot
+++ b/src/interp/sys-utility.boot
@@ -220,3 +220,35 @@ PRINT_-AND_-EVAL_-DEFUN(name,body) ==
PRINT_-DEFUN(name,body)
+
+--% File IO
+$InputIOMode == KEYWORD::INPUT
+$OutputIOMode == KEYWORD::OUTPUT
+$BothWaysIOMode == KEYWORD::IO
+
+++ return a binary stream open for `file' in mode `mode'; nil
+++ if something wnet wrong.
+openBinaryFile(file,mode) ==
+ mode = $InputIOMode =>
+ OPEN(file,KEYWORD::DIRECTION,mode,
+ KEYWORD::IF_-DOES_-NOT_-EXIST,nil,
+ KEYWORD::ELEMENT_-TYPE,"%Byte")
+ OPEN(file,KEYWORD::DIRECTION,mode,
+ KEYWORD::IF_-EXISTS,KEYWORD::SUPERSEDE,
+ KEYWORD::ELEMENT_-TYPE,"%Byte")
+
+++ Attemp to read a byte from input file `ifile'. If not end of
+++ file, return the read byte; otherwise -1.
+readByteFromFile: %Thing -> %Short
+readByteFromFile ifile ==
+ byte := READ_-BYTE(ifile,false) => byte
+ -1
+
+++ Write byte `b' to output binary file `ofile'.
+writeByteToFile: (%Thing,%Byte) -> %Short
+writeByteToFile(ofile,b) ==
+ WRITE_-BYTE(b,ofile)
+
+closeFile file ==
+ CLOSE file
+ nil