fs_ftruncate()
int fs_ftruncate (FS_FILE *p_file, fs_off_t size);
File | Called from | Code enabled by |
---|---|---|
| Application |
|
Truncate a file.
Arguments
p_file
Pointer to a file.
size
Size of the file after truncation
Returned Value
0, if the function succeeds.
-1, otherwise.
Notes/Warnings
- The file must be opened in write or read/write mode.
- If
fs_ftruncate()
succeeds, the size of the file shall be equal to length. - If the size of the file was previously greater than length, the extra data shall no longer be available.
- If the file previously was smaller than this length, the size of the file shall be increased.
- If the file position indicator before the call to
fs_ftruncate()
lay in the extra data destroyed by the function, then the file position will be set to the end-of-file.