Next: The Byte Data Open Functions, Previous: Nonblocking I/O, Up: The File Library [Index]
The functions close the file argument if it opened before attempting to (re)open it.
file f_affix(file f, text path);
is f, opens the f object file for the path file reading
Same as ‘f_open’(f, path, ‘OPEN_READ’, ‘0’).
file f_bind(file f, text path);
is f, opens the f object file for the path file writing
Same as ‘f_open’(f, path, ‘OPEN_WRITE’, ‘0’).
file f_create(file f, text path, integer permissions);
is f, opens the f object file for the path file writing
Same as ‘f_open’(f, path, ‘OPEN_CREATE’ | ‘OPEN_TRUNCATE’ | ‘OPEN_WRITE’, permissions).
file f_dopen(file f, integer d, integer bits);
is f, opens the f object file for the d file descriptor reading or writing
The bits argument specify the open mode and is the bitwise OR of some file open bits.
Exactly one of the ‘OPEN_READ’ and ‘OPEN_WRITE’ need be specified. ‘OPEN_NONBLOCKING’ is the only other bit observed.
file f_open(file f, text path, integer bits, integer permissions);
is f, opens the f object file for the path file reading or writing
The ‘f_open’ semantics loosely follows the semantics of UNIX open
function.
The bits argument specify the open mode and is the bitwise OR of some file open bits.
Exactly one of the ‘OPEN_READ’ and ‘OPEN_WRITE’ need be specified.
If the file is to be created it will be created with the permissions
permissions (in same way as the open
(2) function, the permissions
argument is passed unchanged as the third argument to the open
(2)
function).
file f_opendir(file f, text path);
is f, opens the f object file for the path directory reading
Subsequent reads retrieve the path directory entry (i.e. file) names, separated by null bytes. Large reads exceeding the read buffer capacity (‘READ_BUFFER’) will see entry names truncated – the entry names that just happen to fall on the buffer end.
The names separator makes ‘f_case’ a suited directory reader, though other functions may be used as well.
See A brief ls.
file f_stderr(file f);
is f, opens the f object file for standard error writing
No new system file is created and no system file is closed when f is closed. Output is on unistd.h STDERR_FILENO.
While the output medium is the same the with program error (on which the ‘v_’ functions are writing) and with other files opened for standard error, the buffering is not (and if writing is done over multiple standard error interfaces and without sufficient flushing, the output may appear in a random order).
See The Output Library.
file f_stdin(file f);
is f, opens the f object file for standard input reading
No new system file is created and no system file is closed when f is closed. Input is from unistd.h STDIN_FILENO.
While the input medium is the same the with program input and with other files opened for standard input, the buffering is not (and if reading is done over multiple standard input interfaces, the input may appear out of order, as each interface may read ahead).
file f_stdout(file f);
is f, opens the f object file for standard output writing
No new system file is created and no system file is closed when f is closed. Output is on unistd.h STDOUT_FILENO.
While the output medium is the same the with program output (on which the ‘o_’ functions are writing) and with other files opened for standard output, the buffering is not (and if writing is done over multiple standard output interfaces and without sufficient flushing, the output may appear in a random order).
See The Output Library.
Next: The Byte Data Open Functions, Previous: Nonblocking I/O, Up: The File Library [Index]