ANSI C streams - Factor Documentation (original) (raw)

ANSI C streams
Factor handbook » Input and output

Prev: Checksums
Next: Non-blocking I/O implementation

C streams are found in the io.streams.c vocabulary; they are Stream protocol implementations which read and write C FILE* handles.
( handle -- stream )
( handle -- stream )

Underlying primitives used to implement the above:

fopen ( path mode -- alien )

fwrite ( data length alien -- )
fflush ( alien -- )
fclose ( alien -- )
fputc ( byte alien -- )
fgetc ( alien -- byte/f )
fread-unsafe ( n buf alien -- count )

The three standard file handles:

stdin-handle ( -- alien )

stdout-handle ( -- alien )
stderr-handle ( -- alien )