fs_ftruncate()

int  fs_ftruncate (FS_FILE   *p_file,
                   fs_off_t   size);

File

Called from

Code enabled by

fs_api.c

Application

FS_CFG_API_EN and not FS_CFG_RD_ONLY_EN

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

  1. The file must be opened in write or read/write mode.
  2. If fs_ftruncate() succeeds, the size of the file shall be equal to length.
  3. If the size of the file was previously greater than length, the extra data shall no longer be available.
  4. If the file previously was smaller than this length, the size of the file shall be increased.
  5. 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.