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

Function archive_fstat

libctru/source/archive_dev.c:787–808  ·  view source on GitHub ↗

! Get file stats from an open file * * @param[in,out] r newlib reentrancy struct * @param[in] fd Pointer to archive_file_t * @param[out] st Pointer to file stats to fill * * @returns 0 for success * @returns -1 for error */

Source from the content-addressed store, hash-verified

785 * @returns -1 for error
786 */
787static int
788archive_fstat(struct _reent *r,
789 void *fd,
790 struct stat *st)
791{
792 Result rc;
793 u64 size;
794 archive_file_t *file = (archive_file_t*)fd;
795
796 rc = FSFILE_GetSize(file->fd, &size);
797 if(R_SUCCEEDED(rc))
798 {
799 memset(st, 0, sizeof(struct stat));
800 st->st_size = (off_t)size;
801 st->st_nlink = 1;
802 st->st_mode = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
803 return 0;
804 }
805
806 r->_errno = archive_translate_error(rc);
807 return -1;
808}
809
810/*! Get file stats
811 *

Callers 1

archive_statFunction · 0.85

Calls 2

FSFILE_GetSizeFunction · 0.85
archive_translate_errorFunction · 0.85

Tested by

no test coverage detected