fatfs v0.10 Oct 02,2013:
- Added selection of character encoding on the file. (_STRF_ENCODE) - Added f_closedir(). - Added forced full FAT scan for f_getfree(). (_FS_NOFSINFO) - Added forced mount feature with changes of f_mount(). - Improved behavior of volume auto detection. - Improved write throughput of f_puts() and f_printf(). - Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write(). - Fixed f_write() can be truncated when the file size is close to 4GB. - Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect error code.
This commit is contained in:
1 parent
750225eb33
commit
f9a05f6eda
83 files changed
+1636
-1121
No files matched your search
+26
-25
@@ -42,7 +42,7 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
|
||||
|
||||
<h4>System organizations</h4>
|
||||
<p>The dependency diagram shown below is a typical configuration of the embedded system with FatFs module.</p>
|
||||
<p><img src="../img/modules.png" width="507" height="224" alt="dependency diagram"></p>
|
||||
<p><img src="../img/modules.png" width="580" height="280" alt="dependency diagram"></p>
|
||||
|
||||
<h4>Which function is required?</h4>
|
||||
<p>You need to provide only low level disk I/O functions that required by FatFs module and nothing else. If a working disk module for the target is already existing, you need to write only glue functions to attach it to the FatFs module. If not, you need to port any other disk module or write it from scratch. Most of defined functions are not that always required. For example, disk write function is not required in read-only configuration. Following table shows which function is required depends on configuration options.</p>
|
||||
@@ -66,8 +66,8 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
|
||||
<li>Number of open files: Unlimited, depends on available memory.</li>
|
||||
<li>Number of volumes: Upto 10.</li>
|
||||
<li>File size: Depends on FAT specs. (upto 4G-1 bytes)</li>
|
||||
<li>Volume size: Depends on FAT specs. (upto 2T bytes on 512 bytes/sector)</li>
|
||||
<li>Cluster size: Depends on FAT specs. (upto 64K bytes on 512 bytes/sector)</li>
|
||||
<li>Volume size: Depends on FAT specs. (upto 2T bytes at 512 bytes/sector)</li>
|
||||
<li>Cluster size: Depends on FAT specs. (upto 64K bytes at 512 bytes/sector)</li>
|
||||
<li>Sector size: Depends on FAT specs. (upto 4K bytes)</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -78,18 +78,18 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
|
||||
<tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>CM3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX600</th><th>IA-32</th></tr>
|
||||
<tr><td>Compiler</td><td>GCC</td><td>GCC</td><td>GCC</td><td>GCC</td><td>CH38</td><td>C30</td><td>CC78K0R</td><td>CA850</td><td>SHC</td><td>RXC</td><td>VC6</td></tr>
|
||||
<tr><td>_WORD_ACCESS</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td><td>1</td></tr>
|
||||
<!-- *ARM *Thumb *CM3 *AVR *H8 *PIC24 RL78 *V850ES *SH-2A *RX600 *IA-32 -->
|
||||
<tr class="lst3"><td>text (Full, R/W)</td><td>10395</td><td>7037</td><td>6555</td><td>13362</td><td>10609</td><td>11364</td><td>12884</td><td>7814</td><td>8783</td><td>5826</td><td>7659</td></tr>
|
||||
<tr> <td>text (Min, R/W)</td> <td>6519</td><td>4747</td><td>4315</td> <td>8608</td> <td>7043</td> <td>7539</td> <td>8860</td><td>5070</td><td>5723</td><td>3821</td><td>5038</td></tr>
|
||||
<tr> <td>text (Full, R/O)</td> <td>4563</td><td>3147</td><td>2911</td> <td>6174</td> <td>4925</td> <td>5340</td> <td>6136</td><td>3628</td><td>3863</td><td>2721</td><td>3534</td></tr>
|
||||
<tr> <td>text (Min, R/O)</td> <td>3311</td><td>2463</td><td>2209</td> <td>4610</td> <td>3817</td> <td>4029</td> <td>4641</td><td>2762</td><td>3003</td><td>2068</td><td>2722</td></tr>
|
||||
<!-- *ARM *Thumb *CM3 *AVR *H8 *PIC24 *RL78 *V850ES *SH-2A *RX600 *IA-32 -->
|
||||
<tr class="lst3"><td>text (Full, R/W)</td><td>10591</td><td>7119</td><td>6565</td><td>13240</td><td>10864</td><td>11619</td><td>13192</td><td>8031</td><td>8960</td><td>5977</td><td>7856</td></tr>
|
||||
<tr> <td>text (Min, R/W)</td> <td>6671</td><td>4595</td><td>4293</td> <td>8512</td> <td>7232</td> <td>7674</td> <td>9033</td><td>5235</td><td>5768</td><td>3923</td><td>5129</td></tr>
|
||||
<tr> <td>text (Full, R/O)</td> <td>4695</td><td>3121</td><td>2861</td> <td>6218</td> <td>5162</td> <td>5466</td> <td>6418</td><td>3799</td><td>3964</td><td>2847</td><td>3687</td></tr>
|
||||
<tr> <td>text (Min, R/O)</td> <td>3523</td><td>2463</td><td>2275</td> <td>4558</td> <td>4058</td> <td>4212</td> <td>4948</td><td>2959</td><td>3096</td><td>2199</td><td>2857</td></tr>
|
||||
<tr> <td>bss</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td></tr>
|
||||
<tr> <td>Work area<br>(_FS_TINY == 0)</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*544</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*544</td><td>V*564 +<br>F*544</td><td>V*564 +<br>F*544</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*550</td><td>V*564 +<br>F*550</td></tr>
|
||||
<tr><td>Work area<br>(_FS_TINY == 1)</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*32</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*32</td><td>V*564 +<br>F*32</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*36</td><td>V*564 +<br>F*36</td></tr>
|
||||
<tr> <td>Work area<br>(_FS_TINY == 0)</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*544</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td><td>V*560 +<br>F*550</td></tr>
|
||||
<tr><td>Work area<br>(_FS_TINY == 1)</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*32</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td><td>V*560 +<br>F*36</td></tr>
|
||||
</table>
|
||||
<p>These are the memory usage on some target systems with following condition. The memory sizes are in unit of byte, <em>V</em> denotes number of volumes and <em>F</em> denotes number of open files. All samples are optimezed in code size.</p>
|
||||
<pre>
|
||||
FatFs R0.09b options:
|
||||
FatFs R0.10 options:
|
||||
_FS_READONLY 0 (R/W), 1 (R/O)
|
||||
_FS_MINIMIZE 0 (Full function), 3 (Minimized function)
|
||||
_USE_STRFUNC 0 (Disable string functions)
|
||||
@@ -104,7 +104,7 @@ _FS_LABEL 0 (Disable volume label functions)
|
||||
_VOLUMES V (Number of logical drives to be used)
|
||||
_MULTI_PARTITION 0 (Single partition per drive)
|
||||
_FS_REENTRANT 0 (Disable reentrancy)
|
||||
_FS_LOCK 0 (Disable shareing control)
|
||||
_FS_LOCK 0 (Disable file lock control)
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@@ -122,6 +122,7 @@ _FS_LOCK 0 (Disable shareing control)
|
||||
<tr><td>f_sync</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_lseek</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_opendir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_closedir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_readdir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_stat</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
<tr><td>f_getfree</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
|
||||
@@ -150,7 +151,7 @@ _FS_LOCK 0 (Disable shareing control)
|
||||
<h3>Long File Name</h3>
|
||||
<p>The FatFs module has started to support long file name (LFN) at revision 0.07. The two different file names, SFN and LFN, of a file is transparent in the file functions except for f_readdir function. To enable LFN feature, set <tt>_USE_LFN</tt> to 1, 2 or 3, and add a Unicode code conversion function <tt>ff_convert()</tt> and <tt>ff_wtoupper()</tt> to the project. The LFN feature requiers a certain working buffer in addition. The buffer size can be configured by <tt>_MAX_LFN</tt> corresponding to the available memory size. The size of long file name will reach up to 255 characters, so that the <tt>_MAX_LFN</tt> should be set to 255 for full featured LFN operation. If the size of working buffer is insufficient for the given file name, the file function fails with <tt>FR_INVALID_NAME</tt>. When enable the LFN feature with re-entrant feature, <tt>_USE_LFN</tt> must be set to 2 or 3. In this case, the file function allocates the working buffer on the stack or heap. The working buffer occupies <tt>(_MAX_LFN + 1) * 2</tt> bytes.</p>
|
||||
<table class="lst2 rset">
|
||||
<caption>LFN cfg on ARM7</caption>
|
||||
<caption>LFN cfg on ARM7TDMI</caption>
|
||||
<tr><th>Code page</th><th>Program size</th></tr>
|
||||
<tr><td>SBCS</td><td>+3.7K</td></tr>
|
||||
<tr><td>932(Shift-JIS)</td><td>+62K</td></tr>
|
||||
@@ -164,26 +165,26 @@ _FS_LOCK 0 (Disable shareing control)
|
||||
|
||||
<div class="para" id="unicode">
|
||||
<h3>Unicode API</h3>
|
||||
<p>In default, FatFs supports ANSI/OEM code set on the API but FatFs can also switch the code set to Unicode. This means the FatFs supports the True LFN feature. For more information, refer to the description in the <a href="filename.html">file name</a>.</p>
|
||||
<p>By default, FatFs uses ANSI/OEM code set on the API under LFN configuration. FatFs can also switch the character encoding to Unicode on the API (<tt>_LFN_UNICODE</tt>). This means the FatFs supports the True-LFN feature. For more information, refer to the description in the <a href="filename.html">file name</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="para" id="reentrant">
|
||||
<h3>Re-entrancy</h3>
|
||||
<p>The file operations to the different volume is always re-entrant and can work simultaneously. The file operations to the same volume is not re-entrant but it can also be configured to thread-safe with <tt>_FS_REENTRANT</tt> option. In this case, also the OS dependent synchronization object control functions, <tt>ff_cre_syncobj(), ff_del_syncobj(), ff_req_grant() and ff_rel_grant()</tt> must be added to the project.</p>
|
||||
<p>When a file function is called while the volume is in use by any other task, the file function is suspended until that task leaves file function. If wait time exceeded a period defined by <tt>_TIMEOUT</tt>, the file function will abort with <tt>FR_TIMEOUT</tt>. The timeout feature might not be supported on some RTOS.</p>
|
||||
<p>There is an exception on <tt>f_mount()</tt> and <tt>f_mkfs()</tt> function. These functions are not re-entrant to the same volume. When use these functions, all other task must close the corresponding file on the volume and avoid to access the volume.</p>
|
||||
<p>Note that this section describes on the re-entrancy of the FatFs module itself but also the low level disk I/O layer must be re-entrant.</p>
|
||||
<p>When a file function is called while the volume is in use by any other task, the file function is suspended until that task leaves file function. If wait time exceeded a period defined by <tt>_TIMEOUT</tt>, the file function will abort with <tt>FR_TIMEOUT</tt>. The timeout feature might not be supported by some RTOS.</p>
|
||||
<p>There is an exception for <tt>f_mount(), f_mkfs(), f_fdisk()</tt> function. These functions are not re-entrant to the same volume or corresponding physical drive. When use these functions, all other tasks must unmount the volume and avoid to access the volume.</p>
|
||||
<p>Note that this section describes on the re-entrancy of the FatFs module itself but also the low level disk I/O layer will need to be re-entrant.</p>
|
||||
</div>
|
||||
|
||||
<div class="para" id="dup">
|
||||
<h3>Duplicated File Access</h3>
|
||||
<p>FatFs module does not support the shareing controls of duplicated file access in default. It is permitted when open method to a file is only read mode. The duplicated open in write mode to a file is always prohibited and open file must not be renamed, deleted, or the FAT structure on the volume can be collapted.</p>
|
||||
<p>The file shareing control can also be available when <tt>_FS_LOCK</tt> is set to 1 or grater. The value specifies the number of files to manage simultaneously. In this case, if any open, rename or remove that violating the file shareing rule that described above is attempted, the file function will fail with <tt>FR_LOCKED</tt>. If number of open files gets larger than <tt>_FS_LOCK</tt>, the <tt>f_open()</tt> function will fail with <tt>FR_TOO_MANY_OPEN_FILES</tt>.</p>
|
||||
<p>The file shareing control can also be available when <tt>_FS_LOCK</tt> is set to 1 or grater. The value specifies the number of files to manage simultaneously. In this case, if any open, rename or remove that violating the file shareing rule that described above is attempted, the file function will fail with <tt>FR_LOCKED</tt>. If number of open objects gets larger than <tt>_FS_LOCK</tt>, the <tt>f_open()/f_opendir()</tt> function will fail with <tt>FR_TOO_MANY_OPEN_FILES</tt>.</p>
|
||||
</div>
|
||||
|
||||
<div class="para" id="fs1">
|
||||
<h3>Performance Effective File Access</h3>
|
||||
<p>For good performance on reading/writing files on the small embedded system, application programmer should consider what process is done in the FatFs module. The file data on the volume is transferred in following sequence by <tt>f_read()</tt> function.</p>
|
||||
<p>For good performance to read/write files on the small embedded system, application programmer should consider what process is done in the FatFs module. The file data on the volume is transferred in following sequence by <tt>f_read()</tt> function.</p>
|
||||
<p>Figure 1. Sector miss-aligned read (short)<br>
|
||||
<img src="../img/f1.png" width="490" height="110" alt="">
|
||||
</p>
|
||||
@@ -193,9 +194,9 @@ _FS_LOCK 0 (Disable shareing control)
|
||||
<p>Figure 3. Sector aligned read<br>
|
||||
<img src="../img/f3.png" width="490" height="119" alt="">
|
||||
</p>
|
||||
<p>The file I/O buffer is a sector buffer to read/write a partial data on the sector. The sector buffer is either file private sector buffer on each file object or shared sector buffer on the file system object. The buffer configuration option <tt>_FS_TINY</tt> determins which sector buffer is used for the file data transfer. When tiny buffer (1) is selected, data memory consumption is reduced 512 bytes each file object. In this case, FatFs module uses only a sector buffer on the file system object for file data transfer and FAT/directory access. The disadvantage of the tiny buffer configuration is: the FAT data cached in the sector buffer will be lost by file data transfer and it must be reloaded at every cluster boundary. However it will be suitable for most application from view point of the decent performance and low memory comsumption.</p>
|
||||
<p>Figure 1 shows that a partial sector is transferred via the file I/O buffer. On long data transfer shown in Figure 2, middle of transfer data that covers one or more sector is transferred to application buffer directly. Figure 3 shows that the case of entier transfer data is aligned to the sector boundary. In this case, file I/O buffer is not used. On the direct transfer, the maximum extent of sectors are read with <tt>disk_read()</tt> function at a time but the multiple sector transfer never across the cluster boundary even if it is contiguous.</p>
|
||||
<p>Therefore taking effort to sector aligned read/write accesss avoids buffered data transfer and the read/write performance will be improved. Besides the effect, cached FAT data will not be flushed by file data transfer on the tiny configuration so that it can achieve same performance as non-tiny configuration with small memory footprint.</p>
|
||||
<p>The file I/O buffer is a sector buffer to read/write a partial data on the sector. The sector buffer is either file private sector buffer on each file object or shared sector buffer in the file system object. The buffer configuration option <tt>_FS_TINY</tt> determins which sector buffer is used for the file data transfer. When tiny buffer (1) is selected, data memory consumption is reduced 512 bytes each file object. In this case, FatFs module uses only a sector buffer in the file system object for file data transfer and FAT/directory access. The disadvantage of the tiny buffer configuration is: the FAT data cached in the sector buffer will be lost by file data transfer and it must be reloaded at every cluster boundary. However it will be suitable for most application from view point of the decent performance and low memory comsumption.</p>
|
||||
<p>Figure 1 shows that a partial sector, sector mis-aligned part of the file, is transferred via the file I/O buffer. On long data transfer shown in Figure 2, middle of transfer data that covers one or more sector is transferred to the application buffer directly. Figure 3 shows that the case of entier transfer data is aligned to the sector boundary. In this case, file I/O buffer is not used. On the direct transfer, the maximum extent of sectors are read with <tt>disk_read()</tt> function at a time but the multiple sector transfer never across the cluster boundary even if it is contiguous.</p>
|
||||
<p>Therefore taking effort to sector aligned read/write accesss avoids buffered data transfer and the read/write performance will be improved. Besides the effect, cached FAT data will not be flushed by file data transfer at the tiny configuration, so that it can achieve same performance as non-tiny configuration with small memory footprint.</p>
|
||||
</div>
|
||||
|
||||
<div class="para" id="fs2">
|
||||
@@ -231,7 +232,7 @@ Figure 5. Minimized critical section<br>
|
||||
<li>The file created as new or overwritten remains but no content.</li>
|
||||
<li>Efficiency of disk use gets worse due to lost clusters.</li>
|
||||
</ul>
|
||||
<p>Each case does not affect the files that not opened in write mode. To minimize risk of data loss, the critical section can be minimized like shown in Figure 5 by minimizing the time that file is opened in write mode or using <tt>f_sync()</tt> function properly.</p>
|
||||
<p>Each case does not affect the files that not opened in write mode. To minimize risk of data loss, the critical section can be minimized by minimizing the time that file is opened in write mode or using <tt>f_sync()</tt> function as shown in Figure 5.</p>
|
||||
</div>
|
||||
|
||||
<div class="para" id="fs3">
|
||||
@@ -248,7 +249,7 @@ Figure 5. Minimized critical section<br>
|
||||
<h3>About FatFs License</h3>
|
||||
<p>This is a copy of the FatFs license document that included in the source codes.</p>
|
||||
<pre>/*----------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module R0.09b (C)ChaN, 2013
|
||||
/ FatFs - FAT file system module R0.10 (C)ChaN, 2013
|
||||
/-----------------------------------------------------------------------------/
|
||||
/ FatFs module is a generic FAT file system module for small embedded systems.
|
||||
/ This is a free software that opened for education, research and commercial
|
||||
@@ -262,7 +263,7 @@ Figure 5. Minimized critical section<br>
|
||||
/ * Redistributions of source code must retain the above copyright notice.
|
||||
/
|
||||
/-----------------------------------------------------------------------------/</pre>
|
||||
<p>Therefore FatFs license is one of the BSD-style license but there is a big difference. Because FatFs is for embedded projects, the conditions for redistributions in binary form, such as embedded code, hex file and binary library, is not specified to increase its usability. The documentation of the distributions need not include about FatFs and its license document, and it may also. Of course FatFs is compatible with the projects under GNU GPL. When redistribute it with any modification, the license can also be changed to GNU GPL or BSD-style license.</p>
|
||||
<p>Therefore FatFs license is one of the BSD-style license but there is a significant feature. Because FatFs is for embedded projects, the conditions for redistributions in binary form, such as embedded code, hex file and binary library, are not specified to increase its usability. The documentation of the distributions need not include about FatFs and its license document, and it may also. This is equivalent to the BSD 1-Clause License. Of course FatFs is compatible with the projects under GNU GPL. When redistribute the FatFs with any modification, the license can also be changed to GNU GPL or BSD-style license.</p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
<p>The f_chdrive function changes the current drive.</p>
|
||||
<pre>
|
||||
FRESULT f_chdrive (
|
||||
BYTE <span class="arg">vol</span> <span class="c">/* [IN] Logical drive number */</span>
|
||||
const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] Logical drive number */</span>
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
@@ -24,7 +24,7 @@ FRESULT f_chdrive (
|
||||
<div class="para arg">
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>vol</dt>
|
||||
<dt>path</dt>
|
||||
<dd>Specifies the <a href="filename.html">logical drive number</a> to be set as the current drive.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
@@ -46,7 +46,7 @@ FRESULT f_chdrive (
|
||||
|
||||
<div class="para comp">
|
||||
<h4>QuickInfo</h4>
|
||||
<p>Available when <tt>_FS_RPATH >= 1</tt>.</p>
|
||||
<p>Available when <tt>_FS_RPATH >= 1</tt> and <tt>_VOLUMES >= 2</tt>.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -13,7 +13,7 @@
|
||||
|
||||
<div class="para func">
|
||||
<h2>f_chmod</h2>
|
||||
<p>The f_chmod function changes the attribute of a file or directory.</p>
|
||||
<p>The f_chmod function changes the attribute of a file or sub-directory.</p>
|
||||
<pre>
|
||||
FRESULT f_chmod (
|
||||
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Object name */</span>
|
||||
@@ -27,7 +27,7 @@ FRESULT f_chmod (
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>path</dt>
|
||||
<dd>Pointer to the null-terminated string that specifies a <a href="filename.html">file or directory</a> to be changed</dd>
|
||||
<dd>Pointer to the null-terminated string that specifies an <a href="filename.html">object</a> to be changed</dd>
|
||||
<dt>attr</dt>
|
||||
<dd>Attribute flags to be set in one or more combination of the following flags. The specified flags are set and others are cleard.<br>
|
||||
<table class="lst">
|
||||
@@ -66,7 +66,7 @@ FRESULT f_chmod (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_chmod()</tt> function changes the attribute of a file or directory.</p>
|
||||
<p>The <tt>f_chmod()</tt> function changes the attribute of a file or sub-directory.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
+2
-1
@@ -45,7 +45,8 @@ FRESULT f_close (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_close()</tt> function closes an open file object. If any data has been written to the file, the cached information of the file is written back to the disk. After the function succeeded, the file object is no longer valid and it can be discarded.</p>
|
||||
<p>The <tt>f_close()</tt> function closes an open file object. If any data has been written to the file, the cached information of the file is written back to the volume. After the function succeeded, the file object is no longer valid and it can be discarded.</p>
|
||||
<p>Note that if the file object is in read-only mode and <tt>_FS_LOCK</tt> option is not enabled, the file object can also be discarded without this process. However it is not recommended for future compatibility.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html lang="en">
|
||||
<head>
|
||||
<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/close.html">
|
||||
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
|
||||
<title>FatFs - f_closedir</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="para func">
|
||||
<h2>f_closedir</h2>
|
||||
<p>The f_closedir function closes an open directory.</p>
|
||||
<pre>
|
||||
FRESULT f_closedir (
|
||||
DIR* <span class="arg">dp</span> <span class="c">/* [IN] Pointer to the directory object */</span>
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<div class="para arg">
|
||||
<h4>Parameter</h4>
|
||||
<dl class="par">
|
||||
<dt>dp</dt>
|
||||
<dd>Pointer to the open directory object structure to be closed.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para ret">
|
||||
<h4>Return Values</h4>
|
||||
<p>
|
||||
<a href="rc.html#ok">FR_OK</a>,
|
||||
<a href="rc.html#ie">FR_INT_ERR</a>,
|
||||
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
||||
<a href="rc.html#tm">FR_TIMEOUT</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_closedir()</tt> function closes an open directory object. After the function succeeded, the file object is no longer valid and it can be discarded.</p>
|
||||
<p>Note that the directory object can also be discarded without this process unless <tt>_FS_LOCK</tt> option is not enabled. However it is not recommended for future compatibility.</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para comp">
|
||||
<h4>QuickInfo</h4>
|
||||
<p>Available when <tt>_FS_MINIMIZE <= 1</tt>.</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para ref">
|
||||
<h4>See Also</h4>
|
||||
<p><tt><a href="opendir.html">f_opendir</a>, <a href="readdir.html">f_readdir</a>, <a href="sdir.html">DIR</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
</body>
|
||||
</html>
|
||||
+1
-1
@@ -32,7 +32,7 @@ DSTATUS disk_initialize (
|
||||
|
||||
<div class="para ret">
|
||||
<h4>Return Values</h4>
|
||||
<p>This function returns a disk status as the result. For details of the disk status, refer to the <a href="dstat.html">disk_status</a> function.</p>
|
||||
<p>This function returns a disk status as the result. For details of the disk status, refer to the <a href="dstat.html">disk_status()</a> function.</p>
|
||||
</div>
|
||||
|
||||
<div class="para desc">
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ DRESULT disk_read (
|
||||
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Physical drive number */</span>
|
||||
BYTE* <span class="arg">buff</span>, <span class="c">/* [OUT] Pointer to the read data buffer */</span>
|
||||
DWORD <span class="arg">sector</span>, <span class="c">/* [IN] Start sector number */</span>
|
||||
BYTE <span class="arg">count</span> <span class="c">/* [IN] Number of sectros to read */</span>
|
||||
UINT <span class="arg">count</span> <span class="c">/* [IN] Number of sectros to read */</span>
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
@@ -34,7 +34,7 @@ DRESULT disk_read (
|
||||
<dt>sector</dt>
|
||||
<dd>Specifies the start sector number in logical block address (LBA).</dd>
|
||||
<dt>count</dt>
|
||||
<dd>Specifies number of sectors to read. The value can be 1 to 128. Generally, a multiple sector transfer request must not be split into single sector transactions to the device, or you may not get good read performance.</dd>
|
||||
<dd>Specifies number of sectors to read. FatFs specifis with 1 to 128. Generally, a multiple sector transfer request must not be split into single sector transactions to the device, or you may not get good read performance.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ DRESULT disk_write (
|
||||
BYTE <span class="arg">drv</span>, <span class="c">/* [IN] Physical drive number */</span>
|
||||
const BYTE* <span class="arg">buff</span>, <span class="c">/* [IN] Write data (may be non aligned) */</span>
|
||||
DWORD <span class="arg">sector</span>, <span class="c">/* [IN] Sector number to write */</span>
|
||||
BYTE <span class="arg">count</span> <span class="c">/* [IN] Number of sectors to write */</span>
|
||||
UINT <span class="arg">count</span> <span class="c">/* [IN] Number of sectors to write */</span>
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
@@ -34,7 +34,7 @@ DRESULT disk_write (
|
||||
<dt>sector</dt>
|
||||
<dd>Specifies the start sector number in logical block address (LBA).</dd>
|
||||
<dt>count</dt>
|
||||
<dd>Specifies the number of sectors to write. The value can be 1 to 128. Generally, a multiple sector transfer request must not be split into single sector transactions to the device, or you will never get good write performance.</dd>
|
||||
<dd>Specifies the number of sectors to write. FatFs specifis 1 to 128. Generally, a multiple sector transfer request must not be split into single sector transactions to the device, or you will never get good write performance.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ int f_error (
|
||||
|
||||
<div class="para ret">
|
||||
<h4>Return Values</h4>
|
||||
<p>Returns a non-zero value if an error has occured; otherwise it returns a zero.</p>
|
||||
<p>Returns a non-zero value if a hard error has occured; otherwise it returns a zero.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
+10
-10
@@ -17,7 +17,7 @@
|
||||
<pre>
|
||||
FRESULT f_fdisk (
|
||||
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Physical drive number */</span>
|
||||
const DWORD <em>part[]</em>, <span class="c">/* [IN] Partition size */</span>
|
||||
const DWORD <span class="arg">part[]</span>, <span class="c">/* [IN] Partition size */</span>
|
||||
void* <span class="arg">work</span> <span class="c">/* [IN] Work area */</span>
|
||||
);
|
||||
</pre>
|
||||
@@ -48,7 +48,7 @@ FRESULT f_fdisk (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_fdisk()</tt> function creates a partition table into the MBR of the physical drive. The partitioning rule is in generic FDISK format so that it can create upto four primary partitions. Extended partition is not supported. The <tt class="arg">part[]</tt> array with four items specifies how to divide the physical drive. The first item specifies the size of first primary partition and fourth item specifies the fourth primary partition. If the value is less than or equal to 100, it means percentage of the partition in the entire disk space. If it is larger than 100, it means partition size in unit of sector.</p>
|
||||
<p>The <tt>f_fdisk()</tt> function creates a partition table into the MBR of the physical drive. The partitioning rule is in generic FDISK format, so that it can create upto four primary partitions. Extended partition is not supported. The <tt class="arg">part[]</tt> array with four items specifies how to divide the physical drive. The first item specifies the size of first primary partition and fourth item specifies the fourth primary partition. If the value is less than or equal to 100, it means percentage of the partition in the entire disk space. If it is larger than 100, it means partition size in unit of sector.</p>
|
||||
</div>
|
||||
|
||||
<div class="para comp">
|
||||
@@ -70,19 +70,19 @@ FRESULT f_fdisk (
|
||||
<pre>
|
||||
<span class="c">/* Initialize a brand-new disk drive mapped to physical drive 0 */</span>
|
||||
|
||||
FATFS Fatfs;
|
||||
FATFS fs;
|
||||
DWORD plist[] = {50, 50, 0, 0}; <span class="c">/* Divide drive into two partitions */</span>
|
||||
BYTE work[_MAX_SS];
|
||||
|
||||
f_fdisk(0, plist, work); <span class="c">/* Divide physical drive 0 */</span>
|
||||
f_fdisk(0, plist, work); <span class="c">/* Divide physical drive 0 */</span>
|
||||
|
||||
f_mount(0, &Fatfs);
|
||||
f_mkfs(0, 0, 0); <span class="c">/* Create an FAT volume on the logical drive 0. 2nd argument is ignored. */</span>
|
||||
f_mount(0, 0);
|
||||
f_mount(&fs, "0:", 0); <span class="c">/* Register work area to the logical drive 0 */</span>
|
||||
f_mkfs("0:", 0, 0); <span class="c">/* Create FAT volume on the logical drive 0. 2nd argument is ignored. */</span>
|
||||
f_mount(0, "0:", 0); <span class="c">/* Unregister work area from the logical drive 0 */</span>
|
||||
|
||||
f_mount(1, &Fatfs);
|
||||
f_mkfs(1, 0, 0);
|
||||
f_mount(1, 0);
|
||||
f_mount(&fs, "1:", 0); <span class="c">/* Give a work area to the logical drive 1 */</span>
|
||||
f_mkfs("1:", 0, 0); <span class="c">/* Create FAT volume on the logical drive 1. 2nd argument is ignored. */</span>
|
||||
f_mount(0, "1:", 0); <span class="c">/* Unregister work area from the logical drive 1 */</span>
|
||||
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
+11
-10
@@ -17,7 +17,7 @@
|
||||
<p>The format of path name on the FatFs module is similer to the filename specs of DOS/Windos as follows:</p>
|
||||
<pre>"[drive#:][/]directory/file"</pre>
|
||||
<p>The FatFs module supports long file name (LFN) and 8.3 format file name (SFN). The LFN can be used when LFN feature is enabled (<tt>_USE_LFN > 0</tt>). The sub directories are separated with a \ or / in the same way as DOS/Windows API. Duplicated separators are skipped and ignored. Only a difference is that the logical drive is specified in a numeral with a colon. When the drive number is omitted, it is assumed as <em>default drive</em> (drive 0 or current drive).</p>
|
||||
<p>Control characters (<tt>'\0'</tt> to <tt>'\x1F'</tt>) are recognized as end of the path name. Leading/embedded spaces in the path name are valid as a part of the name on LFN configuration but they are recognized as end of the path name on non-LFN configuration. Trailing spaces and dots are ignored.</p>
|
||||
<p>Control characters (<tt>'\0'</tt> to <tt>'\x1F'</tt>) are recognized as end of the path name. Leading/embedded spaces in the path name are valid as a part of the name at LFN configuration but they are recognized as end of the path name at non-LFN configuration. Trailing spaces and dots are ignored.</p>
|
||||
<p>In default configuration (<tt>_FS_RPATH == 0</tt>), it does not have a concept of current directory like OS oriented file system. All objects on the volume are always specified in full path name that follows from the root directory. Dot directory names are not allowed. Heading separator is ignored and it can be exist or omitted. The default drive number is fixed to 0.</p>
|
||||
<p>When relative path feature is enabled (<tt>_FS_RPATH == 1</tt>), specified path is followed from the root directory if a heading separator is exist. If not, it is followed from the current directory set with <a href="chdir.html">f_chdir</a> function. Dot names are also allowed for the path name. The default drive is the current drive set with <a href="chdrive.html">f_chdrive</a> function.</p>
|
||||
<table class="lst2">
|
||||
@@ -40,21 +40,22 @@
|
||||
<p><br></p>
|
||||
<div class="para" id="uni">
|
||||
<h3>Unicode API</h3>
|
||||
<p>The path names are input/output in either ANSI/OEM code (SBCS/DBCS) or Unicode depends on the configuration options. The type of arguments that specifies the file names are defined as <tt>TCHAR</tt> which is an alias of <tt>char</tt> in default. The code set of the file name string is the ANSI/OEM code set specifid by <tt>_CODE_PAGE</tt>. When <tt>_LFN_UNICODE</tt> is set to 1, the type of the <tt>TCHAR</tt> is switched to <tt>WCHAR, unsigned short</tt> (UCS-2 character) to support Unicode. In this case, the LFN feature is fully supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name. It also affects data types and encoding of the string I/O functions. To define literal strings, <tt>_T(s)</tt> and <tt>_TEXT(s)</tt> macro are available to select either ANSI/OEM or Unicode automatically. The code shown below is an example to define the literal strings.</p>
|
||||
<p>The path names are input/output in either ANSI/OEM code (SBCS/DBCS) or Unicode depends on the configuration options. The type of arguments which specify the file names are defined as <tt>TCHAR</tt>. It is an alias of <tt>char</tt> in default. The code set used to the file name string is ANSI/OEM specifid by <tt>_CODE_PAGE</tt>. When <tt>_LFN_UNICODE</tt> is set to 1, the type of the <tt>TCHAR</tt> is switched to <tt>WCHAR</tt> to support Unicode (UTF-16 encoding). In this case, the LFN feature is fully supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name. It also affects data types and encoding of the string I/O functions. To define literal strings, <tt>_T(s)</tt> and <tt>_TEXT(s)</tt> macro are available to select either ANSI/OEM or Unicode automatically. The code shown below is an example to define the literal strings.</p>
|
||||
<pre>
|
||||
f_open(fp, "filename.txt", FA_READ); <span class="c">/* ANSI/OEM only */</span>
|
||||
f_open(fp, L"filename.txt", FA_READ); <span class="c">/* Unicode only */</span>
|
||||
f_open(fp, "filename.txt", FA_READ); <span class="c">/* ANSI/OEM string */</span>
|
||||
f_open(fp, L"filename.txt", FA_READ); <span class="c">/* Unicode string */</span>
|
||||
f_open(fp, _T("filename.txt"), FA_READ); <span class="c">/* Changed by configuration */</span>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p><br></p>
|
||||
<div class="para" id="vol">
|
||||
<h3>Correspondence between logical and physical drives</h3>
|
||||
<p>The FatFs module has work areas that called <em>file system object</em> for each volume (logical drive). In default, each logical drive is bound to the physical drive that has same drive number. It attempts to mount a volume as SFD format and first FDISK partition. When <tt>_MULTI_PARTITION >= 1</tt> is specified in configuration option, each individual logical drive is bound to any physical drive/partition. In this case, a volume management table must be defined by user. It is used to resolve relationship between logical drives and partitions as follows:</p>
|
||||
<h3>Volume Management</h3>
|
||||
<p>The FatFs module needs dynamic work area called <em>file system object</em> for each volume (logical drive). It is registered to the FatFs module by <tt>f_mount()</tt> function. By default, each logical drive is bound to the physical drive with the same drive number and an FAT volume on the drive is serched by auto detect feature. It loads boot sectors and checks it if it is an FAT boot sector in order of sector 0 as SFD format, 1st partition, 2nd partition, 3rd partition and 4th partition as FDISK format.</p>
|
||||
<p>When <tt>_MULTI_PARTITION == 1</tt> is specified by configuration option, each individual logical drive is bound to the partition on the physical drive specified by volume management table. The volume management table must be defined by user to resolve relationship between logical drives and partitions. Following code is an example of a volume management table.</p>
|
||||
<pre>
|
||||
Example: Logical drive 0-2 are assigned to three pri-partitions on the physical drive 0 (fixed disk)
|
||||
Logical drive 3 is assigned to physical drive 1 (removable disk)
|
||||
Example: Logical drive 0-2 are tied to three pri-partitions on the physical drive 0 (fixed disk)
|
||||
Logical drive 3 is tied to an FAT volume on the physical drive 1 (removable disk)
|
||||
|
||||
PARTITION VolToPart[] = {
|
||||
{0, 1}, <span class="c">/* Logical drive 0 ==> Physical drive 0, 1st partition */</span>
|
||||
@@ -64,9 +65,9 @@ PARTITION VolToPart[] = {
|
||||
};
|
||||
</pre>
|
||||
<img src="../img/f7.png" width="828" height="288" alt="relationship between logical drive and physical drive">
|
||||
<p>There are some considerations when use <tt>_MULTI_PARTITION</tt> configuration.</p>
|
||||
<p>There are some considerations on using <tt>_MULTI_PARTITION</tt> configuration.</p>
|
||||
<ul>
|
||||
<li>Only four pri-partitions can be mounted. Extended partition is not supported.</li>
|
||||
<li>Only four primary partitions can be specified. Logical partition is not supported.</li>
|
||||
<li>The physical drive that has two or more partitions must be non-removable class.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ FRESULT f_getcwd (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_getcwd()</tt> function retrieves the current directory of the current drive in full path string including drive number.</p>
|
||||
<p>The <tt>f_getcwd()</tt> function retrieves full path name of the current directory of the current drive. When <tt>_VOLUMES</tt> is larger than 1, a logical drive number is added to top of the path name.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
+4
-4
@@ -27,7 +27,7 @@ FRESULT f_getfree (
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>path</dt>
|
||||
<dd>Pinter to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. A null-string means the current drive.</dd>
|
||||
<dd>Pinter to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. A null-string means the default drive.</dd>
|
||||
<dt>nclst</dt>
|
||||
<dd>Pointer to the <tt>DWORD</tt> variable to store number of free clusters.</dd>
|
||||
<dt>fatfs</dt>
|
||||
@@ -53,7 +53,7 @@ FRESULT f_getfree (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Descriptions</h4>
|
||||
<p>The <tt>f_getfree()</tt> function gets number of free clusters on the drive. The member <tt>csize</tt> in the file system object is refrecting number of sectors per cluster, so that the free space in unit of sector can be calcurated with this. When FSInfo structure on FAT32 volume is not in sync, this function can return an incorrect free cluster count.</p>
|
||||
<p>The <tt>f_getfree()</tt> function gets number of free clusters on the volume. The member <tt>csize</tt> in the file system object indicates number of sectors per cluster, so that the free space in unit of sector can be calcurated with this information. When FSINFO structure on the FAT32 volume is not in sync, this function can return an incorrect free cluster count. To avoid this problem, FatFs can be forced full FAT scan by <tt>_FS_NOFSINFO</tt> option.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -78,8 +78,8 @@ FRESULT f_getfree (
|
||||
tot_sect = (fs->n_fatent - 2) * fs->csize;
|
||||
fre_sect = fre_clust * fs->csize;
|
||||
|
||||
<span class="c">/* Print free space in unit of KiB (assuming 512 bytes/sector) */</span>
|
||||
printf("%lu KB total drive space.\n%lu KB available.\n",
|
||||
<span class="c">/* Print the free space (assuming 512 bytes/sector) */</span>
|
||||
printf("%10lu KiB total drive space.\n%10lu KiB available.\n",
|
||||
tot_sect / 2, fre_sect / 2);
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<p>The f_getlabel function returns volume label and volume serial number of a drive.</p>
|
||||
<pre>
|
||||
FRESULT f_getlabel (
|
||||
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Path name */</span>
|
||||
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Drive number */</span>
|
||||
TCHAR* <span class="arg">buff</span>, <span class="c">/* [OUT] Volume label */</span>
|
||||
DWORD* <span class="arg">sn</span> <span class="c">/* [OUT] Volume serial number */</span>
|
||||
);
|
||||
@@ -27,9 +27,9 @@ FRESULT f_getlabel (
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>path</dt>
|
||||
<dd>Pointer to the nul-terminated string specifying the logical drive. Null-string specifies the default drive.</dd>
|
||||
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. Null-string specifies the default drive.</dd>
|
||||
<dt>buff</dt>
|
||||
<dd>Pointer to the buffer to store the volume label. The buffer size must be at least 12 items. If no volume label, a nul-string will be returned. Set null pointer if this information is not needed.</dd>
|
||||
<dd>Pointer to the buffer to store the volume label. The buffer size must be at least 12 items. If the volume has no label, a null-string will be returned. Set null pointer if this information is not needed.</dd>
|
||||
<dt>sn</dt>
|
||||
<dd>Pointer to the <tt>DWORD</tt> variable to store the volume serial number. Set null pointer if this information is not needed.</dd>
|
||||
</dl>
|
||||
|
||||
+2
-2
@@ -44,8 +44,8 @@ TCHAR* f_gets (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_gets()</tt> function is a wrapper function of <a href="read.html">f_read()</a> function. The read operation continues until a <tt>'\n'</tt> is stored, reached end of the file or the buffer is filled with <tt>len - 1</tt> characters. The read string is terminated with a <tt>'\0'</tt>. When no character to read or any error occured during read operation, it returns a null pointer. The status of eof and error can be examined with <tt>f_eof()</tt> and <tt>f_error()</tt> macros.</p>
|
||||
<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the file is read in assumption of UTF-8 encoding and stored it to the buffer in UCS-2. If not the case, the file will be read in one byte per character without any code conversion.</p>
|
||||
<p>The <tt>f_gets()</tt> function is a wrapper function of <a href="read.html"><tt>f_read()</tt></a> function. The read operation continues until a <tt>'\n'</tt> is stored, reached end of the file or the buffer is filled with <tt>len - 1</tt> characters. The read string is terminated with a <tt>'\0'</tt>. When no character to read or any error occured during read operation, it returns a null pointer. The status of EOF and error can be examined with <tt>f_eof()</tt> and <tt>f_error()</tt> macros.</p>
|
||||
<p>When FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), data types on the srting fuctions, <tt>f_putc()</tt>, <tt>f_puts()</tt>, <tt>f_printf()</tt> and <tt>f_gets()</tt>, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by <tt>_STRF_ENCODE</tt> option.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
+11
-11
@@ -13,7 +13,7 @@
|
||||
|
||||
<div class="para func">
|
||||
<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 increase 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 expand the file size (cluster pre-allocation). </p>
|
||||
|
||||
<pre>
|
||||
FRESULT f_lseek (
|
||||
@@ -49,13 +49,13 @@ FRESULT f_lseek (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<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 above the file size is specified in write mode, the file size is increased to the offset and the data in the expanded area is undefined. This is suitable to create a large file quickly, for fast write operation. 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 was moved correctry. In case of the current read/write pointer is not the expected value, either of followings has been occured.</p>
|
||||
<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 in 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 <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 current read/write pointer is not the expected value, either of followings has been occured.</p>
|
||||
<ul>
|
||||
<li>End of file. The specified <tt class="arg">ofs</tt> was clipped at end of the file because the file is in read-only mode.</li>
|
||||
<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>
|
||||
<li>Disk full. There is insufficient free space on the volume to expand the file.</li>
|
||||
</ul>
|
||||
<p>Fast seek feature is enabled when <tt>_USE_FASTSEEK</tt> is set to 1 and the member <tt>cltbl</tt> in the file object is not NULL. This feature enables fast backward/long seek operations without FAT access by using cluster link map table (CLMT). It is also applied to <tt>f_read()/f_write()</tt> functions. In this mode, the file cannot be expanded by <tt>f_write()/f_lseek()</tt> functions.</p>
|
||||
<p>The CLMT must be created in the user defined <tt>DWORD</tt> array prior to use fast seek feature. To create the CLMT, set pointer to the <tt>DWORD</tt> array to the member <tt>cltbl</tt> in the file object, set the array size in unit of items into 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()/f_write()/f_lseek()</tt> functions to the file. If the function failed with <tt>FR_NOT_ENOUGH_CORE</tt>, 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.</p>
|
||||
<p>Fast seek feature is enabled when <tt>_USE_FASTSEEK</tt> is set to 1 and the member <tt>cltbl</tt> in the file object is not NULL. This feature enables fast backward/long seek operations without FAT access by using cluster link map table (CLMT). It is also applied to <tt>f_read()/f_write()</tt> function. In this mode, the file cannot be expanded by <tt>f_write()/f_lseek()</tt> function.</p>
|
||||
<p>The CLMT must be created in the user defined <tt>DWORD</tt> array prior to use the fast seek feature. To create the CLMT, set address of the <tt>DWORD</tt> array to the member <tt>cltbl</tt> in the file object, set the array size in unit of items into 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()/f_write()/f_lseek()</tt> function to the file. If the function failed with <tt>FR_NOT_ENOUGH_CORE</tt>, 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.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -82,11 +82,11 @@ FRESULT f_lseek (
|
||||
<span class="c">/* Forward 3000 bytes */</span>
|
||||
res = f_lseek(fp, f_tell(fp) + 3000);
|
||||
|
||||
<span class="c">/* Rewind 2000 bytes (take care on overflow) */</span>
|
||||
<span class="c">/* Rewind 2000 bytes (take care on wraparound) */</span>
|
||||
res = f_lseek(fp, f_tell(fp) - 2000);
|
||||
</pre>
|
||||
<pre>
|
||||
<span class="c">/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */</span>
|
||||
<span class="c">/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */</span>
|
||||
|
||||
res = f_open(fp, recfile, FA_CREATE_NEW | FA_WRITE); <span class="c">/* Create a file */</span>
|
||||
|
||||
@@ -103,14 +103,14 @@ FRESULT f_lseek (
|
||||
res = f_close(fp);
|
||||
</pre>
|
||||
<pre>
|
||||
<span class="c">/* Using fast seek feature */</span>
|
||||
<span class="c">/* Using fast seek feature */</span>
|
||||
|
||||
DWORD lktbl[SZ_TBL]; <span class="c">/* Link map table buffer */</span>
|
||||
DWORD clmt[SZ_TBL]; <span class="c">/* Cluster link map table buffer */</span>
|
||||
|
||||
res = f_lseek(fp, ofs1); <span class="c">/* This is normal seek (cltbl member is nulled on file open) */</span>
|
||||
|
||||
fp->cltbl = lktbl; <span class="c">/* Enable fast seek feature (cltbl != NULL) */</span>
|
||||
lktbl[0] = SZ_TBL; <span class="c">/* Set table size */</span>
|
||||
fp->cltbl = clmt; <span class="c">/* Enable fast seek feature */</span>
|
||||
clmt[0] = SZ_TBL; <span class="c">/* Set table size */</span>
|
||||
res = f_lseek(fp, CREATE_LINKMAP); <span class="c">/* Create CLMT */</span>
|
||||
...
|
||||
|
||||
|
||||
+9
-9
@@ -16,9 +16,9 @@
|
||||
<p>The f_mkfs fucntion creates an FAT file system on the logical drive.</p>
|
||||
<pre>
|
||||
FRESULT f_mkfs (
|
||||
BYTE <span class="arg">vol</span>, <span class="c">/* [IN] Logical drive number */</span>
|
||||
BYTE <span class="arg">sfd</span>, <span class="c">/* [IN] Partitioning rule */</span>
|
||||
UINT <span class="arg">au</span> <span class="c">/* [IN] Size of the allocation unit */</span>
|
||||
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Logical drive number */</span>
|
||||
BYTE <span class="arg">sfd</span>, <span class="c">/* [IN] Partitioning rule */</span>
|
||||
UINT <span class="arg">au</span> <span class="c">/* [IN] Size of the allocation unit */</span>
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
@@ -26,12 +26,12 @@ FRESULT f_mkfs (
|
||||
<div class="para arg">
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>vol</dt>
|
||||
<dd>Logical drive number to be formatted. (0 to <tt>_VOLUMES - 1</tt>)</dd>
|
||||
<dt>path</dt>
|
||||
<dd>Pinter to the null-terminated string that specifies the <a href="filename.html">logical drive</a> to be formatted. If there is no drive number, it means the default drive.</dd>
|
||||
<dt>sfd</dt>
|
||||
<dd>Specifies partitioning rule (FDISK(0) or SFD(1)). This argument is ignored on some case.</dd>
|
||||
<dd>Specifies partitioning rule (FDISK(0) or SFD(1)). This argument will be ignored on some case.</dd>
|
||||
<dt>au</dt>
|
||||
<dd>Force the size of allocation unit (cluter) in unit of byte. The value must be sector size * n (n = 1 to 128 and power of 2). When a zero is given, the cluster size is determined depends on the volume size.</dd>
|
||||
<dd>Specifies size of the allocation unit (cluter) in unit of byte. The value must be sector size * n (n is 1 to 128 and power of 2). When a zero is given, the cluster size is determined depends on the volume size.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@@ -52,8 +52,8 @@ FRESULT f_mkfs (
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_mkfs()</tt> function creates an FAT volume on the logical drive. When FDISK format is specified, a primary partition occupies the entire disk space is created and then an FAT volume is created on the partition. When SFD format is specified, the FAT volume starts from the first sector of the physical drive.</p>
|
||||
<p>If the logical drive is being bound to any partition (1-4) by multiple partition feature (<tt>_MULTI_PARTITION</tt>), the FAT volume is created into the specified partition. In this case, the second argument <tt class="arg">sfd</tt> is ignored. The physical drive must have been partitioned with f_fdisk function or any other partitioning tool prior to use this function.</p>
|
||||
<p>Note that there are two partitioning rules, FDISK and SFD. The FDISK partitioning is usually used for harddisk, MMC, SDC and CFC. It can divide a physical drive into one or more partitions with a partition table on the MBR. However Windows does not support multiple partition on the removable media. The SFD is non-partitioned method. The FAT volume starts from the first sector on the physical drive without partition table. It is used for floppy disk, Microdrive, optical disk and super-floppy media.</p>
|
||||
<p>If the logical drive has been bound to any partition (1-4) by multiple partition feature (<tt>_MULTI_PARTITION</tt>), the FAT volume is created into the specified partition. In this case, the second argument <tt class="arg">sfd</tt> is ignored. The physical drive must have been partitioned with <tt>f_fdisk()</tt> function or any other partitioning tool prior to use this function.</p>
|
||||
<p>Note that there are two partitioning rules, FDISK and SFD. The FDISK partitioning is usually used for harddisk, MMC, SDC, CFC and U Disk. It can divide a physical drive into one or more partitions with a partition table on the MBR. However Windows does not support multiple partition on the removable media. The SFD is non-partitioned method. The FAT volume starts from the first sector on the physical drive without partition table. It is usually used for floppy disk, Microdrive, optical disk and super-floppy media.</p>
|
||||
<p>The FAT sub-type, FAT12/FAT16/FAT32, is determined by number of clusters on the volume and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the volume size and the specified cluster size. The cluster size affects performance of the file system and large cluster increases the performance.</p>
|
||||
<p>When the number of clusters gets near the FAT sub-type boundaries, the function can fail with <tt>FR_MKFS_ABORTED</tt>.</p>
|
||||
</div>
|
||||
|
||||
+25
-11
@@ -16,8 +16,9 @@
|
||||
<p>The f_mount fucntion registers/unregisters file system object (work area) to the FatFs module.</p>
|
||||
<pre>
|
||||
FRESULT f_mount (
|
||||
BYTE <span class="arg">vol</span>, <span class="c">/* [IN] Logical drive number */</span>
|
||||
FATFS* <span class="arg">fatfs</span> <span class="c">/* [IN] File system object */</span>
|
||||
FATFS* <span class="arg">fatfs</span>, <span class="c">/* [IN] File system object */</span>
|
||||
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Logical drive number */</span>
|
||||
BYTE <span class="arg">opt</span> <span class="c">/* [IN] Initialization option */</span>
|
||||
);
|
||||
</pre>
|
||||
</div>
|
||||
@@ -25,10 +26,12 @@ FRESULT f_mount (
|
||||
<div class="para arg">
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>vol</dt>
|
||||
<dd>Logical drive number to register/unregister file system object. (0 to <tt>_VOLUMES - 1</tt>)</dd>
|
||||
<dt>fatfs</dt>
|
||||
<dd>Pointer to the file system object to be registered. Null pointer unregisters the registered file system object.</dd>
|
||||
<dt>path</dt>
|
||||
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. If there is no drive number, it means the default drive.</dd>
|
||||
<dt>opt</dt>
|
||||
<dd>Initialization option. 0: Do not mount now (to be mounted later), 1: Force mounted the volume to check if the volume is available.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@@ -36,20 +39,31 @@ FRESULT f_mount (
|
||||
<h4>Return Values</h4>
|
||||
<p>
|
||||
<a href="rc.html#ok">FR_OK</a>,
|
||||
<a href="rc.html#id">FR_INVALID_DRIVE</a>
|
||||
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
|
||||
<a href="rc.html#de">FR_DISK_ERR</a>,
|
||||
<a href="rc.html#nr">FR_NOT_READY</a>,
|
||||
<a href="rc.html#ns">FR_NO_FILESYSTEM</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_mount()</tt> function registers/unregisters a file system object to the FatFs module. The file system object is the work area needed for each logical drive. It must be given to the logical drive with this function prior to use any other file functions. To unregister a work area, specify a NULL to the <tt class="arg">fatfs</tt>, and then the work area can be discarded.</p>
|
||||
<p>This function always succeeds regardless of the physical drive status. No media access is occured in this function. It only de-initializes the given work area and registers its address to the internal table. It can also be used to force de-initialized the registered work area of a logical drive. The volume mount process, initialize the corresponding physical drive, find the FAT volume in it and initialize the work area, is performed when either or both of following condition is true:</p>
|
||||
<p>The <tt>f_mount()</tt> function registers/unregisters a file system object used for the logical drive to the FatFs module as follows:</p>
|
||||
<ol>
|
||||
<li>Determines the logical drive which specified by <tt class="arg">path</tt>.</li>
|
||||
<li>Clears and unregisters the regsitered work area of the drive.</li>
|
||||
<li>Clears and registers the work area to the drive if <tt class="arg">fatfs</tt> is not NULL.</li>
|
||||
<li>Performs volume mount process to the drive if forced mount is specified.</li>
|
||||
</ol>
|
||||
<p>The file system object is the work area needed for each logical drive. It must be given to the logical drive with this function prior to use any other file functions. To unregister a work area, specify a NULL to the <tt class="arg">fatfs</tt>, and then the work area can be discarded. </p>
|
||||
<p>If forced mount is not specified, this function always succeeds regardless of the physical drive status due to delayed mount feature. It only clears (de-initializes) the given work area and registers its address to the internal table. No activity of the physical drive in this function. It can also be used to force de-initialized the registered work area of a logical drive. The volume mount processes, initialize the corresponding physical drive, find the FAT volume in it and initialize the work area, is performed in the subsequent file access functions when either or both of following condition is true.</p>
|
||||
<ul>
|
||||
<li>File system object is not initialized. (by <tt>f_mount()</tt>)</li>
|
||||
<li>Physical drive is not initialized. (by system reset or media removal)</li>
|
||||
<li>File system object is not initialized. It is cleared by <tt>f_mount()</tt>.</li>
|
||||
<li>Physical drive is not initialized. It is de-initialized by system reset or media removal.</li>
|
||||
</ul>
|
||||
<p>If the disk I/O layer does not detect media change, application program needs to perform <tt>f_mount()</tt> every media change.</p>
|
||||
<p>If the function with forced mount failed, it means that the file system object is registered but the volume is currently not available. Mount process will also be attempted in subsequent file access functions.</p>
|
||||
<p>If implementation of the disk I/O layer lacks media change detection, application program needs to perform a <tt>f_mount()</tt> after media change to force cleared the file system object.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -61,7 +75,7 @@ FRESULT f_mount (
|
||||
|
||||
<div class="para ref">
|
||||
<h4>See Also</h4>
|
||||
<p><tt><a href="sfatfs.html">FATFS</a></tt></p>
|
||||
<p><tt><a href="open.html">f_open</a></tt>, <tt><a href="sfatfs.html">FATFS</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
||||
+53
-20
@@ -16,7 +16,7 @@
|
||||
<p>The f_open function creates a <em>file object</em> to be used to access the file.</p>
|
||||
<pre>
|
||||
FRESULT f_open (
|
||||
FIL* <span class="arg">fp</span>, <span class="c">/* [OUT] File object structure */</span>
|
||||
FIL* <span class="arg">fp</span>, <span class="c">/* [OUT] Pointer to the file object structure */</span>
|
||||
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] File name */</span>
|
||||
BYTE <span class="arg">mode</span> <span class="c">/* [IN] Mode flags */</span>
|
||||
);
|
||||
@@ -27,7 +27,7 @@ FRESULT f_open (
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>fp</dt>
|
||||
<dd>Pointer to the file object structure to be created.</dd>
|
||||
<dd>Pointer to the blank file object structure to be created.</dd>
|
||||
<dt>path</dt>
|
||||
<dd>Pointer to a null-terminated string that specifies the <a href="filename.html">file name</a> to create or open.</dd>
|
||||
<dt>mode</dt>
|
||||
@@ -87,35 +87,66 @@ To append data to the file, use <a href="lseek.html"><tt>f_lseek()</tt></a> func
|
||||
|
||||
|
||||
<div class="para use">
|
||||
<h4>Example (File Copy)</h4>
|
||||
<h4>Example</h4>
|
||||
<pre>
|
||||
void main (void)
|
||||
<span class="c">/* Read a text file and display it */</span>
|
||||
|
||||
FATFS FatFs; <span class="c">/* Work area (file system object) for logical drive */</span>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
FIL fil; <span class="c">/* File object */</span>
|
||||
char line[82]; <span class="c">/* Line buffer */</span>
|
||||
FRESULT fr; <span class="c">/* FatFs return code */</span>
|
||||
|
||||
|
||||
<span class="c">/* Register work area to the default drive */</span>
|
||||
f_mount(&FatFs, "", 0);
|
||||
|
||||
<span class="c">/* Open a text file */</span>
|
||||
fr = f_open(&fil, "message.txt", FA_READ);
|
||||
if (fr) return (int)fr;
|
||||
|
||||
<span class="c">/* Read all lines and display it */</span>
|
||||
while (f_gets(line, sizeof line, &fil))
|
||||
printf(line);
|
||||
|
||||
<span class="c">/* Close the file */</span>
|
||||
f_close(&fil);
|
||||
|
||||
return 0;
|
||||
}
|
||||
</pre>
|
||||
<pre>
|
||||
<span class="c">/* Copy a file "file.bin" on the drive 1 to drive 0 */</span>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
FATFS fs[2]; <span class="c">/* Work area (file system object) for logical drives */</span>
|
||||
FIL fsrc, fdst; <span class="c">/* file objects */</span>
|
||||
BYTE buffer[4096]; <span class="c">/* file copy buffer */</span>
|
||||
FRESULT res; <span class="c">/* FatFs function common result code */</span>
|
||||
FIL fsrc, fdst; <span class="c">/* File objects */</span>
|
||||
BYTE buffer[4096]; <span class="c">/* File copy buffer */</span>
|
||||
FRESULT fr; <span class="c">/* FatFs function common result code */</span>
|
||||
UINT br, bw; <span class="c">/* File read/write count */</span>
|
||||
|
||||
|
||||
<span class="c">/* Register work area for each volume (Always succeeds regardless of disk status) */</span>
|
||||
f_mount(0, &fs[0]);
|
||||
f_mount(1, &fs[1]);
|
||||
<span class="c">/* Register work area for each logical drive */</span>
|
||||
f_mount(&fs[0], "0:", 0);
|
||||
f_mount(&fs[1], "1:", 0);
|
||||
|
||||
<span class="c">/* Open source file on the drive 1 */</span>
|
||||
res = f_open(&fsrc, "1:srcfile.dat", FA_OPEN_EXISTING | FA_READ);
|
||||
if (res) die(res);
|
||||
fr = f_open(&fsrc, "1:file.bin", FA_OPEN_EXISTING | FA_READ);
|
||||
if (fr) return (int)fr;
|
||||
|
||||
<span class="c">/* Create destination file on the drive 0 */</span>
|
||||
res = f_open(&fdst, "0:dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE);
|
||||
if (res) die(res);
|
||||
fr = f_open(&fdst, "0:file.bin", FA_CREATE_ALWAYS | FA_WRITE);
|
||||
if (fr) return (int)fr;
|
||||
|
||||
<span class="c">/* Copy source to destination */</span>
|
||||
for (;;) {
|
||||
res = f_read(&fsrc, buffer, sizeof buffer, &br); <span class="c">/* Read a chunk of src file */</span>
|
||||
if (res || br == 0) break; <span class="c">/* error or eof */</span>
|
||||
res = f_write(&fdst, buffer, br, &bw); <span class="c">/* Write it to the dst file */</span>
|
||||
if (res || bw < br) break; <span class="c">/* error or disk full */</span>
|
||||
fr = f_read(&fsrc, buffer, sizeof buffer, &br); <span class="c">/* Read a chunk of source file */</span>
|
||||
if (fr || br == 0) break; <span class="c">/* error or eof */</span>
|
||||
fr = f_write(&fdst, buffer, br, &bw); <span class="c">/* Write it to the destination file */</span>
|
||||
if (fr || bw < br) break; <span class="c">/* error or disk full */</span>
|
||||
}
|
||||
|
||||
<span class="c">/* Close open files */</span>
|
||||
@@ -123,8 +154,10 @@ void main (void)
|
||||
f_close(&fdst);
|
||||
|
||||
<span class="c">/* Unregister work area prior to discard it */</span>
|
||||
f_mount(0, NULL);
|
||||
f_mount(1, NULL);
|
||||
f_mount(NULL, "0:", 0);
|
||||
f_mount(NULL, "1:", 0);
|
||||
|
||||
return (int)fr;
|
||||
}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
+5
-4
@@ -16,7 +16,7 @@
|
||||
<p>The f_opendir function opens a directory.</p>
|
||||
<pre>
|
||||
FRESULT f_opendir (
|
||||
DIR* <span class="arg">dj</span>, <span class="c">/* [OUT] Blank directory object */</span>
|
||||
DIR* <span class="arg">dp</span>, <span class="c">/* [OUT] Pointer to the directory object structure */</span>
|
||||
const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] Directory name */</span>
|
||||
);
|
||||
</pre>
|
||||
@@ -25,7 +25,7 @@ FRESULT f_opendir (
|
||||
<div class="para arg">
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>dj</dt>
|
||||
<dt>dp</dt>
|
||||
<dd>Pointer to the blank directory object to be created.</dd>
|
||||
<dt>path</dt>
|
||||
<dd>Pinter to the null-terminated string that specifies the <a href="filename.html">directory name</a> to be opened.</dd>
|
||||
@@ -42,6 +42,7 @@ FRESULT f_opendir (
|
||||
<a href="rc.html#nr">FR_NOT_READY</a>,
|
||||
<a href="rc.html#np">FR_NO_PATH</a>,
|
||||
<a href="rc.html#in">FR_INVALID_NAME</a>,
|
||||
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
|
||||
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
|
||||
<a href="rc.html#ne">FR_NOT_ENABLED</a>,
|
||||
<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
|
||||
@@ -53,7 +54,7 @@ FRESULT f_opendir (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_opendir()</tt> function opens an exsisting directory and creates the directory object for subsequent calls. The directory object structure can be discarded at any time without any procedure.</p>
|
||||
<p>The <tt>f_opendir()</tt> function opens an exsisting directory and creates the directory object for subsequent calls.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -65,7 +66,7 @@ FRESULT f_opendir (
|
||||
|
||||
<div class="para ref">
|
||||
<h4>See Also</h4>
|
||||
<p><tt><a href="readdir.html">f_readdir</a>, <a href="sdir.html">DIR</a></tt></p>
|
||||
<p><tt><a href="readdir.html">f_readdir</a>, <a href="closedir.html">f_closedir</a>, <a href="sdir.html">DIR</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
||||
+7
-7
@@ -39,13 +39,13 @@ int f_printf (
|
||||
|
||||
<div class="para ret">
|
||||
<h4>Return Values</h4>
|
||||
<p>When the function succeeded, number of characters written is returned. When the function failed due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
|
||||
<p>When the function succeeded, it returns number of characters written. When the function failed due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_printf()</tt> is a wrapper function of <a href="putc.html"><tt>f_putc()</tt></a> and <a href="puts.html"><tt>f_puts()</tt></a>. The format control directive is a sub-set of standard library shown as follos:</p>
|
||||
<p>The <tt>f_printf()</tt> is a wrapper function of <a href="write.html"><tt>f_write()</tt></a>. The format control directive is a sub-set of standard library shown as follos:</p>
|
||||
<ul>
|
||||
<li>Type: <tt>c C s S d D u U x X b B</tt></li>
|
||||
<li>Size: <tt>l L</tt></li>
|
||||
@@ -57,7 +57,7 @@ int f_printf (
|
||||
<div class="para comp">
|
||||
<h4>QuickInfo</h4>
|
||||
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\n'</tt>s contained in the output are converted to <tt>"\r\n"</tt>.</p>
|
||||
<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the generated UCS-2 string is written to the file in UTF-8 encoding. If not the case, the byte characters will be written directly.</p>
|
||||
<p>When FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), data types on the srting fuctions, <tt>f_putc()</tt>, <tt>f_puts()</tt>, <tt>f_printf()</tt> and <tt>f_gets()</tt>, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by <tt>_STRF_ENCODE</tt> option.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -68,12 +68,12 @@ int f_printf (
|
||||
f_printf(&fil, "%6d,%3d%%", -200, 5); <span class="c">/* " -200, 5%" */</span>
|
||||
f_printf(&fil, "%-6u", 100); <span class="c">/* "100 " */</span>
|
||||
f_printf(&fil, "%ld", 12345678L); <span class="c">/* "12345678" */</span>
|
||||
f_printf(&fil, "%04x", 0xA3); <span class="c">/* "00a3" */</span>
|
||||
f_printf(&fil, "%08LX", 0x123ABC); <span class="c">/* "00123ABC" */</span>
|
||||
f_printf(&fil, "%04x", 0xAB); <span class="c">/* "00ab" */</span>
|
||||
f_printf(&fil, "%08LX", 0x123ABCL); <span class="c">/* "00123ABC" */</span>
|
||||
f_printf(&fil, "%016b", 0x550F); <span class="c">/* "0101010100001111" */</span>
|
||||
f_printf(&fil, "%s", "String"); <span class="c">/* "String" */</span>
|
||||
f_printf(&fil, "%-4s", "abc"); <span class="c">/* "abc " */</span>
|
||||
f_printf(&fil, "%4s", "abc"); <span class="c">/* " abc" */</span>
|
||||
f_printf(&fil, "%5s", "abc"); <span class="c">/* " abc" */</span>
|
||||
f_printf(&fil, "%-5s", "abc"); <span class="c">/* "abc " */</span>
|
||||
f_printf(&fil, "%c", 'a'); <span class="c">/* "a" */</span>
|
||||
f_printf(&fil, "%f", 10.0); <span class="c">/* f_printf lacks floating point support */</span>
|
||||
</pre>
|
||||
|
||||
+2
-2
@@ -35,8 +35,8 @@ int f_putc (
|
||||
|
||||
<div class="para ret">
|
||||
<h4>Return Values</h4>
|
||||
<p>When the character was written successfuly, the function returns 1. When the function failed due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
|
||||
<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the UCS-2 character is written to the file in UTF-8 encoding. If not the case, the byte will be written directly.</p>
|
||||
<p>When the character was written successfuly, it returns number of characters written. When the function failed due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
|
||||
<p>When FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), character encoding on the string fuctions, <tt>f_putc()</tt>, <tt>f_puts()</tt>, <tt>f_printf()</tt> and <tt>f_gets()</tt>, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by <tt>_STRF_ENCODE</tt> option.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -35,14 +35,14 @@ int f_puts (
|
||||
|
||||
<div class="para ret">
|
||||
<h4>Return Value</h4>
|
||||
<p>When the function succeeded, number of characters written that is not minus value is returned. When the write operation is aborted due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
|
||||
<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the UCS-2 string is written to the file in UTF-8 encoding. If not the case, the byte stream will be written directly.</p>
|
||||
<p>When the function succeeded, it returns number of characters written. When the write operation is aborted due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
|
||||
<p>When FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), character encoding on the srting fuctions, <tt>f_putc()</tt>, <tt>f_puts()</tt>, <tt>f_printf()</tt> and <tt>f_gets()</tt>, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by <tt>_STRF_ENCODE</tt> option.</p>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_puts()</tt> function is a wrapper function of <a href="putc.html"><tt>f_putc()</tt></a> function.</p>
|
||||
<p>The <tt>f_puts()</tt> function is a wrapper function of <a href="write.html"><tt>f_write()</tt></a> function.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@
|
||||
<dt id="wp">FR_WRITE_PROTECTED</dt>
|
||||
<dd>Any write mode action against the write-protected media.</dd>
|
||||
<dt id="id">FR_INVALID_DRIVE</dt>
|
||||
<dd>Invalid drive number is specified. (Related option: <tt>_VOLUMES</tt>)</dd>
|
||||
<dd>Invalid drive number is specified in the path name. (Related option: <tt>_VOLUMES</tt>)</dd>
|
||||
<dt id="ne">FR_NOT_ENABLED</dt>
|
||||
<dd>Work area for the logical drive has not been registered by <tt>f_mount()</tt> function.</dd>
|
||||
<dt id="ns">FR_NO_FILESYSTEM</dt>
|
||||
|
||||
+12
-6
@@ -16,7 +16,7 @@
|
||||
<p>The f_readdir function reads directory entries.</p>
|
||||
<pre>
|
||||
FRESULT f_readdir (
|
||||
DIR* <span class="arg">dj</span>, <span class="c">/* [IN] Directory object */</span>
|
||||
DIR* <span class="arg">dp</span>, <span class="c">/* [IN] Directory object */</span>
|
||||
FILINFO* <span class="arg">fno</span> <span class="c">/* [OUT] File information structure */</span>
|
||||
);
|
||||
</pre>
|
||||
@@ -25,7 +25,7 @@ FRESULT f_readdir (
|
||||
<div class="para arg">
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>dj</dt>
|
||||
<dt>dp</dt>
|
||||
<dd>Pointer to the open directory object.</dd>
|
||||
<dt>fno</dt>
|
||||
<dd>Pointer to the file information structure to store the read item.</dd>
|
||||
@@ -49,9 +49,14 @@ FRESULT f_readdir (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_readdir()</tt> function reads directory items, file and directory, in sequence. All items in the directory can be read by calling <tt>f_readdir()</tt> function repeatedly. When all directory items have been read and no item to read, the function returns a null string into <tt>fname[]</tt> member without any error. When a null pointer is given to the <tt class="arg">fno</tt>, the read index of the directory object will be rewinded.</p>
|
||||
<p>When LFN feature is enabled, <tt>lfname</tt> and <tt>lfsize</tt> in the file information structure must be initialized with valid value prior to use it. The <tt>lfname</tt> is a pointer to the string buffer to return the long file name. The <tt>lfsize</tt> is the size of the string buffer in unit of <tt>TCHAR</tt>. If either the size of read buffer or LFN working buffer is insufficient for the LFN or the object has no LFN, a null string will be returned to the LFN read buffer. If the LFN contains any charactrer that cannot be converted to OEM code, a null string will be returned but this is not the case on Unicode API configuration. When <tt>lfname</tt> is a null, nothing of the LFN is returned. When the object has no LFN, some small capitals can be contained in the SFN in the <tt>fname[]</tt>.</p>
|
||||
<p>When relative path feature is enabled (<tt>_FS_RPATH == 1</tt>), dot entries ("." and "..") are not filtered out and they will appear in the read items.</p>
|
||||
<p>The <tt>f_readdir()</tt> function reads directory items, file and directory, in sequence. All items in the directory can be read by calling <tt>f_readdir()</tt> function repeatedly. When relative path feature is enabled (<tt>_FS_RPATH >= 1</tt>), dot entries ("." and "..") are not filtered out and they will appear in the read items. When all directory items have been read and no item to read, a null string is returned into the <tt>fname[]</tt> without any error. When a null pointer is given to the <tt class="arg">fno</tt>, the read index of the directory object is rewinded.</p>
|
||||
<p>When LFN feature is enabled, <tt>lfname</tt> and <tt>lfsize</tt> in the file information structure must be initialized with valid value prior to use it. The <tt>lfname</tt> is a pointer to the LFN read buffer. The <tt>lfsize</tt> is size of the LFN read buffer in unit of <tt>TCHAR</tt>. If the LFN is not needed, set a null pointer to the <tt>lfname</tt> and the LFN is not returned. A null string will be returned into the LFN read buffer in case of following conditions.</p>
|
||||
<ul>
|
||||
<li>The directory item has no LFN information.</li>
|
||||
<li>Either the size of read buffer or LFN working buffer is insufficient for the LFN.</li>
|
||||
<li>The LFN contains Unicode charactrer that cannot be converted to OEM code. (not the case on Unicode API)</li>
|
||||
</ul>
|
||||
<p>When the directory item has no LFN information, lower case characters can be contained in the <tt>fname[]</tt>.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -101,6 +106,7 @@ FRESULT scan_files (
|
||||
printf("%s/%s\n", path, fn);
|
||||
}
|
||||
}
|
||||
f_closedir(&dir)
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -111,7 +117,7 @@ FRESULT scan_files (
|
||||
|
||||
<div class="para ref">
|
||||
<h4>See Also</h4>
|
||||
<p><tt><a href="opendir.html">f_opendir</a>, <a href="stat.html">f_stat</a>, <a href="sfileinfo.html">FILINFO</a>, <a href="sdir.html">DIR</a></tt></p>
|
||||
<p><tt><a href="opendir.html">f_opendir</a>, <a href="closedir.html">f_closedir</a>, <a href="stat.html">f_stat</a>, <a href="sfileinfo.html">FILINFO</a>, <a href="sdir.html">DIR</a></tt></p>
|
||||
</div>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
||||
+4
-4
@@ -13,7 +13,7 @@
|
||||
|
||||
<div class="para func">
|
||||
<h2>f_rename</h2>
|
||||
<p>Renames an object.</p>
|
||||
<p>Renames a file or sub-directory.</p>
|
||||
<pre>
|
||||
FRESULT f_rename (
|
||||
const TCHAR* <span class="arg">old_name</span>, <span class="c">/* [IN] Old object name */</span>
|
||||
@@ -26,9 +26,9 @@ FRESULT f_rename (
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>old_name</dt>
|
||||
<dd>Pointer to a null-terminated string specifies the old <a href="filename.html">object name</a> to be renamed.</dd>
|
||||
<dd>Pointer to a null-terminated string that specifies the old <a href="filename.html">object name</a> to be renamed.</dd>
|
||||
<dt>new_name</dt>
|
||||
<dd>Pointer to a null-terminated string specifies the new object name without drive number.</dd>
|
||||
<dd>Pointer to a null-terminated string tha specifies the new object name without drive number.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@@ -58,7 +58,7 @@ FRESULT f_rename (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>Renames an object (file or directory) and can also move it to other directory. The logical drive number is determined by old name, new name must not contain a logical drive number. <em>Do not rename open objects</em> or directry table can be collapted.</p>
|
||||
<p>Renames a file or sub-directory and can also move it to other directory. The logical drive number is determined by old name, new name must not contain a logical drive number. <em>Do not rename open objects</em> or directry table can be collapted.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
+5
-2
@@ -19,14 +19,17 @@
|
||||
FATFS* fs; <span class="c">/* Pointer to the owner file system object */</span>
|
||||
WORD id; <span class="c">/* Owner file system mount ID */</span>
|
||||
WORD index; <span class="c">/* Index of directory entry to start to search next */</span>
|
||||
DWORD sclust; <span class="c">/* Table start cluster (0:Root dir) */</span>
|
||||
DWORD sclust; <span class="c">/* Table start cluster (0:Root directory) */</span>
|
||||
DWORD clust; <span class="c">/* Current cluster */</span>
|
||||
DWORD sect; <span class="c">/* Current sector */</span>
|
||||
BYTE* dir; <span class="c">/* Pointer to the current SFN entry in the win[] */</span>
|
||||
BYTE* fn; <span class="c">/* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */</span>
|
||||
<span class="k">#if</span> _FS_LOCK
|
||||
UINT lockid; <span class="c">/* Sub-directory lock ID (0:Root directory) */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if</span> _USE_LFN
|
||||
WCHAR* lfn; <span class="c">/* Pointer to the LFN working buffer */</span>
|
||||
WORD lfn_idx; <span class="c">/* Index of last matched LFN entry (0xFFFF:No LFN) */</span>
|
||||
WORD lfn_idx; <span class="c">/* Index of top of last matched LFN entris (0xFFFF:No LFN) */</span>
|
||||
<span class="k">#endif</span>
|
||||
} DIR;
|
||||
</pre>
|
||||
|
||||
@@ -25,7 +25,7 @@ FRESULT f_setlabel (
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>name</dt>
|
||||
<dd>Pointer to the nul-terminated string specifying the volume label to be set.</dd>
|
||||
<dd>Pointer to the null-terminated string that specifies the volume label to be set.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@@ -49,7 +49,7 @@ FRESULT f_setlabel (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>When the string has a drive number, the volume label will be set to the volume specified by the drive number. If the volume label is a null-string, the volume label on the volume will be removed. The format of the volume label is similar to the SFN but there are some difference shown below:</p>
|
||||
<p>When the string has a drive number, the volume label will be set to the volume specified by the drive number. If the volume label is a null-string, the volume label on the volume will be removed. The format of the volume label is similar to the SFN but there are some differences shown below:</p>
|
||||
<ul>
|
||||
<li>11 bytes or less in length as local character code.</li>
|
||||
<li>Cannot contain period.</li>
|
||||
|
||||
+7
-8
@@ -18,10 +18,10 @@
|
||||
<span class="k">typedef</span> <span class="k">struct</span> {
|
||||
BYTE fs_type; <span class="c">/* FAT sub-type (0:Not mounted) */</span>
|
||||
BYTE drv; <span class="c">/* Physical drive number */</span>
|
||||
BYTE csize; <span class="c">/* Sectors per cluster (1,2,4...128) */</span>
|
||||
BYTE csize; <span class="c">/* Sectors per cluster (1,2,4,...,128) */</span>
|
||||
BYTE n_fats; <span class="c">/* Number of FAT copies (1,2) */</span>
|
||||
BYTE wflag; <span class="c">/* win[] dirty flag */</span>
|
||||
BYTE fsi_flag; <span class="c">/* fsinfo dirty flag */</span>
|
||||
BYTE wflag; <span class="c">/* win[] flag (b0:win[] is dirty) */</span>
|
||||
BYTE fsi_flag; <span class="c">/* FSINFO flags (b7:Disabled, b0:Dirty) */</span>
|
||||
WORD id; <span class="c">/* File system mount ID */</span>
|
||||
WORD n_rootdir; <span class="c">/* Number of root directory entries (FAT12/16) */</span>
|
||||
<span class="k">#if</span> _MAX_SS != 512
|
||||
@@ -31,12 +31,11 @@
|
||||
_SYNC_t sobj; <span class="c">/* Identifier of sync object */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if</span> !_FS_READONLY
|
||||
DWORD last_clust; <span class="c">/* Last allocated cluster */</span>
|
||||
DWORD free_clust; <span class="c">/* Number of free clusters */</span>
|
||||
DWORD fsi_sector; <span class="c">/* fsinfo sector (FAT32) */</span>
|
||||
DWORD last_clust; <span class="c">/* FSINFO: Last allocated cluster */</span>
|
||||
DWORD free_clust; <span class="c">/* FSINFO: Number of free clusters */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if</span> _FS_RPATH
|
||||
DWORD cdir; <span class="c">/* Current directory cluster (0:root) */</span>
|
||||
DWORD cdir; <span class="c">/* Current directory start cluster (0:root) */</span>
|
||||
<span class="k">#endif</span>
|
||||
DWORD n_fatent; <span class="c">/* Number of FAT entries (== Number of clusters + 2) */</span>
|
||||
DWORD fsize; <span class="c">/* Sectors per FAT */</span>
|
||||
@@ -45,7 +44,7 @@
|
||||
DWORD dirbase; <span class="c">/* Root directory area start sector (FAT32: Cluster#) */</span>
|
||||
DWORD database; <span class="c">/* Data area start sector */</span>
|
||||
DWORD winsect; <span class="c">/* Current sector appearing in the win[] */</span>
|
||||
BYTE win[_MAX_SS]; <span class="c">/* Disk access window for Directory, FAT (and file data on tiny cfg) */</span>
|
||||
BYTE win[_MAX_SS]; <span class="c">/* Disk access window for directory, FAT (and file data at tiny cfg) */</span>
|
||||
} FATFS;
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
+7
-7
@@ -13,16 +13,16 @@
|
||||
|
||||
<div class="para">
|
||||
<h2>FIL</h2>
|
||||
<p>The <tt>FIL</tt> structure (file object) holds state of an open file. It is created by <tt>f_open()</tt> function and discarded by <tt>f_close()</tt> function. Application program must not modify any member in this structure except for <tt>cltbl</tt>. Note that a sector buffer is defined in this structure under non-tiny configuration, so that the <tt>FIL</tt> structures should not be defined as auto variable.</p>
|
||||
<p>The <tt>FIL</tt> structure (file object) holds state of an open file. It is created by <tt>f_open()</tt> function and discarded by <tt>f_close()</tt> function. Application program must not modify any member in this structure except for <tt>cltbl</tt>. Note that a sector buffer is defined in this structure at non-tiny configuration, so that the <tt>FIL</tt> structures should not be defined as auto variable.</p>
|
||||
|
||||
<pre>
|
||||
<span class="k">typedef</span> <span class="k">struct</span> {
|
||||
FATFS* fs; <span class="c">/* Pointer to the owner file system object */</span>
|
||||
WORD id; <span class="c">/* Owner file system mount ID */</span>
|
||||
BYTE flag; <span class="c">/* File status flags */</span>
|
||||
BYTE pad1;
|
||||
BYTE flag; <span class="c">/* File object status flags */</span>
|
||||
BYTE err; <span class="c">/* Abort flag (error code) */</span>
|
||||
DWORD fptr; <span class="c">/* File read/write pointer (Byte offset origin from top of the file) */</span>
|
||||
DWORD fsize; <span class="c">/* File size */</span>
|
||||
DWORD fsize; <span class="c">/* File size in unit of byte */</span>
|
||||
DWORD sclust; <span class="c">/* File start cluster */</span>
|
||||
DWORD clust; <span class="c">/* Current cluster */</span>
|
||||
DWORD dsect; <span class="c">/* Current data sector */</span>
|
||||
@@ -33,11 +33,11 @@
|
||||
<span class="k">#if</span> _USE_FASTSEEK
|
||||
DWORD* cltbl; <span class="c">/* Pointer to the cluster link map table (Nulled on file open) */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if</span> _FS_SHARE
|
||||
UINT lockid; <span class="c">/* File lock ID */</span>
|
||||
<span class="k">#if</span> _FS_LOCK
|
||||
UINT lockid; <span class="c">/* Fle lock ID */</span>
|
||||
<span class="k">#endif</span>
|
||||
<span class="k">#if</span> !_FS_TINY
|
||||
BYTE buf[_MAX_SS]; <span class="c">/* Data read/write buffer */</span>
|
||||
BYTE buf[_MAX_SS]; <span class="c">/* File private data transfer buffer */</span>
|
||||
<span class="k">#endif</span>
|
||||
} FIL;
|
||||
</pre>
|
||||
|
||||
@@ -58,11 +58,11 @@
|
||||
<dt>fattrib</dt>
|
||||
<dd>Indicates the file/directory attribute in combination of <tt>AM_DIR</tt>, <tt>AM_RDO</tt>, <tt>AM_HID</tt>, <tt>AM_SYS</tt> and <tt>AM_ARC</tt>.</dd>
|
||||
<dt>fname[]</dt>
|
||||
<dd>Indicates the file/directory name in 8.3 format null-terminated string. It is always returnd with upper case on non-LFN configuration but it can be returned with lower case on LFN configuration.</dd>
|
||||
<dd>Indicates the file/directory name in 8.3 format null-terminated string. It is always returnd with upper case in non-LFN configuration but it can be returned with lower case in LFN configuration.</dd>
|
||||
<dt>lfname</dt>
|
||||
<dd>Pointer to the LFN buffer to store the read LFN. This member must be initialized by application prior to use this structure. Not available on non-LFN configuration.</dd>
|
||||
<dd>Pointer to the LFN buffer to store the read LFN. This member must be initialized by application prior to use this structure. Not available in non-LFN configuration.</dd>
|
||||
<dt>lfsize</dt>
|
||||
<dd>Size of the LFN buffer in unit of TCHAR. This member must be initialized by application prior to use this structure. Not available on non-LFN configuration.</dd>
|
||||
<dd>Size of the LFN buffer in unit of TCHAR. This member must be initialized by application prior to use this structure. Not available in non-LFN configuration.</dd>
|
||||
</dl>
|
||||
|
||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||
|
||||
+4
-4
@@ -13,7 +13,7 @@
|
||||
|
||||
<div class="para func">
|
||||
<h2>f_stat</h2>
|
||||
<p>The f_stat gets the file status.</p>
|
||||
<p>The f_stat function checks the existence of a file or sub-directory.</p>
|
||||
<pre>
|
||||
FRESULT f_stat (
|
||||
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Object name */</span>
|
||||
@@ -26,9 +26,9 @@ FRESULT f_stat (
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>path</dt>
|
||||
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">file or directory</a> to get its information.</dd>
|
||||
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">object</a> to get its information.</dd>
|
||||
<dt>fno</dt>
|
||||
<dd>Pointer to the blank <tt>FILINFO</tt> structure to store the information.</dd>
|
||||
<dd>Pointer to the blank <tt>FILINFO</tt> structure to store the information of the object. Set null pointer if it is not needed.</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
@@ -54,7 +54,7 @@ FRESULT f_stat (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_stat()</tt> function gets the size, timestamp and attribute of a file or directory. For details of the infomation, refer to the <tt>FILINFO</tt> structure and <a href="readdir.html"><tt>f_readdir()</tt></a> function.</p>
|
||||
<p>The <tt>f_stat()</tt> function checks the existence of a file or sub-directory. If exist, the function returns with <tt>FR_OK</tt> and the information of the object is stored to the file information structure. If not exist, the function returns with <tt>FR_NO_FILE</tt>. For details, refer to the <tt>FILINFO</tt> structure and <a href="readdir.html"><tt>f_readdir()</tt></a> function.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
+2
-1
@@ -45,7 +45,8 @@ FRESULT f_sync (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_sync()</tt> function performs the same process as <tt>f_close()</tt> function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing <tt>f_sync()</tt> function of periodic or immediataly after <tt>f_write()</tt> function can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. However the <tt>f_sync()</tt> function immediataly before <tt>f_close()</tt> function has no advantage because it performs <tt>f_sync()</tt> function in it. In other words, the differnce between those functions is that the file object is invalidated or not. </p>
|
||||
<p>The <tt>f_sync()</tt> function performs the same process as <tt>f_close()</tt> function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing <tt>f_sync()</tt> function of periodic or immediataly after <tt>f_write()</tt> function can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. For more information, refer to <a href="appnote.html#critical">application note</a>.</p>
|
||||
<p>However the <tt>f_sync()</tt> function immediataly before <tt>f_close()</tt> function has no advantage because it performs <tt>f_sync()</tt> function in it. In other words, the differnce between those functions is that the file object is invalidated or not.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
+4
-4
@@ -13,7 +13,7 @@
|
||||
|
||||
<div class="para func">
|
||||
<h2>f_unlink</h2>
|
||||
<p>The f_unlink function removes a file or directory.</p>
|
||||
<p>The f_unlink function removes a file or sub-directory.</p>
|
||||
<pre>
|
||||
FRESULT f_unlink (
|
||||
const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] Object name */</span>
|
||||
@@ -56,10 +56,10 @@ FRESULT f_unlink (
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>
|
||||
If condition of the object to be removed is applicable to the following terms, the function will fail with error.<ul>
|
||||
If condition of the object to be removed is applicable to the following terms, the function will be rejected.<ul>
|
||||
<li>The object must not have read-only attribute (<tt>AM_RDO</tt>) or the function will be rejected with <tt>FR_DENIED</tt>.</li>
|
||||
<li>The directory must be empty and must not be current directory or the function will be rejected with <tt>FR_DENIED</tt>.</li>
|
||||
<li>The file must not have been opened or the <em>FAT volume can be collapted</em>. It will able to be rejected with <tt>FR_LOCKED</tt> when <a href="appnote.html#dup">file shareing control</a> is enabled.</li>
|
||||
<li>The sub-directory must be empty and must not be current directory or the function will be rejected with <tt>FR_DENIED</tt>.</li>
|
||||
<li>The file or directory must not have been opened or the <em>FAT volume can be collapted</em>. It will able to be rejected with <tt>FR_LOCKED</tt> when <a href="appnote.html#dup">file lock feature</a> is enabled.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
+3
-3
@@ -13,7 +13,7 @@
|
||||
|
||||
<div class="para func">
|
||||
<h2>f_utime</h2>
|
||||
<p>The f_utime function changes the timestamp of a file or directory.</p>
|
||||
<p>The f_utime function changes the timestamp of a file or sub-directory.</p>
|
||||
<pre>
|
||||
FRESULT f_utime (
|
||||
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Object name */</span>
|
||||
@@ -26,7 +26,7 @@ FRESULT f_utime (
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>path</dt>
|
||||
<dd>Pointer to the null-terminated string that specifies a <a href="filename.html">file or directory</a> to be changed.</dd>
|
||||
<dd>Pointer to the null-terminated string that specifies an <a href="filename.html">object</a> to be changed.</dd>
|
||||
<dt>fno</dt>
|
||||
<dd>Pointer to the file information structure that has a timestamp to be set in member fdate and ftime. Do not care any other members.</dd>
|
||||
</dl>
|
||||
@@ -55,7 +55,7 @@ FRESULT f_utime (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_utime()</tt> function changes the timestamp of a file or directory</p>
|
||||
<p>The <tt>f_utime()</tt> function changes the timestamp of a file or sub-directory</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user