| 526 | } |
| 527 | |
| 528 | off_t AP_Filesystem_FATFS::lseek(int fileno, off_t position, int whence) |
| 529 | { |
| 530 | FRESULT res; |
| 531 | FIL *fh; |
| 532 | errno = 0; |
| 533 | |
| 534 | FS_CHECK_ALLOWED(-1); |
| 535 | WITH_SEMAPHORE(sem); |
| 536 | |
| 537 | // fileno_to_fatfs checks for fd out of bounds |
| 538 | fh = fileno_to_fatfs(fileno); |
| 539 | if (fh == nullptr) { |
| 540 | errno = EMFILE; |
| 541 | return -1; |
| 542 | } |
| 543 | if (isatty_(fileno)) { |
| 544 | return -1; |
| 545 | } |
| 546 | |
| 547 | if (whence == SEEK_END) { |
| 548 | position += f_size(fh); |
| 549 | } else if (whence==SEEK_CUR) { |
| 550 | position += fh->fptr; |
| 551 | } |
| 552 | |
| 553 | res = f_lseek(fh, position); |
| 554 | if (res) { |
| 555 | errno = fatfs_to_errno(res); |
| 556 | return -1; |
| 557 | } |
| 558 | return fh->fptr; |
| 559 | } |
| 560 | |
| 561 | static time_t fat_time_to_unix(uint16_t date, uint16_t time) |
| 562 | { |
nothing calls this directly
no test coverage detected