<< Previous | Next >> | |
|
int fopen_wr( File * f, FileNumber name );
Description
- Open file for read or write. The given file number is composed of two parts: the low byte contains the file number (1 to 255 inclusive) and the high byte, if not zero, contains the metadata extent number. If the extent number is zero, it defaults to the correct metadata extent - this is for the purpose of validating an expected extent number. Most applications should just pass the file number with zero high byte.
- A file may be opened multiple times, with a different file descriptor pointer for each call, which allows the file to be read or written at more than one position at a time. A reference count for the actual file is maintained, so that the file can only be deleted when all file descriptors referring to this file are closed.
fopen_wr()
orfopen_rd()
must be called before any other function from this library is called that requires aFile
pointer. The "current position" is set to zero i.e. the start of the file.
- When a file is created, it is automatically opened for writing thus a subsequent call to
fopen_wr()
is redundant.Parameters
- f
- Pointer to file descriptor (uninitialized).
- name
- File number (1 to 255 inclusive).
Return value
0
: Success.
!0
: Failure.ERRNO values
ENOENT
- File does not exist, or metadata extent number does not match an existing file.Library
- fs2.lib
See also
- fclose, fopen_rd (FS2)
Dynamic C Functions | << Previous | Next >> | rabbit.com |