/usr/share/axiom-20170501/src/algebra/TEXTFILE.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | )abbrev domain TEXTFILE TextFile
++ Author: Stephen M. Watt
++ Date Created: 1985
++ Date Last Updated: June 4, 1991
++ Description:
++ This domain provides an implementation of text files. Text is stored
++ in these files using the native character set of the computer.
TextFile() : SIG == CODE where
StreamName ==> Union(FileName, "console")
SIG ==> FileCategory(FileName, String) with
writeLine_! : (%, String) -> String
++ writeLine!(f,s) writes the contents of the string s
++ and finishes the current line in the file f.
++ The value of s is returned.
writeLine_! : % -> String
++ writeLine!(f) finishes the current line in the file f.
++ An empty string is returned. The call \spad{writeLine!(f)} is
++ equivalent to \spad{writeLine!(f,"")}.
readLine_! : % -> String
++ readLine!(f) returns a string of the contents of a line from
++ the file f.
readLineIfCan_! : % -> Union(String, "failed")
++ readLineIfCan!(f) returns a string of the contents of a line from
++ file f, if possible. If f is not readable or if it is
++ positioned at the end of file, then \spad{"failed"} is returned.
readIfCan_! : % -> Union(String, "failed")
++ readIfCan!(f) returns a string of the contents of a line from
++ file f, if possible. If f is not readable or if it is
++ positioned at the end of file, then \spad{"failed"} is returned.
endOfFile? : % -> Boolean
++ endOfFile?(f) tests whether the file f is positioned after the
++ end of all text. If the file is open for output, then
++ this test is always true.
CODE ==> File(String) add
FileState ==> SExpression
Rep := Record(fileName: FileName, _
fileState: FileState, _
fileIOmode: String)
read_! f == readLine_! f
readIfCan_! f == readLineIfCan_! f
readLine_! f ==
f.fileIOmode ^= "input" => error "File not in read state"
s: String := read_-line(f.fileState)$Lisp
PLACEP(s)$Lisp => error "End of file"
s
readLineIfCan_! f ==
f.fileIOmode ^= "input" => error "File not in read state"
s: String := read_-line(f.fileState)$Lisp
PLACEP(s)$Lisp => "failed"
s
write_!(f, x) ==
f.fileIOmode ^= "output" => error "File not in write state"
PRINC(x, f.fileState)$Lisp
x
writeLine_! f ==
f.fileIOmode ^= "output" => error "File not in write state"
TERPRI(f.fileState)$Lisp
""
writeLine_!(f, x) ==
f.fileIOmode ^= "output" => error "File not in write state"
PRINC(x, f.fileState)$Lisp
TERPRI(f.fileState)$Lisp
x
endOfFile? f ==
f.fileIOmode = "output" => false
(EOFP(f.fileState)$Lisp pretend Boolean) => true
false
|