MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / lseek

Method lseek

libraries/AP_Filesystem/AP_Filesystem_FATFS.cpp:528–559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

526}
527
528off_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
561static time_t fat_time_to_unix(uint16_t date, uint16_t time)
562{

Callers

nothing calls this directly

Calls 3

fileno_to_fatfsFunction · 0.85
isatty_Function · 0.85
fatfs_to_errnoFunction · 0.85

Tested by

no test coverage detected