1.2.7.4.9 SYS_FS_FileStat Function
C
SYS_FS_RESULT SYS_FS_FileStat ( const char *fname, SYS_FS_FSTAT *buf )
Summary
Gets file status.
Description
This function obtains information about a file associated with the file name, and populates the information in the structure pointed to by buf. This function can read the status of file regardless of whether a file is opened or not.
The file system supports 8.3 file name(Short File Name) and also long file name. 8.3 filenames are limited to at most eight characters, followed optionally by a filename extension consisting of a period . and at most three further characters. If the file name fits within the 8.3 limits then generally there will be no valid LFN for it.
For FAT File system
If LFN is used the stat structure's altname field will contain the short file name and fname will contain the long file name. The "lfname" member of the SYS_FS_FSTAT is not applicable for FAT. It has to be initialized to NULL before calling the API. If "lfname" is not NULL, then first byte of lfname will be set to zero indicating no file found.
For other File systems based on thier implementation -If LFN is used then the "lfname" member of the SYS_FS_FSTAT structure should be initialized with the address of a suitable buffer and the "lfsize" should be initialized with the size of the buffer. Once the function returns, the buffer whose address is held in "lfname" will have the file name(long file name).
The stat structure's fname field will contain the SFN and if there is a valid LFN entry for the file then the long file name will be copied into lfname member of the structure.
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
Param | Description |
---|---|
fname | Name of the file with the path and the volume name. The string of volume and file name has to be preceded by "/mnt/". Also, the volume name and file name has to be separated by a slash "/". |
buf | pointer to SYS_FS_FSTAT structure. |
Returns
SYS_FS_RES_SUCCESS - File stat operation was successful.
SYS_FS_RES_FAILURE - File stat operation was unsuccessful. The reason for the failure can be retrieved with SYS_FS_Error.
Example
SYS_FS_fStat fileStat;
if(SYS_FS_FileStat("/mnt/myDrive/FILE.TXT", &fileStat) == SYS_FS_RES_SUCCESS)
{
// Successfully read the status of file "FILE.TXT"
}
Remarks
None.