5.17.2 General files

Files are opened/created by name and type. The following file access
methods (FAMs) are recognised:

r/o– fam file “r-o”

r/w– fam file “r-w”

w/o– fam file “w-o”

binfam1 – fam2 file “bin”

When a file is opened/created, it returns a file identifier,
wfileid that is used for all other file commands. All file
commands also return a status value, wior, that is 0 for a
successful operation and an implementation-defined non-zero value in the
case of an error.

open-filec-addr u wfam – wfileid wior file “open-file”

create-filec-addr u wfam – wfileid wior file “create-file”

close-filewfileid – wior file “close-file”

delete-filec-addr u – wior file “delete-file”

rename-filec-addr1 u1 c-addr2 u2 – wior file-ext “rename-file”

Rename file c_addr1 u1 to new name c_addr2 u2

read-filec-addr u1 wfileid – u2 wior file “read-file”

read-linec_addr u1 wfileid – u2 flag wior file “read-line”

key-filewfileid – c gforth “paren-key-file”

Read one character c from wfileid. This word disables
buffering for wfileid. If you want to read characters from a
terminal in non-canonical (raw) mode, you have to put the terminal in
non-canonical mode yourself (using the C interface); the exception is
stdin: Gforth automatically puts it into non-canonical mode.

key?-filewfileid – f gforth “key-q-file”

f is true if at least one character can be read from wfileid
without blocking. If you also want to use read-file or
read-line on the file, you have to call key?-file or
key-file first (these two words disable buffering).