Download FreeRTOS
 

Quality RTOS & Embedded Software

LIBRARIES
WHAT'S NEW
Simplifying Authenticated Cloud Connectivity for Any Device.
Designing an energy efficient and cloud-connected IoT solution with CoAP.
Introducing FreeRTOS Kernel version 11.0.0:
FreeRTOS Roadmap and Code Contribution process.
OPC-UA over TSN with FreeRTOS.

ff_stat() [FreeRTOS-Plus-FAT Standard API Reference]

ff_stdio.h  
int ff_stat( const char *pcFileName, FF_Stat_t *pxStatBuffer );

Populates an FF_Stat_t with information about a file. FF_Stat_t contains the fields shown in the table below:

Field
Description
st_dev The Device ID of the device containing the file.(_RB_ Actually set to xFindData.dirHandler.fsIndex. Could that be described as the index of the mount within the file system - where 0 is the root of the file system?)
st_ino The file's serial number.(_RB_ Actually set to xFindData.dirent->ulObjectCluster. Could that be described as the number of the cluster containing the start of the file.)
st_mode If the file is a directory then st_mode will be set to FF_IFDIR. Otherwise st_mode will be set to FF_IFREG (regular).
st_nlink Number of hard links to the fileHard coded to 1. Can st_nlink be removed from the strucutre.
st_uid User ID of file(_RB_ Actually hard coded to 0x1FF. Can st_uid just be removed from the stat structure?)
st_gid Group ID of the file(_RB_ Actually hard coded to 0x1FF. Can st_uid just be removed from the stat structure?)
st_rdev Device ID(_RB_ Duplicate of st_dev. Can st_rdev be removed from the stat structure?)
st_size The size of the file in bytes. ff_stat() cannot be used to obtain the size of an open file.
st_atime The time the file was last accessed. Only available if FF_TIME_SUPPORT is set to 1 in FreeRTOSFATConfig.h.
st_mtime The time the file was last modified. Only available if FF_TIME_SUPPORT is set to 1 in FreeRTOSFATConfig.h.
st_ctime The time the status of the file last changed. Only available if FF_TIME_SUPPORT is set to 1 in FreeRTOSFATConfig.h.

Parameters:

pcFileName A pointer to a standard null terminated C string that holds the name of the file on which stat information is being retrieved. The file name can include a relative path to the directory. 
pxStatBuffer A pointer to the FF_Stat_t to fill with information on the file. 

Returns:

  • If the stat structure was populated with information about the file then zero is returned.
  • If the stat structure could not be populated with information about the file then -1 is returned and the task's errno is set to indicate the reason. A task can obtain its errno value using the stdioGET_ERRNO() API function.

Example usage:


long lGetFileLength( char *pcFileName )
{
FF_Stat_t xStat;
long lReturn;

/* Find the length of the file with name pcFileName. */
if( ff_stat( pcFileName, &xStat ) == 0 )
{
lReturn = xStat.st_size;
}
else
{
/* Could not obtain the length of the file. */
lReturn = -1;
}

return lReturn;
}

Example use of the ff_stat() API function
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.