FSfopen Function

MDD File System Interface Library

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

This function will open a ascii name file or directory on PIC24/PIC32/dsPIC MCU's. 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 or LFN 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, a new file 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 
  • FS_WRITE - Create a new file or replace an existing file
  • FS_READ - Read data from an existing file
  • FS_APPEND - Append data to an existing file
  • FS_WRITEPLUS - Create a new file or replace an existing file (reads also enabled)
  • FS_READPLUS - Read data from an existing file (writes also enabled)
  • FS_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.4.2 - [Oct 15, 2012]
Copyright © 2012 Microchip Technology, Inc.  All rights reserved.