1.2.7.4.6 SYS_FS_FileOpen Function

C

SYS_FS_HANDLE SYS_FS_FileOpen
(
    const char* fname,
    SYS_FS_FILE_OPEN_ATTRIBUTES attributes
);

Summary

Opens a file.

Description

This function opens a file with the requested attributes.

Precondition

Prior to opening a file, the name of the volume on which the file resides should be known and the volume should be mounted.

Parameters

ParamDescription
fnameThe name of the file to be opened along with the path. The fname format is as follows: "/mnt/volumeName/dirName/fileName". volumeName is the name of the volume/drive. dirName is the name of the directory under which the file is located. fileName is the name of the file to be opened. The "/mnt/volumeName" portion from the fName can be omitted if the SYS_FS_CurrentDriveSet () has been invoked to set the current drive/volume.
attributesAccess mode of the file, of type SYS_FS_FILE_OPEN_ATTRIBUTES

Returns

On success - A valid file handle will be returned

On failure - SYS_FS_HANDLE_INVALID. The reason for the failure can be retrieved with SYS_FS_Error.

Example

SYS_FS_HANDLE fileHandle;

fileHandle = SYS_FS_FileOpen("/mnt/myDrive/FILE.txt", (SYS_FS_FILE_OPEN_READ));

if(fileHandle != SYS_FS_HANDLE_INVALID)
{
    // File open succeeded.
}
else
{
    // File open failed.
}
// Using SYS_FS_CurrentDriveSet () function.

SYS_FS_HANDLE fileHandle;

SYS_FS_CurrentDriveSet("/mnt/myDrive");

fileHandle = SYS_FS_FileOpen("FILE.txt", (SYS_FS_FILE_OPEN_READ));

if(fileHandle != SYS_FS_HANDLE_INVALID)
{
    // File open succeeded.
}
else
{
    // File open failed.
}

Remarks

None.