FSfopen Function

Microchip MDD File System Interface

MDDFS Interface Library Help
FSfopen Function
C
FSFILE * FSfopen(
    const char * fileName, 
    const char * mode
);
Description

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.

Preconditions

For read modes, file exists; FSInit performed

Parameters
Parameters 
Description 
fileName 
The name of the file to open 
mode 
  • WRITE - Create a new file or replace an existing file
  • READ - Read data from an existing file
  • APPEND - Append data to an existing file
  • WRITEPLUS - Create a new file or replace an existing file (reads also enabled)
  • READPLUS - Read data from an existing file (writes also enabled)
  • APPENDPLUS - Append data to an existing file (reads also enabled)

 

Return Values
Return Values 
Description 
FSFILE * 
The pointer to the file object 
NULL 
The file could not be opened 
Side Effects

The FSerrno variable will be changed.

Remarks

None.

Microchip MDD File System Interface 1.2.0 - [Aug 18, 2008]
Copyright © 2008 Microchip Technology, Inc.  All rights reserved.