Note that BRender will recognise an environment variable (in some systems) called BRENDER_PATH, which will be used, if defined, to extend the search for unqualified file names beyond the current directory.
For background information on the following functions, read any standard C library documentation that you may have.
The attributes of the filing system; its capabilities as defined by a combination of the following flag values:
Name to open file as.
Mode in which to open file (
Return a file handle or
Buffer containing block to be written.
Size of each element in block.
Maximum number of elements to write.
Return the number of complete elements written, which may be less than
Format string as supplied to
Any further necessary parameters as would be required in
Returns the number of characters written, or a negative value if an error occurs.
Pointer to zero terminated string containing line of text to be written.
Character to write.
Name of file.
Number of characters required for
Call-back function that can be used to determine file type given the first
If this argument is non-
Return a file handle, or
Buffer to receive block.
Size of each element in block.
Maximum number of elements to read.
Return the number of complete elements read, which may be less than
Buffer to hold text read.
Length of buffer (maximum number of characters to store - including
The number of characters stored in the buffer is returned. If at the end of file upon entry, zero will be returned.
The character read from the file is returned (as though the character had been cast as
Number of bytes to advance.
Returns a non-zero value after the first read operation that attempts to read past the end of the file. It returns 0 if the current position is not end of file.
Description:
Determine capabilities of the filing system.BrFileAttributes()
br_uint_32 BrFileAttributes(void)
br_uint_32
Description:
Open a file for writing, over-writing any existing file of the same name.BrFileOpenWrite()
void* BrFileOpenWrite(const char* name, int mode)
const char * name
int mode
BR_FS_MODE_TEXT
or BR_FS_MODE_BINARY
). In the default implementation of the filing system (using the standard C library), this is effectively turned into a "w"
or "wb"
write mode parameter to fopen()
.name
and mode
.void *
Null
if the file could not be opened.
Description:
Write a block of data to a file.BrFileWrite()
int BrFileWrite(const void* buf, int size, int n, void* f)
const void * buf
int size
int n
void * f
n
elements from buf
to the file f
.int
n
if an error occurs (such as running out of file space).
Description:
Write a formatted string to a file.BrFilePrintf()
int BrFilePrintf(void* f, const char* fmt, ...)
void * f
.const char * fmt
printf()
....
printf()
.vsprintf()
).int
Description:
Write a line of text to a file, followed by writing the new-line character (BrFilePutLine()
`\n'
).void BrFilePutLine(const char* buf, void* f)
const char * buf
void * f
`\n'
).
Description:
Write a single character to a file.BrFilePutChar()
void BrFilePutChar(int c, void* f)
int c
void * f
Description:
Open a file for read access.BrFileOpenRead()
void* BrFileOpenRead(const char* name, br_size_t n_magics, br_mode_test_cbfn* mode_test, int* mode_result)
const char * name
br_size_t n_magics
mode_test
to determine file type (less than or equal to BR_MAX_FILE_MAGICS
).br_mode_test_cbfn * mode_test
n_magics
characters of a file. Will not be used if Null
.int * mode_result
Null
, the file type (if it could be determined) will be stored at the address pointed to.name
, if no path is specified with the file, looks in the current directory, if not found tries, in order, the directories listed in BRENDER_PATH (if defined). Having found the file, use mode_test
(if supplied) to find out if the file is text, binary or unknown. Store the result through mode_result
(if non-Null
). Obtain a handle to the file.void *
Null
if the file could not be opened.
Description:
Read a block of data from a file.BrFileRead()
int BrFileRead(void* buf, int size, int n, void* f)
void * buf
int size
int n
void * f
n
elements of size
bytes from the file f
and store them in buf
.br_size_t
n
if the end of file is encountered before all the elements could be read.
Description:
Read a line of text (excluding terminators) from a file.BrFileGetLine()
int BrFileGetLine(char* buf, br_size_t buf_len, void* f)
char * buf
br_size_t buf_len
`\0'
).void * f
buf_len
-1
characters have been read, end of line has been read, or end of file has been reached. If the last character read was `\n'
it is removed from the buffer.int
Description:
Read a character from a file.BrFileGetChar()
int BrFileGetChar(void* f)
void * f
.int
(int)(unsigned char)
). If a character could not be read because the file position was at the end of the file, BR_EOF
is returned.
Description:
Advance the file pointer a number of bytes through a binary stream.BrFileAdvance()
void BrFileAdvance(long int count, void* f)
long int count
void * f
BrFileOpenWrite()
57count
bytes.BR_FS_MODE_TEXT
, the accuracy of the file pointer is not guaranteed (unless count is zero).
Description:
Test a file pointer for end of file.BrFileEOF()
int BrFileEof(const void* f)
const void * f
and BrFileOpenWrite()
57int
BR_FS_MODE_TEXT
, the result may indicate end-of-file upon reaching an EOF character.
Description:
Close a previously opened file.BrFileClose()
void BrFileClose(void* f)
void * f
and BrFileOpenWrite()
57
Preconditions: Filing system handler dependent. BRender's default filing system requires BRender to have completed initialisation.
Effects: Close file.
See Also: Consult your Standard C library documentation.
Write mode. Either
Returns the old write mode.
If the application produces binary and text files then it will specify the write mode upon opening a file for writing.
When opening a file for read, it is opened in the same mode as it was written.
Description:
Instruct BRender to output data files in text or binary for subsequent `Save' operations.BrWriteModeSet()
int BrWriteModeSet(int mode)
int mode
BR_FS_MODE_TEXT
or BR_FS_MODE_BINARY
.BrModelSave()
245.
int
Generated with CERN WebMaker