Node:General files, Next:, Previous:Forth source files, Up:Files

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''

bin       fam1 -- 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-file       c-addr u wfam -- wfileid wior        file       ``open-file''

create-file       c-addr u wfam -- wfileid wior        file       ``create-file''

close-file       wfileid -- wior        file       ``close-file''

delete-file       c-addr u -- wior        file       ``delete-file''

rename-file       c-addr1 u1 c-addr2 u2 -- wior        file-ext       ``rename-file''
Rename file c_addr1 u1 to new name c_addr2 u2
read-file       c-addr u1 wfileid -- u2 wior        file       ``read-file''

read-line       c_addr u1 wfileid -- u2 flag wior         unknown       ``read-line''

write-file       c-addr u1 wfileid -- wior        file       ``write-file''

write-line       c-addr u fileid -- ior         file       ``write-line''

emit-file       c wfileid -- wior        gforth       ``emit-file''

flush-file       wfileid -- wior        file-ext       ``flush-file''

file-status       c-addr u -- wfam wior        file-ext       ``file-status''

file-position       wfileid -- ud wior        file       ``file-position''

reposition-file       ud wfileid -- wior        file       ``reposition-file''

file-size       wfileid -- ud wior        file       ``file-size''

resize-file       ud wfileid -- wior        file       ``resize-file''

slurp-file       c-addr1 u1 -- c-addr2 u2         unknown       ``slurp-file''
c-addr1 u1 is the filename, c-addr2 u2 is the file's contents
slurp-fid              unknown       ``slurp-fid''

stdin       -- wfileid        gforth       ``stdin''

stdout       -- wfileid        gforth       ``stdout''

stderr       -- wfileid        gforth       ``stderr''