"File-access + extensions"

file
The Optional File-Access Word Set and
File-Access Extension Words.
These words imply some kind of file-system unlike
the BLOCK wordset.
Tektronix CTE %version: 5.5 % GNU LGPL
[ANS]
* BIN ( access-mode -- access-mode' )

modify the give file access-mode to be a binary-mode

file ordinary primitive

* CLOSE-FILE ( file -- code )

close the file and return the status-code

file ordinary primitive

* CREATE-FILE ( str-adr str-len mode -- file code )

create the file with the given name and open
it - returns the file id and a status code.
A code of zero means success. An existing file
of the same name is truncated upon open.

file ordinary primitive

* DELETE-FILE ( str-adr str-len -- code )

delete the named file and return a status code

file ordinary primitive

* FILE-POSITION ( file -- p.pos code )

return the current position in the file and
return a status code. A code of zero means success.

file ordinary primitive

* FILE-SIZE ( file -- s.size code )

return the current size of the file and
return a status code. A code of zero means success.

file ordinary primitive

* INCLUDE-FILE ( file -- )

INTERPRET the given file

file ordinary primitive

* INCLUDED ( str-adr str-len -- )

open the named file and then INCLUDE-FILE
see also the interactive INCLUDE

file ordinary primitive

* OPEN-FILE ( str-adr str-len mode -- file code )

open the named file with mode. returns the
file id and a status code. A code of zero
means success.

file ordinary primitive

* R/O ( -- bitmask )

a bitmask for OPEN-FILE ( R/O R/W W/O BIN )

file ordinary constant

* R/W ( -- bitmask )

a bitmask for OPEN-FILE or CREATE-FILE ( R/O R/W W/O BIN )

file ordinary constant

* READ-FILE ( str-adr str-len file -- count code )

fill the given string buffer with characters
from the buffer. A status code of zero means
success and the returned count gives the
number of bytes actually read. If an error
occurs the number of already transferred bytes
is returned.

file ordinary primitive

* READ-LINE ( str-adr str-len file -- count flag code )

fill the given string buffer with one line
from the file. A line termination character
(or character sequence under WIN/DOS) may
also be placed in the buffer but is not
included in the final count. In other respects
this function performs a READ-FILE

file ordinary primitive

* REPOSITION-FILE ( o.offset file -- code )

reposition the file offset - the next FILE-POSITION
would return o.offset then. returns a status code.

file ordinary primitive

* RESIZE-FILE ( s.size file -- code )

resize the give file, returns a status code.

file ordinary primitive

* W/O ( -- bitmask )

a bitmask for OPEN-FILE or CREATE-FILE ( R/O R/W W/O BIN )

file ordinary constant

* WRITE-FILE ( str-adr str-len file -- code )

write characters from the string buffer to a file,
returns a status code.

file ordinary primitive

* WRITE-LINE ( str-adr str-len file -- )

write characters from the string buffer to a file,
and add the line-terminator to the end of it.
returns a status code.

file ordinary primitive

* FILE-STATUS ( str-adr str-len -- sub-code code )

check the named file - if it exists
the status code is zero. The sub-code
is implementation-specific.

file ordinary primitive

* FLUSH-FILE ( file -- code )

flush all unsaved buffers of the file to disk.
A status code of zero means success.

file ordinary primitive

* RENAME-FILE ( str-adr1 str-len1 str-adr2 str-len2 -- code )

rename the file named by string1 to the name of string2.
returns a status-code

file ordinary primitive

ENVIRONMENT ENVIRONMENT FILE-EXT

no special info, see general notes

file ordinary constant

* ENVIRONMENT MAX-FILES ( -- number )

the number of opened file-ids allowed during compilation.
portable programs can check this with ENVIRONMENT?

file ordinary primitive