Ferreteria/v0.6/clade/Sys/FileSys/Mode/fopen modes
Jump to navigation
Jump to search
|
Modes in
fopen() |
About
(The following is Take 2b of trying to figure this out; previous attempts are here. I changed "E" (exists) to "F" (found).)
R= readable?W= writable?C= create file if not found?F= what to do if existing file found!= fail (return with error)0= erase (truncate to zero length)>= set pointer to end of file
Value-states
-= must be OFF/disabled+= must be ON/enabled
mode | R | W | C | F | documentation says... -----+---+---+---+---+---+---------------------- r | 1 | 0 | 0 | | ...reading only; start of file. r+ | 1 | 1 | 0 | | ...reading and writing; place the file pointer at the beginning of the file. w | 0 | 1 | 1 | 0 | ...writing only; start of file; truncate to zero length. If the file does not exist, attempt to create it. w+ | 1 | 1 | 1 | 0 | ...reading and writing; otherwise it has the same behavior as 'w'. a | 0 | 1 | 1 | > | ...writing only; file pointer at end of file. Create if not found. fseek() has no effect, writes are always appended. a+ | 1 | 1 | 1 | > | ...reading and writing; file pointer at end of file. Create if not found. fseek() only affects reading, writes appended. x | 0 | 1 | 1 | ! | ...writing only; file pointer at start of file. FAIL if found; create if not found. x+ | 1 | 1 | 1 | ! | ...reading and writing; otherwise it has the same behavior as 'x'. c | 0 | 1 | 1 | | ...writing only. Create if not found. No action if found. File pointer at start of file. c+ | 1 | 1 | 1 | | ...Open the file for reading and writing; otherwise it has the same behavior as 'c'.
The mode-request will now be a string consisting of repeated [R|W|C|E]<value> (case-insensitive), with optional spaces for readability.
Examples
r+ c+= readable file, create if neededr+ w+ c+ f-= read-write file, create if needed, clear any existing contentsr- w+= file must be write-only, don't care about other features