[ ]
Real time embedded FreeRTOS mailing list 
Homepage FreeRTOS Labs FreeRTOS+TCP FreeRTOS+FAT Contact / Enquiries


FreeRTOS+FAT is still in the lab
FreeRTOS+FAT is already in use in commercial products and we encourage you to try it yourself. Be aware however that FreeRTOS+FAT was acquired by Real Time Engineers Ltd., and is still being documented and updated to ensure it meets our strict quality standards. Please use the forum for support, or contact us directly if you have a specific business interest.

ff_stat()

[FreeRTOS+FAT Standard API Reference]

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

Populates an ff_stat_struct with information about a file.

ff_stat_struct contains the fileds 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 file

Hard 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_struct 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 ff_errno() API function.

Example usage:


long lGetFileLength( char *pcFileName )
{
ff_stat_struct 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



[ Back to the top ]    [ About FreeRTOS ]    [ FreeRTOS Labs Sitemap ]    [ Main FreeRTOS Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.