1.2.7.4.12 SYS_FS_FileSize Function

C

int32_t SYS_FS_FileSize
(
    SYS_FS_HANDLE handle
);

Summary

Returns the size of the file in bytes.

Description

This function returns the size of the file as pointed by the handle.

Precondition

A valid file handle must be obtained before knowing a file size.

Parameters

ParamDescription
handleFile handle obtained during file Open.

Returns

On success - returns the size of the file in bytes.

On failure - returns -1. The reason for the failure can be retrieved with SYS_FS_Error or SYS_FS_FileError.

Example

SYS_FS_HANDLE fileHandle;
long fileSize;

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

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

fileSize = SYS_FS_FileSize(fileHandle);

if(fileSize != -1)
{
    // Success
}

Remarks

None.