From 70702af1370e44e32fb2c3c507e4759a187b4fe5 Mon Sep 17 00:00:00 2001 From: Leo C Date: Thu, 8 Sep 2016 19:15:27 +0200 Subject: Import fatfs R0.12b --- fatfs/doc/en/lseek.html | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'fatfs/doc/en/lseek.html') diff --git a/fatfs/doc/en/lseek.html b/fatfs/doc/en/lseek.html index 0f22cf9..cf4f47e 100644 --- a/fatfs/doc/en/lseek.html +++ b/fatfs/doc/en/lseek.html @@ -17,8 +17,8 @@
FRESULT f_lseek ( - FIL* fp, /* [IN] File object */ - DWORD ofs /* [IN] File read/write pointer */ + FIL* fp, /* [IN] File object */ + FSIZE_t ofs /* [IN] File read/write pointer */ );@@ -29,7 +29,7 @@ FRESULT f_lseek (
The f_lseek() function moves the file read/write pointer of an open file. The offset can be specified in only origin from top of the file. When an offset beyond the file size is specified at write mode, the file size is expanded to the specified offset. The file data in the expanded area is undefined because no data is written to the file. This is suitable to pre-allocate a cluster chain quickly, for fast write operation. After the f_lseek() function succeeded, the current read/write pointer should be checked in order to make sure the read/write pointer has been moved correctry. In case of the current read/write pointer is not the expected value, either of followings has been occured.
+The f_lseek function moves the file read/write pointer of an open file. The offset can be specified in only origin from top of the file. When an offset beyond the file size is specified at write mode, the file size is expanded to the specified offset. The file data in the expanded area is undefined because no data is written to the file in this process. This is suitable to pre-allocate a cluster chain quickly, for fast write operation. When a contiguous data area needs to be allocated to the file, use f_expand function instead. After the f_lseek function succeeded, the current read/write pointer should be checked in order to make sure the read/write pointer has been moved correctry. In case of the read/write pointer is not the expected value, either of followings has been occured.
Fast seek feature is enabled when _USE_FASTSEEK is set to 1 and the member cltbl in the file object is not NULL. This feature enables fast backward/long seek operations without FAT access by using CLMT (cluster link map table). The fast seek feature is also applied to f_read()/f_write() function, however, the file size cannot be expanded by f_write()/f_lseek() function.
-The CLMT must be created in the user defined DWORD array prior to use the fast seek feature. To create the CLMT, set address of the DWORD array to the member cltbl in the file object, set the array size in unit of items into the first item and call the f_lseek() function with ofs = CREATE_LINKMAP. After the function succeeded and CLMT is created, no FAT access is occured at subsequent f_read()/f_write()/f_lseek() function to the file. If the function failed with FR_NOT_ENOUGH_CORE, the given array size is insufficient for the file and number of items required is returned into the first item of the array. The required array size is (number of fragments + 1) * 2 items. For example, when the file is fragmented in 5, 12 items will be required for the CLMT.
+The fast seek function enables fast backward/long seek operations without FAT access by using an on-memory CLMT (cluster link map table). It is applied to f_read and f_write function as well, however, the file size cannot be expanded by f_write, f_lseek function while the file is in fast seek mode.
+The fast seek function is enabled when the member cltbl in the file object is not NULL. The CLMT must be created into the DWORD array prior to use the fast seek function. To create the CLMT, set address of the DWORD array to the member cltbl in the open file object, set the size of array in unit of items to the first item and call the f_lseek function with ofs = CREATE_LINKMAP. After the function succeeded and CLMT is created, no FAT access is occured in subsequent f_read, f_write, f_lseek function to the file. The number of items used or required is returned into the first item of the array. The number of items to be used is (number of the file fragments + 1) * 2. For example, when the file is fragmented in 5, 12 items in the array will be used. If the function failed with FR_NOT_ENOUGH_CORE, the given array size is insufficient for the file.
Available when _FS_MINIMIZE <= 2.
+Available when _FS_MINIMIZE <= 2. To use fast seek function, _USE_FASTSEEK needs to be set 1.
-/* Using fast seek feature */ +/* Using fast seek function */ DWORD clmt[SZ_TBL]; /* Cluster link map table buffer */ + res = f_open(fp, fname, FA_READ | FA_WRITE); /* Open a file */ + res = f_lseek(fp, ofs1); /* This is normal seek (cltbl is nulled on file open) */ - fp->cltbl = clmt; /* Enable fast seek feature (cltbl != NULL) */ + fp->cltbl = clmt; /* Enable fast seek function (cltbl != NULL) */ clmt[0] = SZ_TBL; /* Set table size */ res = f_lseek(fp, CREATE_LINKMAP); /* Create CLMT */ ... @@ -121,7 +122,7 @@ FRESULT f_lseek ( -- cgit v1.2.3