fatfs v0.08 May 15, 2010:

- Added a memory configuration option. (_USE_LFN)
- Added file lock feature. (_FS_SHARE)
- Added fast seek feature. (_USE_FASTSEEK)
- Changed some types on the API, XCHAR->TCHAR.
- Changed fname member in the FILINFO structure on Unicode cfg.
- String functions support UTF-8 encoding files on Unicode cfg.
This commit is contained in:
savelij13 committed 2025-09-11 09:40:03 +03:00
1 parent e6cd91ca0b
commit 46155916b1
92 files changed
+2469 -1589

No files matched your search

+53 -42
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/appnote.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs Module Application Note</title>
</head>
@@ -13,22 +14,22 @@
<hr>
<div class="para">
<h3>Basic considerations on porting</h3>
<p>The FatFs module is assuming following terms on portability.</p>
<h3>How to port</h3>
<h4>Basic considerations</h4>
<p>The FatFs module is assuming following conditions on portability.</p>
<ul>
<li>ANSI C<br>
The FatFs module is a middleware that written in ANSI C. There is no platform dependence, so long as the compiler is in compliance with ANSI C.</li>
The FatFs module is a middleware which is written in ANSI C. There is no platform dependence, so long as the compiler is in compliance with ANSI C.</li>
<li>Size of integer types<br>
The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is 16 or 32 bit. These correspondence are defined in integer.h. This will not be a problem on most compilers. When any conflict with existing definitions is occured, you must resolve it with care.</li>
</ul>
</div>
<div class="para">
<h3>How to port</h3>
<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. All 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>
<table class="lst2">
<tr><th>Function</th><th>Required when:</th></tr>
<tr><td>disk_initialize</td><td>Always</td></tr>
<tr><th>Function</th><th>Required when:</th><th>Note</th></tr>
<tr><td>disk_initialize</td><td>Always</td><td rowspan="9">Samples available in ffsample.zip.<br>There are many implementations on the web.</td></tr>
<tr><td>disk_status</td><td>Always</td></tr>
<tr><td>disk_read</td><td>Always</td></tr>
<tr><td>disk_write</td><td>_FS_READONLY == 0</td></tr>
@@ -37,6 +38,14 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
<tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS &gt;= 1024</td></tr>
<tr><td>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr>
<tr><td>get_fattime</td><td>_FS_READONLY == 0</td></tr>
<tr><td>ff_convert</td><td>_USE_LFN &gt;= 1</td><td rowspan="2">Available in option/cc*.c.</td></tr>
<tr><td>ff_wtoupper</td><td>_USE_LFN &gt;= 1</td></tr>
<tr><td>ff_cre_syncobj</td><td>_FS_REENTRANT == 1</td><td rowspan="6">Samples available in option/syscall.c.</td></tr>
<tr><td>ff_del_syncobj</td><td>_FS_REENTRANT == 1</td></tr>
<tr><td>ff_req_grant</td><td>_FS_REENTRANT == 1</td></tr>
<tr><td>ff_rel_grant</td><td>_FS_REENTRANT == 1</td></tr>
<tr><td>ff_mem_alloc</td><td>_USE_LFN == 3</td></tr>
<tr><td>ff_mem_free</td><td>_USE_LFN == 3</td></tr>
</table>
</div>
@@ -44,28 +53,28 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
<h3>Limits</h3>
<ul>
<li>FAT sub-types: FAT12, FAT16 and FAT32.</li>
<li>Number of open files: Unlimited. Depends on available memory.</li>
<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 (4G-1 bytes). </li>
<li>Volume size: Depends on FAT specs (upto 2T,4T or 8T bytes). </li>
<li>Cluster size: Upto 64K bytes. Upto 32K bytes for f_mkfs().</li>
<li>Sector size: Depends on FAT specs (upto 4K bytes).</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>Sector size: Depends on FAT specs. (upto 4K bytes)</li>
</ul>
</div>
<div class="para">
<h3>Memory Usage (R0.07e)</h3>
<h3>Memory Usage (R0.08)</h3>
<table class="lst2">
<tr><th></th><th>AVR</th><th>H8/300H</th><th>PIC</th><th>TLCS-870/C</th><th>V850ES</th><th>SH2</th><th>ARM7TDMI</th><th>x86</th></tr>
<tr><td>Compiler</td><td>WinAVR(gcc)</td><td>CH38</td><td>C30(gcc)</td><td>CC870C</td><td>CA850</td><td>SHC</td><td>WinARM(gcc)</td><td>VC6</td></tr>
<tr><td>_WORD_ACCESS</td><td>1</td><td>0</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>1</td></tr>
<tr class="lst3"><td>text (Full, R/W)</td><td>12194</td><td>10559</td><td>10924</td><td>15229</td><td>7686</td><td>8727</td><td>10564</td><td>7342</td></tr>
<tr> <td>text (Min, R/W)</td><td>7988</td><td>6903</td><td>7108</td><td>9960</td><td>4884</td><td>5651</td><td>6544</td><td>4764</td></tr>
<tr><td>text (Full, R/O)</td><td>5532</td><td>4753</td><td>5020</td><td>6760</td><td>3462</td><td>3777</td><td>4624</td><td>3316</td></tr>
<tr> <td>text (Min, R/O)</td><td>4040</td><td>3631</td><td>3736</td><td>5083</td><td>2556</td><td>2907</td><td>3284</td><td>2510</td></tr>
<tr><td>bss</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
<tr><td>Work area<br>(_FS_TINY == 0)</td><td>D*560 +<br>F*544</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*544</td><td></td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td></tr>
<tr><td>Work area<br>(_FS_TINY == 1)</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td></tr>
<tr><th></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>V850ES</th><th>SH-2A</th><th>ARM7</th><th>x86</th></tr>
<tr><td>Compiler</td><td>WinAVR(gcc)</td><td>CH38</td><td>C30(gcc)</td><td>CA850</td><td>SHC</td><td>WinARM(gcc)</td><td>VC6</td></tr>
<tr><td>_WORD_ACCESS</td><td>1</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>1</td></tr>
<tr class="lst3"><td>text (Full, R/W)</td><td>12700</td><td>10686</td><td>11376</td><td>7730</td><td>8592</td><td>10520</td><td>7545</td></tr>
<tr> <td>text (Min, R/W)</td><td>8386</td><td>6980</td><td>7395</td><td>4930</td><td>5600</td><td>6636</td><td>4923</td></tr>
<tr><td>text (Full, R/O)</td><td>6012</td><td>4874</td><td>5250</td><td>3556</td><td>3848</td><td>4656</td><td>3450</td></tr>
<tr> <td>text (Min, R/O)</td><td>4384</td><td>3774</td><td>3939</td><td>2684</td><td>2996</td><td>3416</td><td>2664</td></tr>
<tr><td>bss</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
<tr><td>Work area<br>(_FS_TINY == 0)</td><td>D*560 +<br>F*544</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*544</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td></tr>
<tr><td>Work area<br>(_FS_TINY == 1)</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td><td>D*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, D means number of volumes and F means number of open files. All samples are optimezed in code size.</p>
<pre>
@@ -74,12 +83,14 @@ _FS_MINIMIZE 0 (Full function), 3 (Minimized function)
_USE_STRFUNC 0 (Disable string functions)
_USE_MKFS 0 (Disable f_mkfs function)
_USE_FORWARD 0 (Disable f_forward function)
_USE_FASTSEEK 0 (Disable fast seek feature)
_CODE_PAGE 932 (Japanese Shift-JIS)
_USE_LFN 0 (Disable LFN)
_MAX_SS 512 (Single sector size)
_MAX_SS 512 (Fixed sector size)
_FS_RPATH 0 (Disable relative path)
_MULTI_PARTITION 0 (Single partition per drive)
_FS_REENTRANT 0 (Disable reentrancy)
_FS_SHARE 0 (Disable shareing control)
</pre>
</div>
@@ -119,7 +130,7 @@ _FS_REENTRANT 0 (Disable reentrancy)
<div class="para">
<h3>Long File Name</h3>
<p>The FatFs module supports long file name (LFN) from 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 or 2, and add a Unicode code conversion function ff_convert and ff_wtoupper to the project. This function is available in <tt>cc*.c</tt>. 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. In this case, the file function allocates the working buffer on the stack. The working buffer occupies <tt>(_MAX_LFN + 1) * 2</tt> bytes so that the caller's stack must be a sufficient size considering the working buffer.</p>
<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>
<tr><th>Code page</th><th>Program size</th></tr>
@@ -129,13 +140,18 @@ _FS_REENTRANT 0 (Disable reentrancy)
<tr><td>949(Korean)</td><td>+139K</td></tr>
<tr><td>950(Big5)</td><td>+111K</td></tr>
</table>
<p>When the LFN feature is enabled, the module size will be increased depends on the selected code page. Right table shows how many bytes increased when LFN feature is enabled with some code pages. We are the Japanese, Chinese and Korean have tens of thousands of characters. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased that shown in the table. As the result, the FatFs with LFN will not able to be implemented to most 8-bit microcontrollers including AVR. <small>This is the reason why I had not been interested in implementing the LFN feature for a long time :-)</small></p>
<p>When the LFN feature is enabled, the module size will be increased depends on the selected code page. Right table shows how many bytes increased when LFN feature is enabled with some code pages. We are the Japanese, Chinese and Korean have tens of thousands of characters. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased that shown in the table. As the result, the FatFs with LFN feature with DBCS will not able to be implemented to most 8-bit microcontrollers. <small>This is the reason why I had not been interested in implementing the LFN feature for a long time :-)</small></p>
<p>Note that the LFN feature on the FAT file system is a patent of Microsoft Corporation. When enable it on the commercial products, a license from Microsoft may be required depends on the final destination.</p>
</div>
<div class="para">
<h3>Unicode API</h3>
<p>FatFs supports ANSI/OEM code set on the API in default but FatFs can also switch the code set to Unicode. For more information, refer to the description in the <a href="filename.html">file name</a>.</p>
</div>
<div class="para">
<h3>Re-entrancy</h3>
<p>The file operations to the different volume can always work simultaneously regardless of re-entrancy setting. The re-entrancy to the same volume can be enabled with <tt>_FS_REENTRANT</tt> option. In this case, also the OS dependent synchronization object control functions, ff_cre_syncobj, ff_del_syncobj, ff_req_grant and ff_rel_grant must be added to the project. The sample code with documentation is available in <tt>syncobj.c</tt>.</p>
<p>The file operations to the different volume can always work simultaneously regardless of re-entrancy setting. The re-entrancy to the same volume can be enabled with <tt>_FS_REENTRANT</tt> option. In this case, also the OS dependent synchronization object control functions, ff_cre_syncobj, ff_del_syncobj, ff_req_grant and ff_rel_grant 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 access is blocked until the 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 f_mount and f_mkfs 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. There is no assumtion on the re-entrancy of low level disk I/O module.</p>
@@ -143,7 +159,8 @@ _FS_REENTRANT 0 (Disable reentrancy)
<div class="para">
<h3>Duplicated file access</h3>
<p>FatFs module does not support the shareing controls of duplicated file access. It is permitted when open method to the 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, otherwise the FAT structure on the volume can be collapted.</p>
<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, otherwise the FAT structure on the volume can be collapted. Also current directory must not be deleted.</p>
<p>The file shareing control can also be available when <tt>_FS_SHARE</tt> is set to 1 or grater. 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>.</p>
</div>
<div class="para">
@@ -160,12 +177,12 @@ _FS_REENTRANT 0 (Disable reentrancy)
</p>
<p>The file I/O buffer means 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 partial sector data 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 disk_read function at a time but the multi 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>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>
</div>
<div class="para">
<h3>Critical Section</h3>
<p>When write operation to the FAT file system is interrupted due to any accidental failure, such as sudden blackout, incorrect disk removal and unrecoverable disk error, the FAT structure can be collapted. Following images shows the critical section on the FatFs application.</p>
<p>If a write operation to the FAT file system is interrupted due to any accidental failure, such as sudden blackout, incorrect disk removal and unrecoverable disk error, the FAT structure can be collapted. Following images shows the critical section on the FatFs application.</p>
<div class="lset">
Figure 4. Long critical section<br>
<img src="../img/f4.png" width="320" height="436" alt="fig.4">
@@ -175,34 +192,28 @@ Figure 5. Minimized critical section<br>
<img src="../img/f5.png" width="320" height="436" alt="fig.5">
</div>
<br class="clr">
<p>An interruption in the red section can cause a cross link; as a result, the file/directory being changed may be lost. There is one or more possibility listed below when an interruption in the yellow section is occured.</p>
<p>An interruption in the red section can cause a cross link; as a result, the object being changed may be lost. There is one or more possibility listed below when an interruption in the yellow section is occured.</p>
<ul>
<li>File data being rewrited is collapted.</li>
<li>A file being appended returns initial state.</li>
<li>A file created as new is gone.</li>
<li>A file created as new or in overwritten remains with length of zero.</li>
<li>A file created as new or in overwritten remains with no content.</li>
<li>Efficiency of disk use gets worse due to lost chain.</li>
</ul>
<p>Each case does not affect the files that not in write mode open. 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 f_sync function properly.</p>
</div>
<div class="para">
<h3>Unicode API</h3>
<p>FatFs supports OEM code set on the API in default but FatFs can also switch the code set to Unicode. For more information, refer to the description in the <a href="filename.html">file name</a>.</p>
</div>
<div class="para">
<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.07e (C)ChaN, 2009
/ FatFs - FAT file system module R0.08 (C)ChaN, 2010
/-----------------------------------------------------------------------------/
/ 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
/ developments under license policy of following trems.
/
/ Copyright (C) 2009, ChaN, all right reserved.
/ Copyright (C) 2010, ChaN, all right reserved.
/
/ * The FatFs module is a free software and there is NO WARRANTY.
/ * No restriction on use. You can use, modify and redistribute it for
@@ -210,7 +221,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, 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. 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 license.</p>
<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, 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. 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>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
+5 -4
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/chdir.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_chdir</title>
</head>
@@ -15,7 +16,7 @@
<p>The f_chdir function changes the current directory of a drive.</p>
<pre>
FRESULT f_chdir (
const XCHAR* <em>Path</em> /* Pointer to the path name */
const TCHAR* <em>Path</em> <span>/* Pointer to the path name */</span>
);
</pre>
</div>
@@ -49,7 +50,7 @@ FRESULT f_chdir (
<dt>FR_NOT_ENABLED</dt>
<dd>The logical drive has no work area.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT volume on the disk.</dd>
<dd>There is no valid FAT volume on the drive.</dd>
</dl>
</div>
@@ -69,10 +70,10 @@ FRESULT f_chdir (
<div class="para">
<h4>Example</h4>
<pre>
// Change current direcoty of the current drive (dir1 under root dir)
<span>/* Change current direcoty of the current drive (dir1 under root dir) */</span>
f_chdir("/dir1");
// Change current direcoty of drive 2 (parent dir)
<span>/* Change current direcoty of drive 2 (parent dir) */</span>
f_chdir("2:..");
</pre>
</div>
+2 -1
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/chdrive.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_chdrive</title>
</head>
@@ -15,7 +16,7 @@
<p>The f_chdrive function changes the current drive.</p>
<pre>
FRESULT f_chdrive (
BYTE <em>Drive</em> /* Logical drive number */
BYTE <em>Drive</em> <span>/* Logical drive number */</span>
);
</pre>
</div>
+6 -5
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/chmod.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_chmod</title>
</head>
@@ -15,9 +16,9 @@
<p>The f_chmod function changes the attribute of a file or directory.</p>
<pre>
FRESULT f_chmod (
const XCHAR* <em>FileName</em>, /* Pointer to the file or directory */
BYTE <em>Attribute</em>, /* Attribute flags */
BYTE <em>AttributeMask</em> /* Attribute masks */
const TCHAR* <em>FileName</em>, <span>/* Pointer to the file or directory */</span>
BYTE <em>Attribute</em>, <span>/* Attribute flags */</span>
BYTE <em>AttributeMask</em> <span>/* Attribute masks */</span>
);
</pre>
</div>
@@ -67,7 +68,7 @@ FRESULT f_chmod (
<dt>FR_NOT_ENABLED</dt>
<dd>The logical drive has no work area.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT volume on the disk.</dd>
<dd>There is no valid FAT volume on the drive.</dd>
</dl>
</div>
@@ -87,7 +88,7 @@ FRESULT f_chmod (
<div class="para">
<h4>Example</h4>
<pre>
// Set read-only flag, clear archive flag and others are retained.
<span>/* Set read-only flag, clear archive flag and others are retained. */</span>
f_chmod("file.txt", AR_RDO, AR_RDO | AR_ARC);
</pre>
</div>
+3 -2
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/close.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_close</title>
</head>
@@ -15,7 +16,7 @@
<p>The f_close function closes an open file.</p>
<pre>
FRESULT f_close (
FIL* <em>FileObject</em> /* Pointer to the file object structure */
FIL* <em>FileObject</em> <span>/* Pointer to the file object structure */</span>
);
</pre>
</div>
@@ -48,7 +49,7 @@ FRESULT f_close (
<div class="para">
<h4>Description</h4>
<p>The f_close 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. If the file object has been opened in read-only mode, it may be discarded without closing process by this function.</p>
<p>The f_close 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. If the file object has been opened in read-only mode, it may be discarded without closing process by this function but not recommended.</p>
</div>
+3 -2
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dinit.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_initialize</title>
</head>
@@ -15,7 +16,7 @@
<p>The disk_initialize function initializes the disk drive.</p>
<pre>
DSTATUS disk_initialize (
BYTE <em>Drive</em> /* Physical drive number */
BYTE <em>Drive</em> <span>/* Physical drive number */</span>
);
</pre>
</div>
@@ -37,7 +38,7 @@ DSTATUS disk_initialize (
<div class="para">
<h4>Description</h4>
<p>The disk_initialize function initializes a physical drive. When the function succeeded, <tt>STA_NOINIT</tt> flag in the return value is cleard.</p>
<p>This function is called from volume mount process in the FatFs module to manage the media change. <em>Application program must not call this function while FatFs module is active, or FAT structure on the volume can be collapted. To re-initialize the file system, use f_mount function.</em></p>
<p>This function is called on volume mount process in the FatFs module to manage the media change. <em>Application program should not call this function, or FAT structure on the volume can be collapted. To re-initialize the file system, use f_mount function.</em></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
+7 -6
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dioctl.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_ioctl</title>
</head>
@@ -15,9 +16,9 @@
<p>The disk_ioctl function cntrols device specified features and miscellaneous functions other than disk read/write.</p>
<pre>
DRESULT disk_ioctl (
BYTE <em>Drive</em>, /* Drive number */
BYTE <em>Command</em>, /* Control command code */
void* <em>Buffer</em> /* Data transfer buffer */
BYTE <em>Drive</em>, <span>/* Drive number */</span>
BYTE <em>Command</em>, <span>/* Control command code */</span>
void* <em>Buffer</em> <span>/* Parameter and data buffer */</span>
);
</pre>
</div>
@@ -56,9 +57,9 @@ DRESULT disk_ioctl (
<table class="lst">
<tr><th>Command</th><th>Description</th></tr>
<tr><td>CTRL_SYNC</td><td>Make sure that the disk drive has finished pending write process. When the disk I/O module has a write back cache, flush the dirty sector immediately. This command is not required in read-only configuration.</td></tr>
<tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the drive into the WORD variable pointed by Buffer. This command is not required in single sector size configuration, _MAX_SS is 512.</td></tr>
<tr><td>GET_SECTOR_COUNT</td><td>Returns total sectors on the drive into the DWORD variable pointed by Buffer. This command is used in only f_mkfs function.</td></tr>
<tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the memory array in unit of sector into the DWORD variable pointed by Buffer. When the erase block size is unknown or magnetic disk device, return 1. This command is used in only f_mkfs function.</td></tr>
<tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the drive into the WORD variable pointed by <tt>Buffer</tt>. This command is not required in single sector size configuration, _MAX_SS is 512.</td></tr>
<tr><td>GET_SECTOR_COUNT</td><td>Returns total sectors on the drive into the DWORD variable pointed by <tt>Buffer</tt>. This command is used by only f_mkfs function to determine the volume size to be created.</td></tr>
<tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the flash memory in unit of sector into the DWORD variable pointed by <tt>Buffer</tt>. This command is used by only f_mkfs function and it attempts to align data area to the erase block boundary. The allowable value is 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or disk devices.</td></tr>
</table>
</div>
+5 -4
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dread.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_read</title>
</head>
@@ -15,10 +16,10 @@
<p>The disk_read function reads sector(s) from the disk drive.</p>
<pre>
DRESULT disk_read (
BYTE <em>Drive</em>, /* Physical drive number */
BYTE* <em>Buffer</em>, /* Pointer to the read data buffer */
DWORD <em>SectorNumber</em>, /* Start sector number */
BYTE <em>SectorCount</em> /* Number of sectros to read */
BYTE <em>Drive</em>, <span>/* Physical drive number */</span>
BYTE* <em>Buffer</em>, <span>/* Pointer to the read data buffer */</span>
DWORD <em>SectorNumber</em>, <span>/* Start sector number */</span>
BYTE <em>SectorCount</em> <span>/* Number of sectros to read */</span>
);
</pre>
</div>
+3 -2
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dstat.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_status</title>
</head>
@@ -15,7 +16,7 @@
<p>The disk_status function returns the current disk status.</p>
<pre>
DSTATUS disk_status (
BYTE <em>Drive</em> /* Physical drive number */
BYTE <em>Drive</em> <span>/* Physical drive number */</span>
);
</pre>
</div>
@@ -31,7 +32,7 @@ DSTATUS disk_status (
<div class="para">
<h4>Return Values</h4>
<p>The disk status is returned in combination of following flags.</p>
<p>The disk status is returned in combination of following flags. FatFs refers only <tt>STA_NOINIT</tt> and <tt>STA_PROTECTED</tt>.</p>
<dl class="ret">
<dt>STA_NOINIT</dt>
<dd>Indicates that the disk drive has not been initialized. This flag is set on: system reset, disk removal and disk_initialize function failed, and cleared on: disk_initialize function succeeded.</dd>
+5 -4
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dwrite.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_write</title>
</head>
@@ -15,10 +16,10 @@
<p>The disk_write writes sector(s) to the disk.</p>
<pre>
DRESULT disk_write (
BYTE <em>Drive</em>, /* Physical drive number */
const BYTE* <em>Buffer</em>, /* Pointer to the write data (may be non aligned) */
DWORD <em>SectorNumber</em>, /* Sector number to write */
BYTE <em>SectorCount</em> /* Number of sectors to write */
BYTE <em>Drive</em>, <span>/* Physical drive number */</span>
const BYTE* <em>Buffer</em>, <span>/* Pointer to the write data (may be non aligned) */</span>
DWORD <em>SectorNumber</em>, <span>/* Sector number to write */</span>
BYTE <em>SectorCount</em> <span>/* Number of sectors to write */</span>
);
</pre>
</div>
+1
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/fattime.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - get_fattime</title>
</head>
+15 -10
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<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/filename.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - Path Names</title>
</head>
@@ -13,10 +14,9 @@
<div class="para">
<h2>Format of the path names</h2>
<p>The path name format on the FatFs module is similer to the filename specs of DOS/Windos as follows:</p>
<pre>
"[<em>drive#</em>:][/]<em>directory</em>/<em>file</em>"
</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 &gt; 0)</tt>. The differences between DOS/Windows are directory separator and logical drive number. The sub directories are separated with a / or \. The logical drive is specified in a numeral with a colon. When the drive number is omitted, it is assumed as default drive (0 or current drive). Leading/embedded spaces in the given 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.</p>
<p><tt>"[drive#:][/]directory/file"</tt></p>
<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 &gt; 0)</tt>. The differences between FatFs and DOS/Windows are directory separator and logical drive number. The sub directories are separated with a / or \. The logical drive is specified in a numeral with a colon. When the drive number is omitted, it is assumed as default drive (0 or current drive).</p>
<p>Nul character and control characters (\0 to \x1F) 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.</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, the path is followed from the current directory set with <a href="chdir.html">f_chdir</a> function. Dot names are also allowed for the directory name. The default drive number is the current drive number set with <a href="chdrive.html">f_chdrive</a> function.</p>
<table class="lst2">
@@ -31,14 +31,19 @@
<tr><td>.</td><td>Invalid name</td><td>This directory</td></tr>
<tr><td>..</td><td>Invalid name</td><td>Parent directory of the current directory</td></tr>
<tr><td>dir1/..</td><td>Invalid name</td><td>The current directory</td></tr>
<tr><td>/..</td><td>Invalid name</td><td>Invalid name (Cannot use dot names at the root directory)</td></tr>
<tr><td>/..</td><td>Invalid name</td><td>The root directory (sticks the top level)</td></tr>
</table>
</div>
<p><br></p>
<div class="para">
<h2>Unicode API</h2>
<p>The path names are input/output in either OEM code (SBCS/DBCS) or Unicode depends on the configuration options. The type of arguments that specifies the file names are defined as <tt>XCHAR</tt> which is an alias of <tt>char</tt> in default. The code set of the file name string is the OEM code set specifid by <tt>_CODE_PAGE</tt>. When <tt>_LFN_UNICODE</tt> is set to 1 under LFN configuration, the type of the <tt>XCHAR</tt> is switched to <tt>unsigned short</tt> (wide 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.</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 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 under LFN configuration, the type of the <tt>TCHAR</tt> is switched to <tt>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>
<pre>
f_open(fp, "filename.txt", FA_READ); <span>/* ANSI/OEM only */</span>
f_open(fp, L"filename.txt", FA_READ); <span>/* Unicode only */</span>
f_open(fp, _T("filename.txt"), FA_READ); <span>/* Changed automatically */</span>
</pre>
</div>
<p><br></p>
@@ -50,10 +55,10 @@ Example: Logical drive 0-2 are assigned to three pri-partitions on the physical
Logical drive 3 is assigned to physical drive 1 (removable disk)
const PARTITION Drives[] = {
{0, 0}, /* Logical drive 0 ==> Physical drive 0, 1st partition */
{0, 1}, /* Logical drive 1 ==> Physical drive 0, 2nd partition */
{0, 2}, /* Logical drive 2 ==> Physical drive 0, 3rd partition */
{1, 0} /* Logical drive 3 ==> Physical drive 1 */
{0, 0}, <span>/* Logical drive 0 ==> Physical drive 0, 1st partition */</span>
{0, 1}, <span>/* Logical drive 1 ==> Physical drive 0, 2nd partition */</span>
{0, 2}, <span>/* Logical drive 2 ==> Physical drive 0, 3rd partition */</span>
{1, 0} <span>/* Logical drive 3 ==> Physical drive 1 */</span>
};
</pre>
<p>There are some considerations when use <tt>_MULTI_PARTITION</tt> configuration.</p>
+28 -25
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/forward.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_forward</title>
</head>
@@ -15,10 +16,10 @@
<p>The f_forward function reads the file data and forward it to the data streaming device.</p>
<pre>
FRESULT f_forward (
FIL* <em>FileObject</em>, /* File object */
UINT (*<em>Func</em>)(const BYTE*,UINT), /* Data streaming function */
UINT <em>ByteToFwd</em>, /* Number of bytes to forward */
UINT* <em>ByteFwd</em> /* Number of bytes forwarded */
FIL* <em>FileObject</em>, <span>/* File object */</span>
UINT (*<em>Func</em>)(const BYTE*,UINT), <span>/* Data streaming function */</span>
UINT <em>ByteToFwd</em>, <span>/* Number of bytes to forward */</span>
UINT* <em>ByteFwd</em> <span>/* Number of bytes forwarded */</span>
);
</pre>
</div>
@@ -72,26 +73,26 @@ FRESULT f_forward (
<div class="para">
<h4>Example (Audio playback)</h4>
<pre>
/*-----------------------------------------------------------------------*/
/* Sample code of data transfer function to be called from f_forward */
/*-----------------------------------------------------------------------*/
<span>/*------------------------------------------------------------------------*/</span>
<span>/* Sample code of data transfer function to be called back from f_forward */</span>
<span>/*------------------------------------------------------------------------*/</span>
UINT out_stream ( /* Returns number of bytes sent or stream status */
const BYTE *p, /* Pointer to the data block to be sent */
UINT btf /* &gt;0: Transfer call (Number of bytes to be sent). 0: Sense call */
UINT out_stream ( <span>/* Returns number of bytes sent or stream status */</span>
const BYTE *p, <span>/* Pointer to the data block to be sent */</span>
UINT btf <span>/* &gt;0: Transfer call (Number of bytes to be sent). 0: Sense call */</span>
)
{
UINT cnt = 0;
if (btf == 0) { /* Sense call */
/* Return stream status (0: Busy, 1: Ready) */
/* When once it returned ready to sense call, it must accept a byte at least */
/* at subsequent transfer call, or f_forward will fail with FR_INT_ERROR. */
if (btf == 0) { <span>/* Sense call */</span>
<span>/* Return stream status (0: Busy, 1: Ready) */</span>
<span>/* When once it returned ready to sense call, it must accept a byte at least */</span>
<span>/* at subsequent transfer call, or f_forward will fail with FR_INT_ERROR. */</span>
if (FIFO_READY) cnt = 1;
}
else { /* Transfer call */
do { /* Repeat while there is any data to be sent and the stream is ready */
else { <span>/* Transfer call */</span>
do { <span>/* Repeat while there is any data to be sent and the stream is ready */</span>
FIFO_PORT = *p++;
cnt++;
} while (cnt &lt; btf &amp;&amp; FIFO_READY);
@@ -101,31 +102,33 @@ UINT out_stream ( /* Returns number of bytes sent or stream status */
}
/*-----------------------------------------------------------------------*/
/* Sample code using f_forward function */
/*-----------------------------------------------------------------------*/
<span>/*------------------------------------------------------------------------*/</span>
<span>/* Sample code using f_forward function */</span>
<span>/*------------------------------------------------------------------------*/</span>
FRESULT play_file (
char *fn /* Pointer to the audio file name to be played */
char *fn <span>/* Pointer to the audio file name to be played */</span>
)
{
FRESULT rc;
FIL fil;
UINT dmy;
/* Open the audio file in read only mode */
<span>/* Open the audio file in read only mode */</span>
rc = f_open(&amp;fil, fn, FA_READ);
if (rc) return rc;
/* Repeat until the file pointer reaches end of the file */
<span>/* Repeat until the file pointer reaches end of the file */</span>
while (rc == FR_OK &amp;&amp; fil.fptr &lt; fil.fsize) {
/* any other processes... */
<span>/* any other processes... */</span>
/* Fill output stream periodicaly or on-demand */
<span>/* Fill output stream periodicaly or on-demand */</span>
rc = f_forward(&amp;fil, out_stream, 1000, &amp;dmy);
}
/* The read-only file object may be discarded without close */
<span>/* Close the file and return */</span>
f_close(&amp;fil);
return rc;
}
</pre>
+10 -9
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/getfree.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_getfree</title>
</head>
@@ -15,9 +16,9 @@
<p>The f_getfree function gets number of the free clusters.</p>
<pre>
FRESULT f_getfree (
const XCHAR* <em>Path</em>, /* Root directory of the drive */
DWORD* <em>Clusters</em>, /* Pointer to the variable to store number of free clusters */
FATFS** <em>FileSystemObject</em> /* Pointer to pointer to file system object */
const TCHAR* <em>Path</em>, <span>/* Logical drive number */</span>
DWORD* <em>Clusters</em>, <span>/* Pointer to the variable to store number of free clusters */</span>
FATFS** <em>FileSystemObject</em> <span>/* Pointer to pointer to file system object */</span>
);
</pre>
</div>
@@ -26,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">root directory</a> of the logical drive.</dd>
<dd>Pinter to the null-terminated string that specifies the <a href="filename.html">logical drive</a>.</dd>
<dt>Clusters</dt>
<dd>Pointer to the DWORD variable to store number of free clusters.</dd>
<dt>FileSystemObject</dt>
@@ -51,7 +52,7 @@ FRESULT f_getfree (
<dt>FR_NOT_ENABLED</dt>
<dd>The logical drive has no work area.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT partition on the disk.</dd>
<dd>There is no valid FAT partition on the drive.</dd>
</dl>
</div>
@@ -75,15 +76,15 @@ FRESULT f_getfree (
DWORD fre_clust, fre_sect, tot_sect;
/* Get drive information and free clusters */
res = f_getfree("/", &amp;fre_clust, &amp;fs);
<span>/* Get volume information and free clusters of drive 1 */</span>
res = f_getfree("1:", &amp;fre_clust, &amp;fs);
if (res) die(res);
/* Get total sectors and free sectors */
<span>/* Get total sectors and free sectors */</span>
tot_sect = (fs->max_clust - 2) * fs->csize;
fre_sect = fre_clust * fs->csize;
/* Print free space in unit of KB (assuming 512B/sector) */
<span>/* Print free space in unit of KB (assuming 512 bytes/sector) */</span>
printf("%lu KB total drive space.\n"
"%lu KB available.\n",
fre_sect / 2, tot_sect / 2);
+8 -6
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/gets.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_gets</title>
</head>
@@ -14,10 +15,10 @@
<h2>f_gets</h2>
<p>The f_gets reads a string from the file.</p>
<pre>
char* f_gets (
char* <em>Str</em>, /* Read buffer */
int <em>Size</em>, /* Size of the read buffer */
FIL* <em>FileObject</em> /* File object */
TCHAR* f_gets (
TCHAR* <em>Str</em>, <span>/* Read buffer */</span>
int <em>Size</em>, <span>/* Size of the read buffer */</span>
FIL* <em>FileObject</em> <span>/* File object */</span>
);
</pre>
</div>
@@ -28,7 +29,7 @@ char* f_gets (
<dt>Str</dt>
<dd>Pointer to read buffer to store the read string.</dd>
<dt>Size</dt>
<dd>Size of the read buffer.</dd>
<dd>Size of the read buffer in unit of character.</dd>
<dt>FileObject</dt>
<dd>Pointer to the open file object structure.</dd>
</dl>
@@ -43,7 +44,8 @@ char* f_gets (
<div class="para">
<h4>Description</h4>
<p>The f_gets() is a wrapper function of <a href="read.html">f_read()</a>. The read operation continues until a <tt>'\n'</tt> is stored, reached end of file or buffer is filled with Size - 1 characters. The read string is terminated with a <tt>'\0'</tt>. When the file has reached end of the file or any error occured during read operation, f_gets() returns a <tt>NULL</tt>. The EOF and error status can be examined with <tt>f_eof()</tt> and <tt>f_error()</tt> macro.</p>
<p>The f_gets() is a wrapper function of <a href="read.html">f_read()</a>. The read operation continues until a <tt>'\n'</tt> is stored, reached end of the file or the buffer is filled with <tt>Size - 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, f_gets() returns a null pointer. The end of file and error status 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 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>
</div>
+32 -14
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/lseek.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_lseek</title>
</head>
@@ -16,8 +17,8 @@
<pre>
FRESULT f_lseek (
FIL* <em>FileObject</em>, /* Pointer to the file object structure */
DWORD <em>Offset</em> /* File offset in unit of byte */
FIL* <em>FileObject</em>, <span>/* Pointer to the file object structure */</span>
DWORD <em>Offset</em> <span>/* File offset in unit of byte */</span>
);
</pre>
</div>
@@ -46,17 +47,20 @@ FRESULT f_lseek (
<dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd>
<dt>FR_INVALID_OBJECT</dt>
<dd>The file object is invalid.</dd>
<dt>FR_NOT_ENOUGH_CORE</dt>
<dd>Insufficient size of link map table for the file.</dd>
</dl>
</div>
<div class="para">
<h4>Description</h4>
<p>The f_lseek function moves the file R/W pointer of an open file. The offset can be specified in only origin from top of the file. When an offset above the file size is specified in write mode, the file size is increased and the data in the expanded area is undefined. This is suitable to create a large file quickly, for fast write operation. After the f_lseek function succeeded, member fptr in the file object should be checked in order to make sure the R/W pointer has been moved correctry. In case of fptr is not the expected value, either of followings has been occured.</p>
<p>The f_lseek function moves the file read/write pointer of an open file. The offset can be specified in only origin from top of the file. When an offset above the file size is specified in write mode, the file size is increased and the data in the expanded area is undefined. This is suitable to create a large file quickly, for fast write operation. After the f_lseek function succeeded, member fptr in the file object should be checked in order to make sure the read/write pointer has been moved correctry. In case of fptr is not the expected value, either of followings has been occured.</p>
<ul>
<li>End of file. The specified Offset was clipped at the file size because the file has been opened in read-only mode.</li>
<li>Disk full. There is insufficient free space on the volume to expand the file size.</li>
</ul>
<p>When <tt>_USE_FASTSEEK</tt> is set to 1 and <tt>cltbl</tt> member in the file object is not NULL, the fast seek feature is enabled. This feature enables fast backward/long seek operations without FAT access by cluster link information stored on the user defined table. The cluster link information must be created prior to do the fast seek. The required size of the table is (number of fragments + 1) * 2 items. For example, when the file is fragmented in 5, 12 items will be required to store the cluster link information. The file size cannot be expanded when the fast seek feature is enabled.</p>
</div>
@@ -69,35 +73,49 @@ FRESULT f_lseek (
<div class="para">
<h4>Example</h4>
<pre>
/* Move to offset of 5000 from top of the file */
<span>/* Move to offset of 5000 from top of the file */</span>
res = f_lseek(file, 5000);
/* Move to end of the file to append data */
<span>/* Move to end of the file to append data */</span>
res = f_lseek(file, file-&gt;fsize);
/* Forward 3000 bytes */
<span>/* Forward 3000 bytes */</span>
res = f_lseek(file, file-&gt;fptr + 3000);
/* Rewind 2000 bytes (take care on overflow) */
<span>/* Rewind 2000 bytes (take care on overflow) */</span>
res = f_lseek(file, file-&gt;fptr - 2000);
</pre>
<pre>
/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */
<span>/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */</span>
res = f_open(file, recfile, FA_CREATE_NEW | FA_WRITE); /* Create a file */
res = f_open(file, recfile, FA_CREATE_NEW | FA_WRITE); <span>/* Create a file */</span>
res = f_lseek(file, PRE_SIZE); /* Pre-allocate clusters */
if (res || file-&gt;fptr != PRE_SIZE) ... /* Check if the file size has been increased correctly */
res = f_lseek(file, PRE_SIZE); <span>/* Pre-allocate clusters */</span>
if (res || file-&gt;fptr != PRE_SIZE) ... <span>/* Check if the file size has been increased correctly */</span>
res = f_lseek(file, DATA_START); /* Record data stream without cluster allocation delay */
res = f_lseek(file, DATA_START); <span>/* Record data stream without cluster allocation delay */</span>
...
res = f_truncate(file); /* Truncate unused area */
res = f_lseek(file, 0); /* Put file header */
res = f_truncate(file); <span>/* Truncate unused area */</span>
res = f_lseek(file, 0); <span>/* Put file header */</span>
...
res = f_close(file);
</pre>
<pre>
<span>/* Using fast seek feature */</span>
DWORD lktbl[SZ_TBL]; <span>/* Link map table buffer */</span>
res = f_lseek(&amp;file, ofs1); <span>/* This is normal seek (file.cltbl == NULL on file open) */</span>
file.cltbl = lktbl; <span>/* Enable fast seek feature */</span>
lktbl[0] = SZ_TBL; <span>/* Set table size to the first item */</span>
res = f_lseek(&amp;file, CREATE_LINKMAP); <span>/* Create cluster link map table */</span>
...
res = f_lseek(&amp;file, ofs2); <span>/* This is fast seek (file.cltbl != NULL) */</span>
</pre>
</div>
+3 -2
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/mkdir.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_mkdir</title>
</head>
@@ -15,7 +16,7 @@
<p>The f_mkdir function creates a new directory.</p>
<pre>
FRESULT f_mkdir (
const XCHAR* <em>DirName</em> /* Pointer to the directory name */
const TCHAR* <em>DirName</em> <span>/* Pointer to the directory name */</span>
);
</pre>
</div>
@@ -55,7 +56,7 @@ FRESULT f_mkdir (
<dt>FR_NOT_ENABLED</dt>
<dd>The logical drive has no work area.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT volume on the disk.</dd>
<dd>There is no valid FAT volume on the drive.</dd>
</dl>
</div>
+8 -7
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/mkfs.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_mkfs</title>
</head>
@@ -15,9 +16,9 @@
<p>The f_mkfs fucntion creates a file system on the drive.</p>
<pre>
FRESULT f_mkfs (
BYTE <em>Drive</em>, /* Logical drive number */
BYTE <em>PartitioningRule</em>, /* Partitioning rule */
WORD <em>AllocSize</em> /* Size of the allocation unit */
BYTE <em>Drive</em>, <span>/* Logical drive number */</span>
BYTE <em>PartitioningRule</em>, <span>/* Partitioning rule */</span>
UINT <em>AllocSize</em> <span>/* Size of the allocation unit */</span>
);
</pre>
</div>
@@ -28,9 +29,9 @@ FRESULT f_mkfs (
<dt>Drive</dt>
<dd>Logical drive number (0-9) to be formatted.</dd>
<dt>PartitioningRule</dt>
<dd>When 0 is given, a partition table is created into the first sector on the drive and then the file system is created on the partition. This is called FDISK format and used for harddisk and memory card. When 1 is given, the file system starts from the first sector without partition table. This is often called super floppy disk (SFD) format and used for floppy disk and removable disk.</dd>
<dd>When 0 is given, a partition table is created into the master boot record and a primary DOS partition is created and then an FAT volume is created on the partition. This is called FDISK format and used for harddisk and memory cards. When 1 is given, the FAT volume starts from the first sector on the drive without partition table. This is called <abbr title="Super Floppy Disk">SFD</abbr> format and used for floppy disk and most optical disk.</dd>
<dt>AllocSize</dt>
<dd>Specifies allocation unit size in number of bytes per cluster. The value must be 0 or power of 2 in range of from 512 to 32768. When 0 is specified, the cluster size is determined depends on the volume size. FAT64 (64KB/cluster on FAT16) cannot be created by this function.</dd>
<dd>Force the allocation unit (cluter) size in unit of byte. The value must be power of 2 and between the sector size and 128 times sector size. When invalid value is specified, the cluster size is determined depends on the volume size.</dd>
</dl>
</div>
@@ -62,8 +63,8 @@ FRESULT f_mkfs (
<div class="para">
<h4>Description</h4>
<p>The f_mkfs function creates a FAT file system on the drive. There are two partitioning rules, FDISK and SFD, for removable media. It can be selected with an argument. The FDISK format is recommended for the most case. This function currently <em>does not support multiple partition</em>, so that existing partitions on the physical dirve will be deleted and re-created a new partition occupies entire disk space.</p>
<p>The FAT sub-type, FAT12/FAT16/FAT32, is determined by number of clusters on the drive 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>The f_mkfs function creates an FAT volume on the drive. There are two partitioning rules, FDISK and SFD, for removable media. The FDISK format is recommended for the most case. This function currently <em>does not support multiple partition</em>, so that existing partitions on the physical dirve will be deleted and re-created a new partition occupies entire disk space.</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>
</div>
+3 -2
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/mount.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_mount</title>
</head>
@@ -15,8 +16,8 @@
<p>The f_mount fucntion registers/unregisters a work area to the FatFs module.</p>
<pre>
FRESULT f_mount (
BYTE <em>Drive</em>, /* Logical drive number */
FATFS* <em>FileSystemObject</em> /* Pointer to the work area */
BYTE <em>Drive</em>, <span>/* Logical drive number */</span>
FATFS* <em>FileSystemObject</em> <span>/* Pointer to the work area */</span>
);
</pre>
</div>
+29 -25
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/open.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_open</title>
</head>
@@ -15,9 +16,9 @@
<p>The f_open function creates a <em>file object</em> to be used to access the file.</p>
<pre>
FRESULT f_open (
FIL* <em>FileObject</em>, /* Pointer to the blank file object structure */
const XCHAR* <em>FileName</em>, /* Pointer to the file neme */
BYTE <em>ModeFlags</em> /* Mode flags */
FIL* <em>FileObject</em>, <span>/* Pointer to the blank file object structure */</span>
const TCHAR* <em>FileName</em>, <span>/* Pointer to the file neme */</span>
BYTE <em>ModeFlags</em> <span>/* Mode flags */</span>
);
</pre>
</div>
@@ -36,7 +37,8 @@ FRESULT f_open (
<tr><td>FA_READ</td><td>Specifies read access to the object. Data can be read from the file.<br>Combine with FA_WRITE for read-write access.</td></tr>
<tr><td>FA_WRITE</td><td>Specifies write access to the object. Data can be written to the file.<br>Combine with FA_READ for read-write access.</td></tr>
<tr><td>FA_OPEN_EXISTING</td><td>Opens the file. The function fails if the file is not existing. (Default)</td></tr>
<tr><td>FA_OPEN_ALWAYS</td><td>Opens the file, if it is existing. If not, a new file is created.</td></tr>
<tr><td>FA_OPEN_ALWAYS</td><td>Opens the file if it is existing. If not, a new file is created.<br>
To append data to the file, use f_lseek function after file open in this method.</td></tr>
<tr><td>FA_CREATE_NEW</td><td>Creates a new file. The function fails if the file is already existing.</td></tr>
<tr><td>FA_CREATE_ALWAYS</td><td>Creates a new file. If the file is existing, it is truncated and overwritten.</td></tr>
</table>
@@ -62,9 +64,9 @@ FRESULT f_open (
<dd>The file is already existing.</dd>
<dt>FR_DENIED</dt>
<dd>The required access was denied due to one of the following reasons:
<ul><li>Write mode open of a read-only file.</li>
<li>File cannot be created due to a read-only file or same name directory is existing.</li>
<li>File cannot be created due to the directory table or disk is full.</li></ul></dd>
<ul><li>Write mode open against a read-only file.</li>
<li>File cannot be created due to a read-only file or same directory name is existing.</li>
<li>File cannot be created due to the directory table or volume is full.</li></ul></dd>
<dt>FR_NOT_READY</dt>
<dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd>
<dt>FR_WRITE_PROTECTED</dt>
@@ -76,21 +78,23 @@ FRESULT f_open (
<dt>FR_NOT_ENABLED</dt>
<dd>The logical drive has no work area.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT volume on the disk.</dd>
<dd>There is no valid FAT volume on the drive.</dd>
<dt>FR_LOCKED</dt>
<dd>The function was rejected due to file shareing policy.</dd>
</dl>
</div>
<div class="para">
<h4>Description</h4>
<p>A file object is created when the function succeeded. The file object is used for subsequent read/write functions to refer to the file. When close an open file object, use <a href="close.html">f_close</a> function. If the modified file is not closed, the file may be collapsed.</p>
<p>A file object is created when the function succeeded. The file object is used for subsequent read/write functions to refer to the file. When close an open file object, use <a href="close.html">f_close</a> function. If the modified file is not closed, the file data can be collapsed.</p>
<p>Before using any file function, a work area (file system object) must be given to the logical drive with <a href="mount.html">f_mount</a> function. All file functions can work after this procedure.</p>
</div>
<div class="para">
<h4>QuickInfo</h4>
<p>Always available. The mode flags, <tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>, are not available when <tt>_FS_READONLY == 1</tt>.</p>
<p>Always available. The mode flags, <tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW and FA_OPEN_ALWAYS</tt>, are not available when <tt>_FS_READONLY == 1</tt>.</p>
</div>
@@ -99,38 +103,38 @@ FRESULT f_open (
<pre>
void main (void)
{
FATFS fs[2]; /* Work area (file system object) for logical drives */
FIL fsrc, fdst; /* file objects */
BYTE buffer[4096]; /* file copy buffer */
FRESULT res; /* FatFs function common result code */
UINT br, bw; /* File R/W count */
FATFS fs[2]; <span>/* Work area (file system object) for logical drives */</span>
FIL fsrc, fdst; <span>/* file objects */</span>
BYTE buffer[4096]; <span>/* file copy buffer */</span>
FRESULT res; <span>/* FatFs function common result code */</span>
UINT br, bw; <span>/* File read/write count */</span>
/* Register work area for logical drives */
<span>/* Register work area for logical drives */</span>
f_mount(0, &amp;fs[0]);
f_mount(1, &amp;fs[1]);
/* Open source file on the drive 1 */
<span>/* Open source file on the drive 1 */</span>
res = f_open(&amp;fsrc, "1:srcfile.dat", FA_OPEN_EXISTING | FA_READ);
if (res) die(res);
/* Create destination file on the drive 0 */
<span>/* Create destination file on the drive 0 */</span>
res = f_open(&amp;fdst, "0:dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE);
if (res) die(res);
/* Copy source to destination */
<span>/* Copy source to destination */</span>
for (;;) {
res = f_read(&amp;fsrc, buffer, sizeof(buffer), &amp;br);
if (res || br == 0) break; /* error or eof */
res = f_write(&amp;fdst, buffer, br, &amp;bw);
if (res || bw &lt; br) break; /* error or disk full */
res = f_read(&amp;fsrc, buffer, sizeof(buffer), &amp;br); <span>/* Read a chunk of src file */</span>
if (res || br == 0) break; <span>/* error or eof */</span>
res = f_write(&amp;fdst, buffer, br, &amp;bw); <span>/* Write it to the dst file */</span>
if (res || bw &lt; br) break; <span>/* error or disk full */</span>
}
/* Close open files */
<span>/* Close open files */</span>
f_close(&amp;fsrc);
f_close(&amp;fdst);
/* Unregister work area prior to discard it */
<span>/* Unregister work area prior to discard it */</span>
f_mount(0, NULL);
f_mount(1, NULL);
}
+4 -3
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/opendir.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_opendir</title>
</head>
@@ -15,8 +16,8 @@
<p>The f_opendir function opens a directory.</p>
<pre>
FRESULT f_opendir (
DIR* <em>DirObject</em>, /* Pointer to the blank directory object structure */
const XCHAR* <em>DirName</em> /* Pointer to the directory name */
DIR* <em>DirObject</em>, <span>/* Pointer to the blank directory object structure */</span>
const TCHAR* <em>DirName</em> <span>/* Pointer to the directory name */</span>
);
</pre>
</div>
@@ -52,7 +53,7 @@ FRESULT f_opendir (
<dt>FR_NOT_ENABLED</dt>
<dd>The logical drive has no work area.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT volume on the disk.</dd>
<dd>There is no valid FAT volume on the drive.</dd>
</dl>
</div>
+15 -12
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/printf.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_printf</title>
</head>
@@ -15,8 +16,8 @@
<p>The f_printf function writes formatted string to the file.</p>
<pre>
int f_printf (
FIL* <em>FileObject</em>, /* File object */
const char* <em>Foramt</em>, /* Format stirng */
FIL* <em>FileObject</em>, <span>/* File object */</span>
const TCHAR* <em>Foramt</em>, <span>/* Format stirng */</span>
...
);
</pre>
@@ -28,7 +29,7 @@ int f_printf (
<dt>FileObject</dt>
<dd>Pointer to the open file object structure.</dd>
<dt>Format</dt>
<dd>Pointer to the null-terminated format string.</dd>
<dd>Pointer to the null terminated format string.</dd>
<dt>...</dt>
<dd>Optional arguments.</dd>
@@ -38,7 +39,7 @@ int f_printf (
<div class="para">
<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</tt> will be returned.</p>
<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>
</div>
@@ -46,8 +47,8 @@ int f_printf (
<h4>Description</h4>
<p>The f_printf() is a wrapper function of <a href="putc.html">f_putc()</a> and <a href="puts.html">f_puts()</a>. The format control directive is a sub-set of standard library shown as follos:</p>
<ul>
<li>Type: <tt>c s d u X</tt></li>
<li>Size: <tt>l</tt></li>
<li>Type: <tt>c C s S d D u U x X b B</tt></li>
<li>Size: <tt>l L</tt></li>
<li>Flag: <tt>0</tt></li>
</ul>
</div>
@@ -56,18 +57,20 @@ int f_printf (
<div class="para">
<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 characters are written to the file in UTF-8 encoding. If not the case, the byte characters will be written directly.</p>
</div>
<div class="para">
<h4>Example</h4>
<pre>
f_printf(&amp;fil, "%6d", -200); /* " -200" */
f_printf(&amp;fil, "%02u", 5); /* "05" */
f_printf(&amp;fil, "%ld", 12345678L); /* "12345678" */
f_printf(&amp;fil, "%08lX", 1194684UL); /* "00123ABC" */
f_printf(&amp;fil, "%s", "String"); /* "String" */
f_printf(&amp;fil, "%c", 'a'); /* "a" */
f_printf(&amp;fil, "%6d", -200); <span>/* " -200" */</span>
f_printf(&amp;fil, "%02u", 5); <span>/* "05" */</span>
f_printf(&amp;fil, "%ld", 12345678L); <span>/* "12345678" */</span>
f_printf(&amp;fil, "%08lX", 1194684UL); <span>/* "00123ABC" */</span>
f_printf(&amp;fil, "%08b", 0x55); <span>/* "01010101" */</span>
f_printf(&amp;fil, "%s", "String"); <span>/* "String" */</span>
f_printf(&amp;fil, "%c", 'a'); <span>/* "a" */</span>
</pre>
</div>
+5 -3
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/putc.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_putc</title>
</head>
@@ -15,8 +16,8 @@
<p>The f_putc funciton puts a character to the file.</p>
<pre>
int f_putc (
int <em>Chr</em>, /* A character to put */
FIL* <em>FileObject</em> /* File object */
TCHAR <em>Chr</em>, <span>/* A character to put */</span>
FIL* <em>FileObject</em> <span>/* File object */</span>
);
</pre>
</div>
@@ -34,7 +35,8 @@ int f_putc (
<div class="para">
<h4>Return Values</h4>
<p>When the character was written successfuly, the function returns the character. When the function failed due to disk full or any error, an <tt>EOF</tt> will be returned.</p>
<p>When the character was written successfuly, the function returns the character. 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>
</div>
+5 -3
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/puts.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_puts</title>
</head>
@@ -15,8 +16,8 @@
<p>The f_puts function writes a string to the file.</p>
<pre>
int f_puts (
const char* <em>Str</em>, /* String */
FIL* <em>FileObject</em> /* File object */
const TCHAR* <em>Str</em>, <span>/* String */</span>
FIL* <em>FileObject</em> <span>/* File object */</span>
);
</pre>
</div>
@@ -34,7 +35,8 @@ int f_puts (
<div class="para">
<h4>Return Value</h4>
<p>When the function succeeded, number of characters written that is not minus value is returned. When the function failed due to disk full or any error, an <tt>EOF</tt> will be returned.</p>
<p>When the function succeeded, number of characters written that is not minus value 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 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>
</div>
+6 -5
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/read.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_read</title>
</head>
@@ -15,10 +16,10 @@
<p>The f_read function reads data from a file.</p>
<pre>
FRESULT f_read (
FIL* <em>FileObject</em>, /* Pointer to the file object structure */
void* <em>Buffer</em>, /* Pointer to the buffer to store read data */
UINT <em>ByteToRead</em>, /* Number of bytes to read */
UINT* <em>ByteRead</em> /* Pointer to the variable to return number of bytes read */
FIL* <em>FileObject</em>, <span>/* Pointer to the file object structure */</span>
void* <em>Buffer</em>, <span>/* Pointer to the buffer to store read data */</span>
UINT <em>ByteToRead</em>, <span>/* Number of bytes to read */</span>
UINT* <em>ByteRead</em> <span>/* Pointer to the variable to return number of bytes read */</span>
);
</pre>
</div>
@@ -59,7 +60,7 @@ FRESULT f_read (
<div class="para">
<h4>Description</h4>
<p>The file pointer of the file object increases in number of bytes read. After the function succeeded, <tt>*ByteRead</tt> should be checked to detect the end of file. In case of <tt>*ByteRead &lt; ByteToRead</tt>, it means the R/W pointer reached end of the file during read operation.</p>
<p>The file pointer of the file object increases in number of bytes read. After the function succeeded, <tt>*ByteRead</tt> should be checked to detect the end of file. In case of <tt>*ByteRead &lt; ByteToRead</tt>, it means the read/write pointer reached end of the file during read operation.</p>
</div>
+3 -2
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/readdir.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_readdir</title>
</head>
@@ -15,8 +16,8 @@
<p>The f_readdir function reads directory entries.</p>
<pre>
FRESULT f_readdir (
DIR* <em>DirObject</em>, /* Pointer to the open directory object */
FILINFO* <em>FileInfo</em> /* Pointer to the file information structure */
DIR* <em>DirObject</em>, <span>/* Pointer to the open directory object */</span>
FILINFO* <em>FileInfo</em> <span>/* Pointer to the file information structure */</span>
);
</pre>
</div>
+8 -5
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/rename.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_rename</title>
</head>
@@ -15,8 +16,8 @@
<p>Renames an object.</p>
<pre>
FRESULT f_rename (
const XCHAR* <em>OldName</em>, /* Pointer to old object name */
const XCHAR* <em>NewName</em> /* Pointer to new object name */
const TCHAR* <em>OldName</em>, <span>/* Pointer to old object name */</span>
const TCHAR* <em>NewName</em> <span>/* Pointer to new object name */</span>
);
</pre>
</div>
@@ -60,7 +61,9 @@ FRESULT f_rename (
<dt>FR_NOT_ENABLED</dt>
<dd>The logical drive has no work area.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT volume on the disk.</dd>
<dd>There is no valid FAT volume on the drive.</dd>
<dt>FR_LOCKED</dt>
<dd>The function was rejected due to file shareing policy.</dd>
</dl>
</div>
@@ -80,10 +83,10 @@ FRESULT f_rename (
<div class="para">
<h4>Example</h4>
<pre>
/* Rename an object */
<span>/* Rename an object */</span>
f_rename("oldname.txt", "newname.txt");
/* Rename and move an object to other directory */
<span>/* Rename and move an object to other directory */</span>
f_rename("oldname.txt", "dir1/newname.txt");
</pre>
</div>
+12 -11
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/sdir.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - DIR</title>
</head>
@@ -14,18 +15,18 @@
<h2>DIR</h2>
<p>The <tt>DIR</tt> structure is used for the work area to read a directory by f_oepndir, f_readdir function. There is no member that can be changed by application.</p>
<pre>
typedef struct _DIR_ {
FATFS* fs; /* Pointer to the owner file system object */
WORD id; /* Owner file system mount ID */
WORD index; /* Current read/write index number */
DWORD sclust; /* Table start cluster (0:Static table) */
DWORD clust; /* Current cluster */
DWORD sect; /* Current sector */
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
typedef struct {
FATFS* fs; <span>/* Pointer to the owner file system object */</span>
WORD id; <span>/* Owner file system mount ID */</span>
WORD index; <span>/* Directory index number to be read/write next */</span>
DWORD sclust; <span>/* Table start cluster (0:Root dir) */</span>
DWORD clust; <span>/* Current cluster */</span>
DWORD sect; <span>/* Current sector */</span>
BYTE* dir; <span>/* Pointer to the current SFN entry in the win[] */</span>
BYTE* fn; <span>/* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */</span>
#if _USE_LFN
WCHAR* lfn; /* Pointer to the LFN working buffer */
WORD lfn_idx; /* Last matched LFN index (0xFFFF:No LFN) */
WCHAR* lfn; <span>/* Pointer to the LFN working buffer */</span>
WORD lfn_idx; <span>/* Last matched LFN index (0xFFFF:No LFN) */</span>
#endif
} DIR;
</pre>
+25 -24
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/sfatfs.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FATFS</title>
</head>
@@ -14,36 +15,36 @@
<h2>FATFS</h2>
<p>The <tt>FATFS</tt> structure holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with f_mount function. Following members are in standard configuration. There is no member that can be changed from the application program.</p>
<pre>
typedef struct _FATFS_ {
BYTE fs_type; /* FAT sub type */
BYTE drive; /* Physical drive number */
BYTE csize; /* Number of sectors per cluster */
BYTE n_fats; /* Number of FAT copies */
BYTE wflag; /* win[] dirty flag (1:must be written back) */
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
WORD id; /* File system mount ID */
WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */
#if _FS_REENTRANT
_SYNC_t sobj; /* Identifier of sync object */
#endif
typedef struct {
BYTE fs_type; <span>/* FAT sub-type (0:Not mounted) */</span>
BYTE drv; <span>/* Physical drive number */</span>
BYTE csize; <span>/* Sectors per cluster (1,2,4...128) */</span>
BYTE n_fats; <span>/* Number of FAT copies (1,2) */</span>
BYTE wflag; <span>/* win[] dirty flag */</span>
BYTE fsi_flag; <span>/* fsinfo dirty flag */</span>
WORD id; <span>/* File system mount ID */</span>
WORD n_rootdir; <span>/* Number of root directory entries (FAT12/16) */</span>
#if _MAX_SS != 512
WORD s_size; /* Sector size */
WORD ssize; <span>/* Sector size (512,1024,2048,4096) */</span>
#endif
#if _FS_REENTRANT
_SYNC_t sobj; <span>/* Identifier of sync object */</span>
#endif
#if !_FS_READONLY
DWORD last_clust; /* Last allocated cluster */
DWORD free_clust; /* Number of free clusters */
DWORD fsi_sector; /* fsinfo sector */
DWORD last_clust; <span>/* Last allocated cluster */</span>
DWORD free_clust; <span>/* Number of free clusters */</span>
DWORD fsi_sector; <span>/* fsinfo sector (FAT32) */</span>
#endif
#if _FS_RPATH
DWORD cdir; /* Current directory (0:root)*/
DWORD cdir; <span>/* Current directory cluster (0:root) */</span>
#endif
DWORD sects_fat; /* Sectors per fat */
DWORD max_clust; /* Maximum cluster# + 1. Number of clusters is max_clust - 2 */
DWORD fatbase; /* FAT start sector */
DWORD dirbase; /* Root directory start sector (Cluster# on FAT32) */
DWORD database; /* Data start sector */
DWORD winsect; /* Current sector appearing in the win[] */
BYTE win[_MAX_SS];/* Disk access window for Directory/FAT */
DWORD n_fatent; <span>/* Number of FAT entries (= number of clusters + 2) */</span>
DWORD fsize; <span>/* Sectors per FAT */</span>
DWORD fatbase; <span>/* FAT area start sector */</span>
DWORD dirbase; <span>/* Root directory area start sector (FAT32: cluster#) */</span>
DWORD database; <span>/* Data area start sector */</span>
DWORD winsect; <span>/* Current sector appearing in the win[] */</span>
BYTE win[_MAX_SS]; <span>/* Disk access window for Directory, FAT (and Data on tiny cfg) */</span>
} FATFS;
</pre>
</div>
+21 -14
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/sfile.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FIL</title>
</head>
@@ -12,25 +13,31 @@
<div class="para">
<h2>FIL</h2>
<p>The FIL structure (file object) holds state of an open file. It is initialzed by f_open function and discarded by f_close function. There is no member that can be changed by the application program.</p>
<p>The FIL structure (file object) holds state of an open file. It is created by f_open function and discarded by f_close function. There is no member that can be changed by the application program except for <tt>cltbl</tt>. Note that a sector buffer is defined in this structure under non-tiny configuration so that the FIL structures should not be defined as auto variable.</p>
<pre>
typedef struct _FIL_ {
FATFS* fs; /* Pointer to the owner file system object */
WORD id; /* Owner file system mount ID */
BYTE flag; /* File status flags */
BYTE csect; /* Sector address in the cluster */
DWORD fptr; /* File R/W pointer */
DWORD fsize; /* File size */
DWORD org_clust; /* File start cluster */
DWORD curr_clust; /* Current cluster */
DWORD dsect; /* Current data sector */
typedef struct {
FATFS* fs; <span>/* Pointer to the owner file system object */</span>
WORD id; <span>/* Owner file system mount ID */</span>
BYTE flag; <span>/* File status flags */</span>
BYTE pad1;
DWORD fptr; <span>/* File read/write pointer (Byte offset origin from top of the file) */</span>
DWORD fsize; <span>/* File size */</span>
DWORD org_clust; <span>/* File start cluster */</span>
DWORD curr_clust; <span>/* Current cluster */</span>
DWORD dsect; <span>/* Current data sector */</span>
#if !_FS_READONLY
DWORD dir_sect; /* Sector containing the directory entry */
BYTE* dir_ptr; /* Ponter to the directory entry in the window */
DWORD dir_sect; <span>/* Sector containing the directory entry */</span>
BYTE* dir_ptr; <span>/* Ponter to the directory entry in the window */</span>
#endif
#if _USE_FASTSEEK
DWORD* cltbl; <span>/* Pointer to the cluster link map table */</span>
#endif
#if _FS_SHARE
UINT lockid; <span>/* File lock ID */</span>
#endif
#if !_FS_TINY
BYTE buf[_MAX_SS];/* File R/W buffer */
BYTE buf[_MAX_SS]; <span>/* Data read/write buffer */</span>
#endif
} FIL;
</pre>
+9 -8
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/sfileinfo.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FILINFO</title>
</head>
@@ -14,15 +15,15 @@
<h2>FILINFO</h2>
<p>The <tt>FILINFO</tt> structure holds a file information returned by f_stat and f_readdir function.</p>
<pre>
typedef struct _FILINFO_ {
DWORD fsize; /* File size */
WORD fdate; /* Last modified date */
WORD ftime; /* Last modified time */
BYTE fattrib; /* Attribute */
char fname[13]; /* Short file name (8.3 format) */
typedef struct {
DWORD fsize; <span>/* File size */</span>
WORD fdate; <span>/* Last modified date */</span>
WORD ftime; <span>/* Last modified time */</span>
BYTE fattrib; <span>/* Attribute */</span>
TCHAR fname[13]; <span>/* Short file name (8.3 format) */</span>
#if _USE_LFN
XCHAR* lfname; /* Pointer to the LFN buffer */
int lfsize; /* Size of LFN buffer [characters] */
TCHAR* lfname; <span>/* Pointer to the LFN buffer */</span>
int lfsize; <span>/* Size of LFN buffer [characters] */</span>
#endif
} FILINFO;
</pre>
+4 -3
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/stat.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_stat</title>
</head>
@@ -15,8 +16,8 @@
<p>The f_stat gets the file status.</p>
<pre>
FRESULT f_stat (
const XCHAR* <em>FileName</em>, /* Pointer to the file or directory name */
FILINFO* <em>FileInfo</em> /* Pointer to the FILINFO structure */
const TCHAR* <em>FileName</em>, <span>/* Pointer to the file or directory name */</span>
FILINFO* <em>FileInfo</em> <span>/* Pointer to the FILINFO structure */</span>
);
</pre>
</div>
@@ -54,7 +55,7 @@ FRESULT f_stat (
<dt>FR_NOT_ENABLED</dt>
<dd>The logical drive has no work area.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT volume on the disk.</dd>
<dd>There is no valid FAT volume on the drive.</dd>
</dl>
</div>
+2 -1
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/sync.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_sync</title>
</head>
@@ -15,7 +16,7 @@
<p>The f_sync function flushes the cached information of a writing file.</p>
<pre>
FRESULT f_sync (
FIL* <em>FileObject</em> /* Pointer to the file object */
FIL* <em>FileObject</em> <span>/* Pointer to the file object */</span>
);
</pre>
</div>
+2 -1
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/truncate.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_truncate</title>
</head>
@@ -15,7 +16,7 @@
<p>The f_truncate function truncates the file size.</p>
<pre>
FRESULT f_truncate (
FIL* <em>FileObject</em> /* Pointer to the file object */
FIL* <em>FileObject</em> <span>/* Pointer to the file object */</span>
);
</pre>
</div>
+5 -2
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/unlink.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_unlink</title>
</head>
@@ -15,7 +16,7 @@
<p>The f_unlink removes an object.</p>
<pre>
FRESULT f_unlink (
const XCHAR* <em>FileName</em> /* Pointer to the object name */
const TCHAR* <em>FileName</em> <span>/* Pointer to the object name */</span>
);
</pre>
</div>
@@ -56,7 +57,9 @@ FRESULT f_unlink (
<dt>FR_NOT_ENABLED</dt>
<dd>The logical drive has no work area.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT volume on the disk.</dd>
<dd>There is no valid FAT volume on the drive.</dd>
<dt>FR_LOCKED</dt>
<dd>The function was rejected due to file shareing policy.</dd>
</dl>
</div>
+28 -3
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/utime.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_utime</title>
</head>
@@ -15,8 +16,8 @@
<p>The f_utime function changes the timestamp of a file or directory.</p>
<pre>
FRESULT f_utime (
const XCHAR* <em>FileName</em>, /* Pointer to the file or directory path */
const FILINFO* <em>TimeDate</em> /* Time and data to be set */
const TCHAR* <em>FileName</em>, <span>/* Pointer to the file or directory path */</span>
const FILINFO* <em>TimeDate</em> <span>/* Time and data to be set */</span>
);
</pre>
</div>
@@ -56,7 +57,7 @@ FRESULT f_utime (
<dt>FR_NOT_ENABLED</dt>
<dd>The logical drive has no work area.</dd>
<dt>FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT volume on the disk.</dd>
<dd>There is no valid FAT volume on the drive.</dd>
</dl>
</div>
@@ -67,6 +68,30 @@ FRESULT f_utime (
</div>
<div class="para">
<h4>Example</h4>
<pre>
FRESULT set_timestamp (
char *obj, <span>/* Pointer to the file name */</span>
int year,
int month,
int mday,
int hour,
int min,
int sec
)
{
FILINFO fno;
fno.fdate = (WORD)(((year - 1980) * 512U) | month * 32U | mday);
fno.ftime = (WORD)(hour * 2048U | min * 32U | sec / 2U);
return f_utime(obj, &fno);
}
</pre>
</div>
<div class="para">
<h4>QuickInfo</h4>
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
+6 -5
View File
@@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/write.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_write</title>
</head>
@@ -15,10 +16,10 @@
<p>The f_write writes data to a file.</p>
<pre>
FRESULT f_write (
FIL* <em>FileObject</em>, /* Pointer to the file object structure */
const void* <em>Buffer</em>, /* Pointer to the data to be written */
UINT <em>ByteToWrite</em>, /* Number of bytes to write */
UINT* <em>ByteWritten</em> /* Pointer to the variable to return number of bytes written */
FIL* <em>FileObject</em>, <span>/* Pointer to the file object structure */</span>
const void* <em>Buffer</em>, <span>/* Pointer to the data to be written */</span>
UINT <em>ByteToWrite</em>, <span>/* Number of bytes to write */</span>
UINT* <em>ByteWritten</em> <span>/* Pointer to the variable to return number of bytes written */</span>
);
</pre>
</div>
@@ -59,7 +60,7 @@ FRESULT f_write (
<div class="para">
<h4>Description</h4>
<p>The R/W pointer in the file object is increased in number of bytes written. After the function succeeded, <tt>*ByteWritten</tt> should be checked to detect the disk full. In case of <tt>*ByteWritten &lt; ByteToWrite</tt>, it means the volume got full during the write operation.</p>
<p>The read/write pointer in the file object is increased in number of bytes written. After the function succeeded, <tt>*ByteWritten</tt> should be checked to detect the disk full. In case of <tt>*ByteWritten &lt; ByteToWrite</tt>, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.</p>
</div>