]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - fatfs/documents/doc/lseek.html
Merge branch 'chan-fatfs' into fatfs-integration
[z180-stamp.git] / fatfs / documents / doc / lseek.html
similarity index 51%
rename from fatfs/doc/en/lseek.html
rename to fatfs/documents/doc/lseek.html
index cf4f47e5124c5c1f3711fb2ba672233612cb9b31..7173b0e7cd98e26214eecfc7313d96eeca8dbf4d 100644 (file)
@@ -1,7 +1,7 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\r
 <html lang="en">\r
 <head>\r
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\r
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\r
 <meta http-equiv="Content-Style-Type" content="text/css">\r
 <link rel="up" title="FatFs" href="../00index_e.html">\r
 <link rel="alternate" hreflang="ja" title="Japanese" href="../ja/lseek.html">\r
@@ -29,7 +29,7 @@ FRESULT f_lseek (
 <dt>fp</dt>\r
 <dd>Pointer to the open file object.</dd>\r
 <dt>ofs</dt>\r
-<dd>Byte offset from top of the file. The data type <tt>FSIZE_t</tt> is an alias of either <tt>DWORD</tt>(32-bit) or <tt>QWORD</tt>(64-bit) depends on the configuration option <tt>_FS_EXFAT</tt>.</dd>\r
+<dd>Byte offset from top of the file to set read/write pointer. The data type <tt>FSIZE_t</tt> is an alias of either <tt>DWORD</tt>(32-bit) or <tt>QWORD</tt>(64-bit) depends on the configuration option <tt><a href="config.html#fs_exfat">FF_FS_EXFAT</a></tt>.</dd>\r
 </dl>\r
 </div>\r
 \r
@@ -48,19 +48,20 @@ FRESULT f_lseek (
 \r
 <div class="para desc">\r
 <h4>Description</h4>\r
-<p>The <tt>f_lseek</tt> 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 <em>undefined</em> 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 <tt>f_expand</tt> function instead. After the <tt>f_lseek</tt> 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.</p>\r
+<p>File read/write ponter in the open file object points the data byte to be read/written at next read/write operation. It advances as the number of bytes read/written. The <tt>f_lseek</tt> function moves the file read/write pointer without any read/write operation to the file.</p>\r
+<p>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 <em>undefined</em> because no data is written to the file in this process. This is suitable to pre-allocate a data area to the file quickly for fast write operation. When a contiguous data area needs to be allocated to the file, use <tt>f_expand</tt> function instead. After the <tt>f_lseek</tt> 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.</p>\r
 <ul>\r
 <li>End of file. The specified <tt class="arg">ofs</tt> was clipped at end of the file because the file has been opened in read-only mode.</li>\r
 <li>Disk full. There is no free space on the volume to expand the file.</li>\r
 </ul>\r
-<p>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 <tt>f_read</tt> and <tt>f_write</tt> function as well, however, the file size cannot be expanded by <tt>f_write</tt>, <tt>f_lseek</tt> function while the file is in fast seek mode.</p>\r
-<p>The fast seek function is enabled when the member <tt>cltbl</tt> in the file object is not NULL. The CLMT must be created into the <tt>DWORD</tt> array prior to use the fast seek function. To create the CLMT, set address of the <tt>DWORD</tt> array to the member <tt>cltbl</tt> in the open file object, set the size of array in unit of items to the first item and call the <tt>f_lseek</tt> function with <tt class="arg">ofs</tt><tt> = CREATE_LINKMAP</tt>. After the function succeeded and CLMT is created, no FAT access is occured in subsequent <tt>f_read</tt>, <tt>f_write</tt>, <tt>f_lseek</tt> 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 <tt>FR_NOT_ENOUGH_CORE</tt>, the given array size is insufficient for the file.</p>\r
+<p>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 <tt>f_read</tt> and <tt>f_write</tt> function as well, however, the file size cannot be expanded by <tt>f_write</tt>, <tt>f_lseek</tt> function while the file is at fast seek mode.</p>\r
+<p>The fast seek mode is enabled when the member <tt>cltbl</tt> in the file object is not NULL. The CLMT must be created into the <tt>DWORD</tt> array prior to use the fast seek function. To create the CLMT, set address of the <tt>DWORD</tt> array to the member <tt>cltbl</tt> in the open file object, set the size of array in unit of items to the first item and call the <tt>f_lseek</tt> function with <tt class="arg">ofs</tt><tt> = CREATE_LINKMAP</tt>. After the function succeeded and CLMT is created, no FAT access is occured in subsequent <tt>f_read</tt>, <tt>f_write</tt>, <tt>f_lseek</tt> 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 <tt>FR_NOT_ENOUGH_CORE</tt>, the given array size is insufficient for the file.</p>\r
 </div>\r
 \r
 \r
 <div class="para comp">\r
 <h4>QuickInfo</h4>\r
-<p>Available when <tt>_FS_MINIMIZE &lt;= 2</tt>. To use fast seek function, <tt>_USE_FASTSEEK</tt> needs to be set 1.</p>\r
+<p>Available when <tt><a href="config.html#fs_minimize">FF_FS_MINIMIZE</a> &lt;= 2</tt>. To use fast seek function, <tt><a href="config.html#use_fastseek">FF_USE_FASTSEEK</a></tt> needs to be set 1 to enable this feature.</p>\r
 </div>\r
 \r
 \r
@@ -73,30 +74,30 @@ FRESULT f_lseek (
     if (res) ...\r
 \r
     <span class="c">/* Move to offset of 5000 from top of the file */</span>\r
-    res = f_lseek(fp, 5000);\r
+    res = <em>f_lseek</em>(fp, 5000);\r
 \r
     <span class="c">/* Move to end of the file to append data */</span>\r
-    res = f_lseek(fp, f_size(fp));\r
+    res = <em>f_lseek</em>(fp, f_size(fp));\r
 \r
     <span class="c">/* Forward 3000 bytes */</span>\r
-    res = f_lseek(fp, f_tell(fp) + 3000);\r
+    res = <em>f_lseek</em>(fp, f_tell(fp) + 3000);\r
 \r
     <span class="c">/* Rewind 2000 bytes (take care on wraparound) */</span>\r
-    res = f_lseek(fp, f_tell(fp) - 2000);\r
+    res = <em>f_lseek</em>(fp, f_tell(fp) - 2000);\r
 </pre>\r
 <pre>\r
 <span class="c">/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */</span>\r
 \r
     res = f_open(fp, recfile, FA_CREATE_NEW | FA_WRITE);   <span class="c">/* Create a file */</span>\r
 \r
-    res = f_lseek(fp, PRE_SIZE);             <span class="c">/* Expand file size (cluster pre-allocation) */</span>\r
-    if (res || f_tell(fp) != PRE_SIZE) ...   <span class="c">/* Check if the file has been expanded */</span>\r
+    res = <em>f_lseek</em>(fp, PRE_SIZE);             <span class="c">/* Expand file size (cluster pre-allocation) */</span>\r
+    if (res || f_tell(fp) != PRE_SIZE) ...   <span class="c">/* Check if the file has been expanded successfly */</span>\r
 \r
-    res = f_lseek(fp, DATA_START);           <span class="c">/* Record data stream WITHOUT cluster allocation delay */</span>\r
+    res = <em>f_lseek</em>(fp, DATA_START);           <span class="c">/* Record data stream WITHOUT cluster allocation delay */</span>\r
     ...                                      <span class="c">/* Write operation should be aligned to sector boundary to optimize the write throughput */</span>\r
 \r
     res = f_truncate(fp);                    <span class="c">/* Truncate unused area */</span>\r
-    res = f_lseek(fp, 0);                    <span class="c">/* Put file header */</span>\r
+    res = <em>f_lseek</em>(fp, 0);                    <span class="c">/* Set file header */</span>\r
     ...\r
 \r
     res = f_close(fp);\r
@@ -108,14 +109,14 @@ FRESULT f_lseek (
 \r
     res = f_open(fp, fname, FA_READ | FA_WRITE);   <span class="c">/* Open a file */</span>\r
 \r
-    res = f_lseek(fp, ofs1);               <span class="c">/* This is normal seek (cltbl is nulled on file open) */</span>\r
+    res = <em>f_lseek</em>(fp, ofs1);               <span class="c">/* This is normal seek (cltbl is nulled on file open) */</span>\r
 \r
     fp-&gt;cltbl = clmt;                      <span class="c">/* Enable fast seek function (cltbl != NULL) */</span>\r
     clmt[0] = SZ_TBL;                      <span class="c">/* Set table size */</span>\r
-    res = f_lseek(fp, CREATE_LINKMAP);     <span class="c">/* Create CLMT */</span>\r
+    res = <em>f_lseek</em>(fp, CREATE_LINKMAP);     <span class="c">/* Create CLMT */</span>\r
     ...\r
 \r
-    res = f_lseek(fp, ofs2);               <span class="c">/* This is fast seek */</span>\r
+    res = <em>f_lseek</em>(fp, ofs2);               <span class="c">/* This is fast seek */</span>\r
 </pre>\r
 </div>\r
 \r