fatfs v0.08 May 15, 2010:
- Added a memory configuration option. (_USE_LFN) - Added file lock feature. (_FS_SHARE) - Added fast seek feature. (_USE_FASTSEEK) - Changed some types on the API, XCHAR->TCHAR. - Changed fname member in the FILINFO structure on Unicode cfg. - String functions support UTF-8 encoding files on Unicode cfg.
This commit is contained in:
1 parent
e6cd91ca0b
commit
46155916b1
92 files changed
+2469
-1589
No files matched your search
+32
-14
@@ -4,6 +4,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
<link rel="up" title="FatFs" href="../00index_e.html">
|
||||
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/lseek.html">
|
||||
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
|
||||
<title>FatFs - f_lseek</title>
|
||||
</head>
|
||||
@@ -16,8 +17,8 @@
|
||||
|
||||
<pre>
|
||||
FRESULT f_lseek (
|
||||
FIL* <em>FileObject</em>, /* Pointer to the file object structure */
|
||||
DWORD <em>Offset</em> /* File offset in unit of byte */
|
||||
FIL* <em>FileObject</em>, <span>/* Pointer to the file object structure */</span>
|
||||
DWORD <em>Offset</em> <span>/* File offset in unit of byte */</span>
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
@@ -46,17 +47,20 @@ FRESULT f_lseek (
|
||||
<dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd>
|
||||
<dt>FR_INVALID_OBJECT</dt>
|
||||
<dd>The file object is invalid.</dd>
|
||||
<dt>FR_NOT_ENOUGH_CORE</dt>
|
||||
<dd>Insufficient size of link map table for the file.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para">
|
||||
<h4>Description</h4>
|
||||
<p>The f_lseek function moves the file R/W pointer of an open file. The offset can be specified in only origin from top of the file. When an offset above the file size is specified in write mode, the file size is increased and the data in the expanded area is undefined. This is suitable to create a large file quickly, for fast write operation. After the f_lseek function succeeded, member fptr in the file object should be checked in order to make sure the R/W pointer has been moved correctry. In case of fptr is not the expected value, either of followings has been occured.</p>
|
||||
<p>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 above the file size is specified in write mode, the file size is increased and the data in the expanded area is undefined. This is suitable to create a large file quickly, for fast write operation. After the f_lseek function succeeded, member fptr in the file object should be checked in order to make sure the read/write pointer has been moved correctry. In case of fptr is not the expected value, either of followings has been occured.</p>
|
||||
<ul>
|
||||
<li>End of file. The specified Offset was clipped at the file size because the file has been opened in read-only mode.</li>
|
||||
<li>Disk full. There is insufficient free space on the volume to expand the file size.</li>
|
||||
</ul>
|
||||
<p>When <tt>_USE_FASTSEEK</tt> is set to 1 and <tt>cltbl</tt> member in the file object is not NULL, the fast seek feature is enabled. This feature enables fast backward/long seek operations without FAT access by cluster link information stored on the user defined table. The cluster link information must be created prior to do the fast seek. The required size of the table is (number of fragments + 1) * 2 items. For example, when the file is fragmented in 5, 12 items will be required to store the cluster link information. The file size cannot be expanded when the fast seek feature is enabled.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -69,35 +73,49 @@ FRESULT f_lseek (
|
||||
<div class="para">
|
||||
<h4>Example</h4>
|
||||
<pre>
|
||||
/* Move to offset of 5000 from top of the file */
|
||||
<span>/* Move to offset of 5000 from top of the file */</span>
|
||||
res = f_lseek(file, 5000);
|
||||
|
||||
/* Move to end of the file to append data */
|
||||
<span>/* Move to end of the file to append data */</span>
|
||||
res = f_lseek(file, file->fsize);
|
||||
|
||||
/* Forward 3000 bytes */
|
||||
<span>/* Forward 3000 bytes */</span>
|
||||
res = f_lseek(file, file->fptr + 3000);
|
||||
|
||||
/* Rewind 2000 bytes (take care on overflow) */
|
||||
<span>/* Rewind 2000 bytes (take care on overflow) */</span>
|
||||
res = f_lseek(file, file->fptr - 2000);
|
||||
</pre>
|
||||
<pre>
|
||||
/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */
|
||||
<span>/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */</span>
|
||||
|
||||
res = f_open(file, recfile, FA_CREATE_NEW | FA_WRITE); /* Create a file */
|
||||
res = f_open(file, recfile, FA_CREATE_NEW | FA_WRITE); <span>/* Create a file */</span>
|
||||
|
||||
res = f_lseek(file, PRE_SIZE); /* Pre-allocate clusters */
|
||||
if (res || file->fptr != PRE_SIZE) ... /* Check if the file size has been increased correctly */
|
||||
res = f_lseek(file, PRE_SIZE); <span>/* Pre-allocate clusters */</span>
|
||||
if (res || file->fptr != PRE_SIZE) ... <span>/* Check if the file size has been increased correctly */</span>
|
||||
|
||||
res = f_lseek(file, DATA_START); /* Record data stream without cluster allocation delay */
|
||||
res = f_lseek(file, DATA_START); <span>/* Record data stream without cluster allocation delay */</span>
|
||||
...
|
||||
|
||||
res = f_truncate(file); /* Truncate unused area */
|
||||
res = f_lseek(file, 0); /* Put file header */
|
||||
res = f_truncate(file); <span>/* Truncate unused area */</span>
|
||||
res = f_lseek(file, 0); <span>/* Put file header */</span>
|
||||
...
|
||||
|
||||
res = f_close(file);
|
||||
</pre>
|
||||
<pre>
|
||||
<span>/* Using fast seek feature */</span>
|
||||
|
||||
DWORD lktbl[SZ_TBL]; <span>/* Link map table buffer */</span>
|
||||
|
||||
res = f_lseek(&file, ofs1); <span>/* This is normal seek (file.cltbl == NULL on file open) */</span>
|
||||
|
||||
file.cltbl = lktbl; <span>/* Enable fast seek feature */</span>
|
||||
lktbl[0] = SZ_TBL; <span>/* Set table size to the first item */</span>
|
||||
res = f_lseek(&file, CREATE_LINKMAP); <span>/* Create cluster link map table */</span>
|
||||
...
|
||||
|
||||
res = f_lseek(&file, ofs2); <span>/* This is fast seek (file.cltbl != NULL) */</span>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user