FSFILE * FSfopen( const char * fileName, const char * mode );
This function will open a file or directory. First, RAM in the dynamic heap or static array will be allocated to a new FSFILE object. Then, the specified file name will be formatted to ensure that it's in 8.3 format. Next, the FILEfind function will be used to search for the specified file name. If the name is found, one of three things will happen: if the file was opened in read mode, its file info will be loaded using the FILEopen function; if it was opened in write mode, it will be erased, and a new file will be constructed in its place; if it was opened in append mode, its file info will be loaded with FILEopen and the current location will be moved to the end of the file using the FSfseek function. If the file was not found by FILEfind, it will be created if the mode was specified as a write or append mode. In these cases, a pointer to the heap or static FSFILE object array will be returned. If the file was not found and the mode was specified as a read mode, the memory allocated to the file will be freed and the NULL pointer value will be returned.
For read modes, file exists; FSInit performed
Parameters |
Description |
fileName |
The name of the file to open |
mode |
|
Return Values |
Description |
FSFILE * |
The pointer to the file object |
NULL |
The file could not be opened |
The FSerrno variable will be changed.
None.