1.2.7.4.17 SYS_FS_FileStringGet Function

C

SYS_FS_RESULT SYS_FS_FileStringGet
(
    SYS_FS_HANDLE handle,
    char* buff,
    uint32_t len
);

Summary

Reads a string from the file into a buffer.

Description

This function reads a string of specified length from the file into a buffer. The read operation continues until

  • '\n' is stored

  • reached end of the file or

  • the buffer is filled with len - 1 characters. The read string is terminated with a '\0'.

Precondition

The file from which a string has to be read, has to be present and should have been opened.

Parameters

ParamDescription
handleHandle of the file from which string is to be read.
buffBuffer in which the string is to be stored.
lenlength of string to be read.

Returns

SYS_FS_RES_SUCCESS - String read operation was successful.

SYS_FS_RES_FAILURE - String read operation was unsuccessful. The reason for the failure can be retrieved with SYS_FS_Error or SYS_FS_FileError.

Example

SYS_FS_RESULT res;
SYS_FS_HANDLE fileHandle;
char CACHE_ALIGN buffer[100];

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

if(fileHandle != SYS_FS_HANDLE_INVALID)
{
    // File open is successful
}

// Read a string from the file.
res = SYS_FS_FileStringGet(fileHandle, buffer, 50);

if( res != SYS_FS_RES_SUCCESS)
{
    //String read operation failed.
}

Remarks

None.