! 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 */
| 785 | * @returns -1 for error |
| 786 | */ |
| 787 | static int |
| 788 | archive_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 | * |
no test coverage detected