MCPcopy Create free account
hub / github.com/devkitPro/libctru / archive_ftruncate

Function archive_ftruncate

libctru/source/archive_dev.c:1244–1268  ·  view source on GitHub ↗

! Truncate an open file * * @param[in,out] r newlib reentrancy struct * @param[in] fd Pointer to archive_file_t * @param[in] len Length to truncate file to * * @returns 0 for success * @returns -1 for error */

Source from the content-addressed store, hash-verified

1242 * @returns -1 for error
1243 */
1244static int
1245archive_ftruncate(struct _reent *r,
1246 void *fd,
1247 off_t len)
1248{
1249 Result rc;
1250
1251 /* get pointer to our data */
1252 archive_file_t *file = (archive_file_t*)fd;
1253
1254 /* make sure length is non-negative */
1255 if(len < 0)
1256 {
1257 r->_errno = EINVAL;
1258 return -1;
1259 }
1260
1261 /* set the new file size */
1262 rc = FSFILE_SetSize(file->fd, len);
1263 if(R_SUCCEEDED(rc))
1264 return 0;
1265
1266 r->_errno = archive_translate_error(rc);
1267 return -1;
1268}
1269
1270/*! Synchronize a file to media
1271 *

Callers

nothing calls this directly

Calls 2

FSFILE_SetSizeFunction · 0.85
archive_translate_errorFunction · 0.85

Tested by

no test coverage detected