1 /*-----------------------------------------------------------------------*/ 2 /* Seek File R/W Pointer */ 3 /*-----------------------------------------------------------------------*/ 4 5 FRESULT f_lseek ( 6 FIL *fp, /* Pointer to the file object */ 7 DWORD ofs /* File pointer from top of file */ 8 ) 9 { 10 FRESULT res; 11 12 13 res = validate(fp->fs, fp->id); /* Check validity of the object */ 14 if (res != FR_OK) LEAVE_FF(fp->fs, res); 15 if (fp->flag & FA__ERROR) /* Check abort flag */ 16 LEAVE_FF(fp->fs, FR_INT_ERR); 17 18 #if _USE_FASTSEEK 19 if (fp->cltbl) { /* Fast seek */ 20 DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; 21 22 if (ofs == CREATE_LINKMAP) { /* Create CLMT */ 23 tbl = fp->cltbl; 24 tlen = *tbl++; ulen = 2; /* Given table size and required table size */ 25 cl = fp->sclust; /* Top of the chain */ 26 if (cl) { 27 do { 28 /* Get a fragment */ 29 tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ 30 do { 31 pcl = cl; ncl++; 32 cl = get_fat(fp->fs, cl); 33 if (cl <= 1) ABORT(fp->fs, FR_INT_ERR); 34 if (cl == 0xFFFFFFFF) ABORT(fp->
FATFS 初学之 f_lseek
最新推荐文章于 2024-10-01 19:31:30 发布
f_lseek函数用于移动文件读/写指针,可用于预分配簇以扩展文件大小。当在写模式下设置offset超过文件长度,文件会被扩展,新区域数据未定义。成功后需检查fptr成员以确认指针位置。若fptr异常,可能是文件结束或磁盘空间不足。了解更多详情,请参阅:https://www.cnblogs.com/Danhuise/p/3910059.html
摘要由CSDN通过智能技术生成