File System Helper Functions
121
SWRU455A – February 2017 – Revised March 2017
Copyright © 2017, Texas Instruments Incorporated
File System
_u32
Token;
SlFsFileInfo_t
FsFileInfo;
Status = sl_FsGetInfo( DeviceFileName, Token, &FsFileInfo);
if
( Status < 0 )
{
/*error */
}
8.8.2 Get Storage Information
This function retrieves information about the storage usage and the file system state. The function output
contains information regarding the number of security alerts, the number of allocated files user/system, the
configured storage size, the format type, and so forth.
Example:
_i32
Status;
SlFsControlGetStorageInfoResponse_t
GetStorageInfoResponse;
Status = sl_FsCtl( ( SlFsCtl_e)SL_FS_CTL_GET_STORAGE_INFO, 0, NULL , NULL , 0, (_u8
*)&GetStorageInfoResponse,
sizeof
(SlFsControlGetStorageInfoResponse_t), NULL );
if
( Status < 0 )
{
/*error */
}
8.8.3 Get List of Files
Retrieves the file list, names, and their main attributes, and observes how many blocks (= subsector, 4096
bytes) each file occupies on the SFLASH.
This function is an iterative function; the host retrieves an iterator that can be used to retrieve the next bulk
of files.
Example:
_i32 NumOfEntriesOrError = 1;
_i32 Index = -1;
slGetfileList_t File[COUNT];
_i32
i;
_i32 Status = 0;
while
( NumOfEntriesOrError > 0 )
{
NumOfEntriesOrError = sl_FsGetFileList( &Index, COUNT, (_u8)(SL_FS_MAX_FILE_NAME_
sizeof
(SlFileAttributes_t)), (
unsigned char
*)File, SL_FS_GET_FILE_ATTRIBUTES);
if
(NumOfEntriesOrError < 0)
{
Status = NumOfEntriesOrError;
//error
break
;
}
for
(i = 0; i < NumOfEntriesOrError; i++)
{
File[i].fileName
File[i].attribute.FileAllocatedBlocks
File[i].attribute.FileMaxSize,(_u16)File[i].attribute.Properties
*/
}
}
return
Status;
//0 means O.K
8.9
Bundle Protection
Bundling changes content to a group of files and then accepts or rejects the changes for all the files in the
group simultaneously. The bundle is used by the OTA process, which downloads a group of files and
needs the ability to first test the files and then to accept or reject the downloaded content.
shows a common work flow of using the bundle.