SWRU455M February 2017 – October 2020 CC3120 , CC3120MOD , CC3130 , CC3135 , CC3135MOD , CC3220MOD , CC3220MODA , CC3220R , CC3220S , CC3220SF , CC3230S , CC3230SF , CC3235MODAS , CC3235MODASF , CC3235MODS , CC3235MODSF , CC3235S , CC3235SF
Opening an existing file for write is the preferred way to update the file content (rather than to delete it and recreate it). A file which was not closed or aborted cannot be opened for write.
Appending content to an existing file is not supported; when the file is opened for write, the storage of the file is erased.
If the file was created with a FAILSAFE flag, the storage of the nonactive content is erased; thus, if the device was powered off before the file closure, the file contains the last valid content.
If the file was created without a FAILSAFE flag, powering off the device before the file is closed results in no valid copy.
The operation of opening a file for write does not involve updating the file allocation table, unlike the create file function.
For a secure file, the default behavior is that when opening a file for write, all the tokens except the master are regenerated. The new tokens can be retrieved by the sl_FsGetInfo function.
If the file is already open (for write or read) or does not exist, sl_FsOpen() returns an error.
Table 9-5 shows a partial list of errors that might be returned by the creation function.
Error | Description |
---|---|
SL_ERROR_FS_FILE_IS_ALREADY_OPENED | The file is already opened for read or write. |
SL_ERROR_FS_INVALID_TOKEN_SECURITY_ALERT | For a secure file, the input token is not valid; this triggers security alerts if the device is secured. |
SL_ERROR_FS_FILE_NOT_EXISTS | The file does not exist. |
The following parameters are required to create a file: