fatfs v0.07e Nov 03,2009:

- Separated out configuration options from ff.h to ffconf.h.
- Added a configuration option, _LFN_UNICODE.
- Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
- Fixed name matching error on the 13 char boundary.
- Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
This commit is contained in:
savelij13 committed 2025-09-11 09:36:45 +03:00
1 parent 25f499b847
commit e6cd91ca0b
76 files changed
+918 -636

No files matched your search

+28 -22
View File
@@ -12,7 +12,7 @@
<div class="para">
<h2>f_lseek</h2>
<p>The f_lseek function moves the file read/write pointer of an open file object. It can also be used to extend the file size (cluster pre-allocation).</p>
<p>The f_lseek function moves the file read/write pointer of an open file object. It can also be used to increase the file size (cluster pre-allocation).</p>
<pre>
FRESULT f_lseek (
@@ -52,51 +52,57 @@ FRESULT f_lseek (
<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 extended to the offset and the data in the extended 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 less than expected value, any of the followings has been occured.</p>
<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>
<ul>
<li>In read-only mode, the Offset was clipped in file size.</li>
<li>The drive gets full during the file extending process.</li>
<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>This function is not supported in minimization level of &gt;= 3.</p></div>
</div>
<div class="para">
<h4>QuickInfo</h4>
<p>Available when <tt>_FS_MINIMIZE &lt;= 2</tt>.</p>
</div>
<div class="para">
<h4>Example</h4>
<pre>
// Move to offset of 5000 from top of the file.
res = f_lseek(&amp;file, 5000);
/* Move to offset of 5000 from top of the file */
res = f_lseek(file, 5000);
// Move to end of the file to append data
res = f_lseek(&amp;file, file.fsize);
/* Move to end of the file to append data */
res = f_lseek(file, file-&gt;fsize);
// Forward 3000 bytes
res = f_lseek(&amp;file, file.fptr + 3000);
/* Forward 3000 bytes */
res = f_lseek(file, file-&gt;fptr + 3000);
// Rewind 2000 bytes (take care on overflow)
res = f_lseek(&amp;file, file.fptr - 2000);
/* Rewind 2000 bytes (take care on overflow) */
res = f_lseek(file, file-&gt;fptr - 2000);
</pre>
<pre>
// Cluster pre-allocation (to prevent buffer overrun on streaming write)
/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */
res = f_open(&amp;file, recfile, FA_CREATE_NEW | FA_WRITE); // Create a file
res = f_open(file, recfile, FA_CREATE_NEW | FA_WRITE); /* Create a file */
res = f_lseek(&amp;file, PRE_SIZE); // Pre-allocate clusters
if (res || file.fptr != PRE_SIZE) .... // Check if the file is extended corrctly
res = f_lseek(file, PRE_SIZE); /* Pre-allocate clusters */
if (res || file-&gt;fptr != PRE_SIZE) ... /* Check if the file size has been increased correctly */
res = f_lseek(&amp;file, DATA_START); // Record data stream without cluster allocation delay
res = f_lseek(file, DATA_START); /* Record data stream without cluster allocation delay */
...
res = f_truncate(&amp;file); // Truncate unused area
res = f_lseek(&amp;file, 0); // Put file header
res = f_truncate(file); /* Truncate unused area */
res = f_lseek(file, 0); /* Put file header */
...
res = f_close(&amp;file);
res = f_close(file);
</pre>
</div>
<div class="para">
<h4>References</h4>
<h4>See Also</h4>
<p><tt><a href="open.html">f_open</a>, <a href="truncate.html">f_truncate</a>, <a href="sfile.html">FIL</a></tt></p>
</div>