fatfs v0.15a November 22, 2024:

- Fixed a complie error when FF_FS_LOCK != 0.
- Fixed a potential issue when work FatFs concurrency with FF_FS_REENTRANT, FF_VOLUMES >= 2 and FF_FS_LOCK > 0.
- Made f_setlabel() accept a volume label in Unix style volume ID when FF_STR_VOLUME_ID == 2.
- Made FatFs update PercInUse field in exFAT VBR. (A preceding f_getfree() is needed for the accuracy)
This commit is contained in:
savelij13 2025-09-11 10:49:22 +03:00
parent ba3f5b7f87
commit 47e601681a
58 changed files with 671 additions and 666 deletions

View File

@ -17,7 +17,7 @@
<div class="abst">
<img src="res/layers.png" class="rset" width="245" height="255" alt="layer">
<p>FatFs is a generic FAT/exFAT filesystem module for small embedded systems. The FatFs module is written in compliance with ANSI C (C89) and completely separated from the disk I/O layer. Therefore it is independent of the platform. It can be incorporated into small microcontrollers with limited resource, such as 8051, PIC, AVR, ARM, Z80, RX and etc. Also Petit FatFs module for tiny microcontrollers is available <a href="http://elm-chan.org/fsw/ff/00index_p.html">here</a>.</p>
<p>FatFs is a generic FAT/exFAT filesystem module for small embedded systems. The FatFs module is written in compliance with ANSI C (C89) and completely separated from the disk control layer. Therefore it is independent of the platforms and storage devices. It can be incorporated into small microcontrollers with limited resource, such as 8051, PIC, AVR, ARM, Z80, RX and etc. Also Petit FatFs module for tiny microcontrollers is available <a href="http://elm-chan.org/fsw/ff/00index_p.html">here</a>.</p>
<h4>Features</h4>
<ul>
@ -105,7 +105,7 @@
<div class="para">
<h3>Media Access Interface</h3>
<img src="res/layers2.png" class="rset" width="245" height="220" alt="layer">
<p>Since FatFs module is the <em>Filesystem Layer</em> independent of platforms and storage media, it is completely separated from the physical devices, such as memory card, harddisk and any type of storage device. The storage device control module is <em>not any part of FatFs module</em> and it needs to be provided by implementer. FatFs controls the storage devices via a simple media access interface shown below. Also sample implementations for some platforms are available in the downloads. A function checker for storage device control module is available <a href="res/app4.c">here</a>.</p>
<p>Since FatFs module is the <em>Filesystem Layer</em> independent of platforms and storage media, it is completely separated from the physical devices, such as memory card, harddisk and any type of storage device. The storage device control module is <em>not a part of FatFs module</em> and it needs to be provided by implementer. FatFs controls the storage devices via a simple media access interface shown below. Also sample implementations for some platforms are available in the downloads. A function checker for storage device control module is available <a href="res/app4.c">here</a>.</p>
<ul>
<li>Storage Device Controls
<ul>
@ -130,20 +130,17 @@
<p>The FatFs module is a free software opened for education, research and development. You can use, modify and/or redistribute it for any purpose without any restriction under your responsibility. For further information, refer to the application note.</p>
<ul>
<li><em>Getting Started: <a href="doc/appnote.html">FatFs Application Note</a></em></li>
<li>Community: <a href="http://elm-chan.org/fsw/ff/bd/">FatFs User Forum</a></li>
<li><a href="https://msdn.microsoft.com/en-us/windows/hardware/gg463080.aspx">FAT32 Specification by Microsoft</a>↗ (The authorized document on FAT filesystem)</li>
<li><a href="https://msdn.microsoft.com/en-us/windows/hardware/gg463080.aspx">FAT32 Specification by Microsoft</a> (The authorized document on FAT filesystem)</li>
<li><a href="http://elm-chan.org/docs/fat_e.html">The basics of FAT filesystem</a> (FatFs is written based on this documentation)</li>
<li><a href="http://elm-chan.org/docs/exfat_e.html">The basics of exFAT filesystem</a> (FatFs is written based on this documentation)</li>
<li><a href="http://elm-chan.org/docs/mmc/mmc_e.html">How to use MMC/SDC</a></li>
<li><a href="http://elm-chan.org/junk/fa/faff.html">Playing with FlashAir and FatFs</a></li>
<li><a href="http://nemuisan.blog.bai.ne.jp/">Nemuisan's Blog</a>↗ (Well written implementations for STM32F/SPI &amp; SDIO and LPC4088/SDMMC)</li>
<li><a href="http://stm32f4-discovery.net/2014/07/library-21-read-sd-card-fatfs-stm32f4xx-devices/">Read SD card with FatFs on STM32F4xx devices by Tilen Majerle</a>↗ (Quick and easy implementation for STM32F4-Discovery)</li>
<li><a href="res/rwtest1.png">Benchmark 1</a> (ATmega1284/20MHz with MMC via USART in SPI, CFC via GPIO)</li>
<li><a href="res/rwtest2.png">Benchmark 2</a> (LPC2368/72MHz with MMC via MCI)</li>
<li><a href="http://nemuisan.blog.bai.ne.jp/">Nemuisan's Blog</a> (Well written implementations for STM32F/SPI &amp; SDIO and LPC4088/SDMMC)</li>
<li><a href="http://stm32f4-discovery.net/2014/07/library-21-read-sd-card-fatfs-stm32f4xx-devices/">Read SD card with FatFs on STM32F4xx devices by Tilen Majerle</a> (Quick and easy implementation for STM32F4-Discovery)</li>
</div>
<hr>
<p class="foot"><a href="../../fsw_e.html">Return</a></p>
<p class="foot"><a href="http://elm-chan.org/fsw/ff/">Go to FatFs Home Page</a></p>
</body>
</html>

View File

@ -38,6 +38,7 @@ div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;
ul.flat li {list-style-type: none; margin: 0;}
a.imglnk img {border: 1px solid;}
.iequ {white-space: nowrap; font-weight: bold;}
.lnk {opacity: 0.5;}
.clr {clear: both;}
.it {font-style: italic;}
.mfd {font-size: 0.7em; padding: 0 1px; border: 1px solid; white-space : nowrap}

View File

@ -3,8 +3,6 @@
<head>
<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/appnote.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs Module Application Note</title>
</head>
@ -171,8 +169,8 @@ And any other options are left unchanged from original setting.
<div class="para doc" id="lfn">
<h3>Long File Name</h3>
<p>FatFs module supports the long file name (LFN) extension of the FAT filesystem. The two different file names, short file name (SFN) and LFN, of a file is transparent on the API. The support for LFN feature is disabled by default. To enable the LFN, set <tt><a href="config.html#use_lfn">FF_USE_LFN</a></tt> to 1, 2 or 3, and add <tt>ffunicode.c</tt> to the project. The LFN feature requiers a certain working buffer. The buffer size can be configured by <tt><a href="config.html#max_lfn">FF_MAX_LFN</a></tt> according to the available memory. The length of LFN can be up to 255 characters, so that the <tt>FF_MAX_LFN</tt> should be set to 255 for any existing file names. If the size of working buffer is insufficient for the input file name, the file function fails with <tt>FR_INVALID_NAME</tt>. When use any re-entry to the API with LFN feature in RTOS environment, <tt>FF_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 LFN working buffer occupies <tt>(FF_MAX_LFN + 1) * 2</tt> bytes and additional <tt>(FF_MAX_LFN + 44) / 15 * 32</tt> bytes when exFAT is enabled.</p>
<h4>Impact upon Module Size</h4>
<p>FatFs module supports the long file name (LFN) extension of the FAT filesystem. The two different file names, short file name (SFN) and LFN, of a file are transparent on the API. The support for LFN feature is disabled by default. To enable the LFN, set <tt><a href="config.html#use_lfn">FF_USE_LFN</a></tt> to 1, 2 or 3, and add <tt>ffunicode.c</tt> to the project. The LFN feature requiers a certain working buffer. The buffer size can be configured by <tt><a href="config.html#max_lfn">FF_MAX_LFN</a></tt> according to the available memory. The LFN specification allows the length of LFN up to 255 characters, so that the <tt>FF_MAX_LFN</tt> should be set to 255 for every existing file name. If the size of working buffer is insufficient for the input file name, the file function fails with <tt>FR_INVALID_NAME</tt>. When use any re-entry to the file API with LFN feature in RTOS environment, <tt>FF_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 LFN working buffer occupies <tt>(FF_MAX_LFN + 1) * 2</tt> bytes and additional <tt>(FF_MAX_LFN + 44) / 15 * 32</tt> bytes when exFAT is enabled.</p>
<h4>Code Page and Module Size</h4>
<table class="lst2 rset">
<caption>With LFN at CM3 + gcc</caption>
<tr><th><tt>FF_CODE_PAGE</tt></th><th>Code size</th></tr>
@ -184,8 +182,8 @@ And any other options are left unchanged from original setting.
<tr><td>0 (All code pages)</td><td>+486k</td></tr>
</table>
<p>When the LFN is enabled, the module size will be increased depends on the configured code page. Right table shows the increment of code size in some code pages. Especially, in the CJK region, tens of thousands of characters are being used. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased as shown in the table.</p>
<p>As the result, the FatFs with LFN enabled with DBCS code pages will not able to be ported on the most 8-bit MCU systems. If the target system is in legacy-free, in only Unicode and any ANSI/OEM code is not used at all, the code page setting gets meaningless. You will able to reduce the code size by configureing FatFs for Unicode API with any SBCS code page.</p>
<p>There ware some restrictions on using LFN for open source project, because the LFN extension on the FAT filesystem was a patent of Microsoft Corporation. However the related patents all have expired and using the LFN feature is free for any projects.</p>
<p>As the result, the FatFs with LFN enabled with DBCS code pages will not able to be ported on the most 8-bit MCU systems. If the target system is in legacy-free, in only Unicode and any ANSI/OEM code is not used at all, the code page setting is meaningless. You will able to reduce the code size by configureing FatFs for Unicode API with some SBCS code page.</p>
<p>There ware some restrictions on using the LFN in open source project, because the LFN extension on the FAT filesystem was a patent of Microsoft Corporation. However the related patents all have expired and using the LFN feature is free for any project.</p>
</div>
<div class="para doc" id="unicode">
@ -334,6 +332,7 @@ Figure 5. Minimized critical section<br>
<p>Therefore FatFs license is one of the BSD-style licenses but there is a significant feature. FatFs is mainly intended for embedded systems. In order to extend the usability for commercial products, the redistributions of FatFs in binary form, such as embedded code, binary library and any forms without source code, does not need to include about FatFs in the documentations. This is equivalent to the 1-clause BSD license. Of course FatFs is compatible with the most of open source software licenses includes GNU GPL. When you redistribute the FatFs source code with any changes or create a fork, the license can also be changed to GNU GPL, BSD-style license or any open source software license that compatible with FatFs license.</p>
</div>
<p class="foot"><a href="../00index_e.html">Return Home</a></p>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/chdir.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_chdir</title>
</head>
@ -83,6 +81,7 @@ FRESULT f_chdir (
<p><tt><a href="chdrive.html">f_chdrive</a>, <a href="getcwd.html">f_getcwd</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/chdrive.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_chdrive</title>
</head>
@ -65,6 +63,7 @@ FRESULT f_chdrive (
<p><tt><a href="chdir.html">f_chdir</a>, <a href="getcwd.html">f_getcwd</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/chmod.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_chmod</title>
</head>
@ -84,6 +82,7 @@ FRESULT f_chmod (
</pre>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/close.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_close</title>
</head>
@ -60,6 +58,7 @@ FRESULT f_close (
<p><tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="write.html">f_write</a>, <a href="sync.html">f_sync</a>, <a href="sfile.html">FIL</a>, <a href="sfatfs.html">FATFS</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/close.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_closedir</title>
</head>
@ -59,6 +57,7 @@ FRESULT f_closedir (
<p><tt><a href="opendir.html">f_opendir</a>, <a href="readdir.html">f_readdir</a>, <a href="sdir.html">DIR</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/config.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - Configuration Options</title>
</head>
@ -105,29 +103,29 @@
<p>Disable (0) or Enable (1) <tt>f_forward</tt> function.</p>
<h4 id="use_strfunc">FF_USE_STRFUNC</h4>
<p>This option switches string functions, <tt>f_gets</tt>, <tt>f_putc</tt>, <tt>f_puts</tt> and <tt>f_printf</tt>. These functions are equivalents of regular string stream I/O functions in POSIX. If <tt>sprintf</tt> is available and code conversion is not needed, <tt>f_write</tt> with <tt>sprintf</tt> will be efficient in code size and performance rather than <tt>f_printf</tt>. When enable this feature, <tt>stdarg.h</tt> is included in <tt>ff.c</tt>.</p>
<p>This option switches string I/O functions, <tt>f_gets</tt>, <tt>f_putc</tt>, <tt>f_puts</tt> and <tt>f_printf</tt>. These functions are the equivalents of regular string stream I/O functions in POSIX. If <tt>sprintf</tt> is available and code conversion is not needed, <tt>f_write</tt> with <tt>sprintf</tt> will be efficient in code size and performance better than <tt>f_printf</tt>. When enable this feature, <tt>stdarg.h</tt> is included in <tt>ff.c</tt>.</p>
<table class="lst1">
<tr><th>Value</th><th>Description</th></tr>
<tr><td>0</td><td>Disable string functions.</td></tr>
<tr><td>1</td><td>Enable string functions without LF-CRLF conversion.</td></tr>
<tr><td>2</td><td>Enable string functions with LF-CRLF conversion.</td></tr>
<tr><td>1</td><td>Enable string functions without LF - CRLF conversion.</td></tr>
<tr><td>2</td><td>Enable string functions with LF - CRLF conversion.</td></tr>
</table>
<h4 id="print_lli">FF_PRINT_LLI</h4>
<p>This option switches support for long long integer argument in <tt>f_printf</tt>.</p>
<p>Disable (0) or Enable (1). When enable this feature, C standard needs to be C99 or later.</p>
<p>Disable (0) or Enable (1). When enable this feature, C standard needs to be C99 or later. This option has no effect when <tt>FF_USE_STRFUNC == 0</tt>.</p>
<h4 id="print_fp">FF_PRINT_FLOAT</h4>
<p>This option switches support for floating point argument in <tt>f_printf</tt>. When enable this feature, C standard needs to be C99 or later and <tt>math.h</tt> is included in <tt>ff.c</tt>.</p>
<p>This option switches support for floating point argument in <tt>f_printf</tt>. When enable this feature, C standard needs to be C99 or later and <tt>math.h</tt> is included in <tt>ff.c</tt>. This option has no effect when <tt>FF_USE_STRFUNC == 0</tt>.</p>
<table class="lst1">
<tr><th>Value</th><th>Description</th></tr>
<tr><td>0</td><td>Disable floating point argument.</td></tr>
<tr><td>1</td><td>Enable floating point argument in type <tt>'f'</tt>, <tt>'e'</tt> and <tt>'E'</tt>.</td></tr>
<tr><td>2</td><td>Enable it with decimal separator <tt>','</tt> instead of <tt>'.'</tt>.</td></tr>
<tr><td>2</td><td>Same as 1 but with decimal separator <tt>','</tt> instead of <tt>'.'</tt> in output string.</td></tr>
</table>
<h4 id="strf_encode">FF_STRF_ENCODE</h4>
<p>When character encoding on the API is Unicode (<tt>FF_LFN_UNICODE &gt;= 1</tt>), string I/O functions enabled by <tt>FF_USE_STRFUNC</tt> convert the character encoding in it. This option defines the assumption of character encoding <em>on the file</em> to be read/written via those functions. When LFN is not enabled or <tt>FF_LFN_UNICODE == 0</tt>, the string functions work without any code conversion and this option has no effect.</p>
<p>When the character encoding on the API is Unicode (<tt>FF_LFN_UNICODE &gt;= 1</tt>), string I/O functions enabled by <tt>FF_USE_STRFUNC</tt> convert the character encoding in it. This option defines the assumption of character encoding <em>on the file</em> to be read/written via the string I/O functions. When LFN is not enabled or <tt>FF_LFN_UNICODE == 0</tt>, the string I/O functions work without any code conversion and this option has no effect.</p>
<table class="lst2">
<tr><th>Value</th><th>Character encoding on the file</th></tr>
<tr><td>0</td><td>ANSI/OEM in current code page</td></tr>
@ -228,9 +226,9 @@
<p>This option switches the support for string volume ID. When arbitrary string for the volume ID is enabled for the drive prefix, also pre-defined strings by <tt>FF_VOLUME_STRS</tt> or user defined strings can be used as drive prefix in the path name. Numeric drive number is always valid regardless of this option, and also either format of drive prefix can be enabled by this option.</p>
<table class="lst2">
<tr><th>Value</th><th>Description</th><th>Example</th></tr>
<tr><td>0</td><td>Only DOS/Windows style drive prefix in numeric ID can be used.</td><td>1:/filename</td></tr>
<tr><td>1</td><td>Also DOS/Windows style drive prefix in string ID can be used.</td><td>flash:/filename</td></tr>
<tr><td>2</td><td>Also Unix style drive prefix in string ID can be used.</td><td>/flash/filename</td></tr>
<tr><td>0</td><td>DOS/Windows style drive prefix in numeric ID.</td><td>1:/filename</td></tr>
<tr><td>1</td><td>0 + DOS/Windows style drive prefix in arbitry string ID.</td><td>flash:/filename</td></tr>
<tr><td>2</td><td>0 + Unix style drive prefix in arbitry string ID.</td><td>/flash/filename</td></tr>
</table>
<h4 id="volume_strs">FF_VOLUME_STRS</h4>
@ -241,7 +239,7 @@ const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb"};
</pre>
<h4 id="multi_partition">FF_MULTI_PARTITION</h4>
<p>Disable (0) or Enable (1). This option switches multi-partition function. By default (0), each logical drive number is bound to the same physical drive number and only a volume in the physical drive is mounted. When enabled, each logical drive is bound to the partition on the physical drive listed in the user defined partition resolution table <tt>VolToPart[]</tt>. Also <tt>f_fdisk</tt> funciton will be available. For more information, read <a href="filename.html#vol">here</a>.</p>
<p>This option switches multi-partition featuer. By default (0), each logical drive number is bound to the same physical drive number and only one volume found in the physical drive is mounted. When it is enabled (1), each logical drive is bound to the specific partition listed in the user defined partition resolution table <tt>VolToPart[]</tt>. Also <tt>f_fdisk</tt> funciton is available to create the arbitrary partitions on the physical drive. For more information, read <a href="filename.html#vol">here</a>.</p>
<h4 id="max_ss">FF_MIN_SS, FF_MAX_SS</h4>
<p>This set of options defines the extent of sector size used for the low level disk I/O interface, <tt>disk_read</tt> and <tt>disk_write</tt> function. Valid values are 512, 1024, 2048 and 4096. <tt>FF_MIN_SS</tt> defines minimum sector size and <tt>FF_MAX_SS</tt> defines the maximum sector size. Always set both 512 for memory card and harddisk. But a larger value may be required for on-board flash memory and some type of optical media. When <tt>FF_MAX_SS &gt; FF_MIN_SS</tt>, support of variable sector size is enabled and <tt>GET_SECTOR_SIZE</tt> command needs to be implemented to the <tt>disk_ioctl</tt> function.</p>
@ -299,6 +297,7 @@ const char* VolumeStr[FF_VOLUMES] = {"ram","flash","sd","usb"};
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/dinit.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_initialize</title>
</head>
@ -41,6 +39,7 @@ DSTATUS disk_initialize (
<p><em>Remarks: This function needs to be under control of FatFs module. Application program MUST NOT call this function while FatFs is in use, or FAT structure on the volume can be broken. To re-initialize the filesystem, use <tt>f_mount</tt> function instead.</em></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/dioctl.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_ioctl</title>
</head>
@ -58,8 +56,8 @@ DRESULT disk_ioctl (
<caption>Standard ioctl command used by FatFs</caption>
<tr><th>Command</th><th>Description</th></tr>
<tr><td>CTRL_SYNC</td><td>Makes sure that the device has finished pending write process. If the disk I/O layer or storage device has a write-back cache, the dirty cache data must be committed to the medium immediately. Nothing to do for this command if each write operation to the medium is completed in the <tt>disk_write</tt> function.</td></tr>
<tr><td>GET_SECTOR_COUNT</td><td>Retrieves number of available sectors, the largest allowable LBA + 1, on the drive into the <tt>LBA_t</tt> variable that pointed by <tt class="arg">buff</tt>. This command is used by <tt>f_mkfs</tt> and <tt>f_fdisk</tt> function to determine the size of volume/partition to be created.</td></tr>
<tr><td>GET_SECTOR_SIZE</td><td>Retrieves sector size, minimum data unit for generic read/write, into the <tt>WORD</tt> variable that pointed by <tt class="arg">buff</tt>. Valid sector sizes are 512, 1024, 2048 and 4096. This command is required only if <tt>FF_MAX_SS &gt; FF_MIN_SS</tt>. When <tt>FF_MAX_SS == FF_MIN_SS</tt>, this command will never be used and the <tt>disk_read</tt> and <tt>disk_write</tt> function must work in <tt>FF_MAX_SS</tt> bytes/sector.</td></tr>
<tr><td>GET_SECTOR_COUNT</td><td>Retrieves number of available sectors (the largest allowable LBA + 1) on the drive into the <tt>LBA_t</tt> variable that pointed by <tt class="arg">buff</tt>. This command is used by <tt>f_mkfs</tt> and <tt>f_fdisk</tt> function to determine the size of volume/partition to be created.</td></tr>
<tr><td>GET_SECTOR_SIZE</td><td>Retrieves sector size (minimum data unit for generic read/write) into the <tt>WORD</tt> variable that pointed by <tt class="arg">buff</tt>. Valid sector sizes are 512, 1024, 2048 and 4096. This command is required only if <tt>FF_MAX_SS &gt; FF_MIN_SS</tt>. When <tt>FF_MAX_SS == FF_MIN_SS</tt>, this command will never be used and the <tt>disk_read</tt> and <tt>disk_write</tt> function must work in <tt>FF_MAX_SS</tt> bytes/sector.</td></tr>
<tr><td>GET_BLOCK_SIZE</td><td>Retrieves <em>erase block size in unit of sector</em> of the flash memory media into the <tt>DWORD</tt> variable that pointed by <tt class="arg">buff</tt>. The allowable value is 1 to 32768 in power of 2. Return 1 if it is unknown or in non flash memory media. This command is used by <tt>f_mkfs</tt> function with block size not specified and it attempts to align the data area on the suggested block boundary. Note that FatFs does not have FTL (flash translation layer), so that either disk I/O layter or storage device must have an FTL in it.</td></tr>
<tr><td>CTRL_TRIM</td><td>Informs the disk I/O layter or the storage device that the data on the block of sectors is no longer needed and it can be erased. The sector block is specified in an <tt>LBA_t</tt> array <tt>{&lt;Start LBA&gt;, &lt;End LBA&gt;}</tt> that pointed by <tt class="arg">buff</tt>. This is an identical command to Trim of ATA device. Nothing to do for this command if this funcion is not supported or not a flash memory device. FatFs does not check the result code and the file function is not affected even if the sector block was not erased well. This command is called on remove a cluster chain and in the <tt>f_mkfs</tt> function. It is required when <tt>FF_USE_TRIM == 1</tt>.</td></tr>
</table>

View File

@ -3,8 +3,6 @@
<head>
<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/dread.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_read</title>
</head>

View File

@ -3,8 +3,6 @@
<head>
<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/dstat.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_status</title>
</head>
@ -43,6 +41,7 @@ DSTATUS disk_status (
</dl>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/dwrite.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_write</title>
</head>
@ -60,7 +58,7 @@ DRESULT disk_write (
<h4>Description</h4>
<p>The specified memory address is not that always aligned to word boundary because the argument is defined as <tt>BYTE*</tt>. For more information, refer to the description of <a href="dread.html"><tt>disk_read</tt></a> function.</p>
<p>Generally, a multiple sector write request (<tt class="arg">count</tt><tt> &gt; 1</tt>) must not be split into single sector transactions to the storage device, or the file write throughput will be drastically decreased.</p>
<p>FatFs expects delayed write function of the disk control layer. The write operation to the media does not need to be completed when return from this function by what write operation is in progress or data is only stored into the write-back cache. But write data on the <tt class="arg">buff</tt> is invalid after return from this function. The write completion request is done by <tt>CTRL_SYNC</tt> command of <tt><a href="dioctl.html">disk_ioctl</a></tt> function. Therefore, if a delayed write function is implemented, the write throughput of the filesystem will be improved.</p>
<p>FatFs expects delayed write function in the disk control layer. The write operation to the media does not need to be completed when return from this function by what write operation is in progress or data is only stored into the write-back cache. The write data on the <tt class="arg">buff</tt> is invalid after return from this function. The write completion request is done by <tt>CTRL_SYNC</tt> command of <tt><a href="dioctl.html">disk_ioctl</a></tt> function. Therefore, if a delayed write function is implemented, the write throughput of the filesystem will be improved.</p>
<p><em>Remarks: Application program MUST NOT call this function, or FAT structure on the volume can be collapsed.</em></p>
</div>

View File

@ -3,8 +3,6 @@
<head>
<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/eof.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_eof</title>
</head>
@ -57,6 +55,7 @@ int f_eof (
<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/error.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_error</title>
</head>
@ -57,6 +55,7 @@ int f_error (
<p><tt><a href="open.html">f_open</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/lseek.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_expand</title>
</head>
@ -28,7 +26,7 @@ FRESULT f_expand (
<h4>Parameters</h4>
<dl class="par">
<dt>fp</dt>
<dd>Pointer to the open file object.</dd>
<dd>Pointer to the open file object. If a null pointer is given, the function fails with <tt>FR_INVALID_OBJECT</tt>.</dd>
<dt>fsz</dt>
<dd>Number of bytes in size to prepare or allocate for the file. The data type <tt>FSIZE_t</tt> is an alias of either <tt>DWORD</tt>(32-bit) or <tt>QWORD</tt>(64-bit) depends on the configuration option <tt>FF_FS_EXFAT</tt>.</dd>
<dt>opt</dt>
@ -61,7 +59,7 @@ FRESULT f_expand (
</ul>
<p>When <tt class="arg">opt</tt> is 0, the function finds a contiguous data area and set it as suggested point for next allocation. The subsequent cluster allocation begins at top of the contiguous area found by this function. Thus the file allocation is guaranteed be contiguous and without allocation delay until the file size reaches this size unless any other changes to the volume is performed.</p>
<p>The contiguous file has an advantage for time-critical read/write operations. It eliminates some overheads in the filesystem and the storage device caused by random access for fragmented file.</p>
<p>Also the contiguous file can be easily accessed directly via low-level disk functions. However, this is not recommended in consideration of portability and future compatibility. If the file has not been confirmed be contiguous, use <a href="../res/app5.c">this function</a> to examine if the file is contiguous or not.</p>
<p>The contiguou files can easily be accessed via low-level disk functions. However, this is not recommended in consideration of portability and future compatibility. If the file has not been confirmed be contiguous, use <a href="../res/app5.c">this function</a> to examine if the file is contiguous or not.</p>
</div>
<div class="para comp">
@ -76,16 +74,16 @@ FRESULT f_expand (
<span class="c">/* Creating a contiguous file */</span>
<span class="c">/* Create a new file */</span>
res = f_open(fp = malloc(sizeof (FIL)), "file.dat", FA_WRITE|FA_CREATE_ALWAYS);
res = <em>f_open</em>(fp = malloc(sizeof (FIL)), "file.dat", FA_WRITE|FA_CREATE_ALWAYS);
if (res) { <span class="c">/* Check if the file has been opened */</span>
free(fp);
die("Failed to open the file.");
}
<span class="c">/* Alloacte a 100 MiB of contiguous area to the file */</span>
<span class="c">/* Allocate a 100 MiB of contiguous area to the file */</span>
res = <em>f_expand</em>(fp, 104857600, 1);
if (res) { <span class="c">/* Check if the file has been expanded */</span>
f_close(fp);
<em>f_close</em>(fp);
free(fp);
die("Failed to allocate contiguous area.");
}
@ -101,7 +99,7 @@ FRESULT f_expand (
lba = fp-&gt;obj.fs-&gt;database + fp-&gt;obj.fs-&gt;csize * (fp-&gt;obj.sclust - 2);
<span class="c">/* Write 2048 sectors from top of the file at a time */</span>
res = disk_write(drv, buffer, lba, 2048);
res = <em>disk_write</em>(drv, data, lba, 2048);
</pre>
</div>
@ -112,6 +110,7 @@ FRESULT f_expand (
<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/fattime.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - get_fattime</title>
</head>

View File

@ -3,8 +3,6 @@
<head>
<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/fdisk.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_fdisk</title>
</head>
@ -49,7 +47,7 @@ FRESULT f_fdisk (
<div class="para desc">
<h4>Description</h4>
<p>The <tt>f_fdisk</tt> function creates partitions on the physical drive. The partitioning format can be in generic MBR or GPT. The partition map table specifies how to divide the physical drive. The first item specifies the size of the first partition and the partitions are located on the drive in order of from the first item. When the value of item is less than or equal to 100, it specifies the partition size in percentage of the entire drive space. When it is larger than 100, it specifies number of sectors. The partition map table is terminated by a zero, no space is remaining for next allocation or 4th partition is created in MBR format. If the specified size is larger than remaining space on the drive, the partition is truncated at end of the drive.</p>
<p>The <tt>f_fdisk</tt> function creates partitions on the physical drive. The partitioning format can be in generic MBR or GPT. The partition map table specifies how to divide the physical drive. The first item specifies the size of the first partition and the partitions are located on the drive in order of from the first item. When the value of item is less than or equal to 100, it specifies the partition size in percentage of the entire drive space. When it is larger than 100, it specifies number of sectors. The partition map table is terminated by a zero, 4th partition in MBR format or no remainin space for next allocation. If the specified size is larger than remaining space on the drive, the partition is truncated at end of the drive.</p>
<p>By default, partitions are created in MBR format. It can create upto four primary partitions on a drive. GPT format is used to create the partitions when 64-bit LBA is enabled (<tt>FF_LBA64 = 1</tt>) and the drive size is equal to or larger than <tt><a href="config.html#fs_gptmin">FF_MIN_GPT</a></tt> sectors. It can create over ten partitions on a drive.</p>
</div>
@ -64,23 +62,23 @@ FRESULT f_fdisk (
<span class="c">/* Volume mapping table defined by user (required when FF_MULTI_PARTITION == 1) */</span>
PARTITION VolToPart[FF_VOLUMES] = {
{0, 1}, <span class="c">/* "0:" ==> 1st partition in PD#0 */</span>
{0, 2}, <span class="c">/* "1:" ==> 2nd partition in PD#0 */</span>
{1, 0} <span class="c">/* "2:" ==> PD#1 as removable drive */</span>
{0, 1}, <span class="c">/* "0:" ==> 1st partition in physical drive 0 */</span>
{0, 2}, <span class="c">/* "1:" ==> 2nd partition in physical drive 0 */</span>
{1, 0} <span class="c">/* "2:" ==> Physical drive 1 as removable drive */</span>
};
</pre>
<pre>
<span class="c">/* Initialize a brand-new disk drive mapped to physical drive 0 */</span>
BYTE work[FF_MAX_SS]; <span class="c">/* Working buffer */</span>
LBA_t plist[] = {50, 50, 0}; <span class="c">/* Divide the drive into two partitions */</span>
<span class="c">/* {0x10000000, 100}; 256M sectors for 1st partition and left all for 2nd partition */</span>
LBA_t plist[] = {50, 50, 0}; <span class="c">/* Divide the drive by 2 */</span>
<span class="c">/* {0x10000000, 100}; 256M sectors for the 1st partition and the remaining for the 2nd partition */</span>
<span class="c">/* {20, 20, 20, 0}; 20% for 3 partitions each and remaing space is left not allocated */</span>
<em>f_fdisk</em>(0, plist, work); <span class="c">/* Divide physical drive 0 */</span>
<em>f_fdisk</em>(0, plist, work); <span class="c">/* Divide the physical drive 0 */</span>
f_mkfs("0:", 0, work, sizeof work); <span class="c">/* Create FAT volume on the logical drive 0 */</span>
f_mkfs("1:", 0, work, sizeof work); <span class="c">/* Create FAT volume on the logical drive 1 */</span>
<em>f_mkfs</em>("0:", 0, work, sizeof work); <span class="c">/* Create FAT volume on the logical drive 0 */</span>
<em>f_mkfs</em>("1:", 0, work, sizeof work); <span class="c">/* Create FAT volume on the logical drive 1 */</span>
</pre>
</div>
@ -90,6 +88,7 @@ FRESULT f_fdisk (
<p><a href="filename.html#vol">Volume management</a>, <a href="mkfs.html"><tt>f_mkfs</tt></a></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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>
@ -36,15 +34,15 @@
<tr><td>/..</td><td>Invalid name</td><td>The root directory (sticks the top level)</td></tr>
</table>
<p>Also the drive prefix can be in pre-defined arbitrary string. When the option <tt><a href="config.html#str_volume_id">FF_STR_VOLUME_ID</a> == 1</tt>, also arbitrary string volume ID can be used as drive prefix. e.g. <tt>"<em>flash:</em>file1.txt"</tt>, <tt>"<em>ram:</em>temp.dat"</tt> or <tt>"<em>sd:</em>"</tt>. If the srting does not match any volume ID, the function fails with <tt>FR_INVALID_DRIVE</tt>.</p>
<p>When <tt>FF_STR_VOLUME_ID == 2</tt>, Unix style drive prefix can be used. e.g. <tt>"<em>/flash</em>/file1.txt"</tt>, <tt>"<em>/ram</em>/temp.dat"</tt> or <tt>"<em>/sd</em>"</tt>. If a heading separator is exist, it is treated as start of drive prefix and in absolute path. Any form as "root directory in current drive" and "current directory in specified drive" cannot be used. Double dot name cannot traverse the drives such as <tt>"<em>/flash</em>/..<em>/ram</em>/foo.dat"</tt>.</p>
<p>When <tt>FF_STR_VOLUME_ID == 2</tt>, Unix style drive prefix can be used. e.g. <tt>"<em>/flash</em>/file1.txt"</tt>, <tt>"<em>/ram</em>/temp.dat"</tt> or <tt>"<em>/sd</em>"</tt>. If a heading separator is exist, it is treated as an absolute path with a heading node ID. Any form as "root directory in current drive" and "current directory in specified drive" cannot be used. Double dot name cannot traverse the volumes such as <tt>"<em>/flash</em>/..<em>/ram</em>/foo.dat"</tt>.</p>
<p><em>Remark: In this revision, double dot name <tt>".."</tt> cannot follow the parent directory on the exFAT volume. It will work as <tt>"."</tt> and stay there.</em></p>
</div>
<div class="para doc" id="case">
<h3>Legal Characters and Case Sensitivity</h3>
<p>In the generic FAT filesystems, the legal characters for object name (file/directory name) are, <tt>0-9 A-Z ! # $ % &amp; ' ( ) - @ ^ _ ` { } ~</tt> in ASCII and extended characters <tt>\x80</tt> to <tt>\xFF</tt>. In the FAT filesystems with LFN extention, also <tt>+ , ; = [ ]</tt>, white space and extended characters <tt>U+000080</tt> to <tt>U+10FFFF</tt> are legal for the object name. White spaces and dots can be placed anywhere in the path name except end of the name. Trailing white spaces and dots are ignored.</p>
<p>FAT filesystem is case-insensitive to the object names on the volume. Object name on the FAT volume is compared in case-insensitive. For instance, these three names, <tt>file.txt</tt>, <tt>File.Txt</tt> and <tt>FILE.TXT</tt>, are identical on the FAT filesystem. This is applied to extended charactres as well. When an object is created on the FAT volume, up converted name is recorded to the SFN entry, and the raw name is recorded to the LFN entry when LFN extension is exist.</p>
<p>As for the MS-DOS and PC DOS for CJK (DOS/DBCS), extended characters ware recorded to the SFN entry without up-case conversion and compared in case-sensitive. This causes a problem on compatibility with Windows system when the object with extended characters is created on the volume by DOS/DBCS system; therfore the object names with DBCS extended characters should not be used on the FAT volume shared by those systems. FatFs works with case-sensitive to the extended characters in only non-LFN with DBCS configuration (DOS/DBCS specs). However, FatFs works with case-insensitive to the extended character (WindowsNT specs) in LFN configuration.</p>
<p>FAT filesystem is case-insensitive to the object names on the volume. Object names on the FAT volume are compared in case-insensitive. For instance, these three names, <tt>file.txt</tt>, <tt>File.Txt</tt> and <tt>FILE.TXT</tt>, are identical on the FAT filesystem. This is applied to extended charactres as well. When an object is created on the FAT volume, up converted name is recorded to the SFN entry, and the original name is recorded to the LFN entry if LFN extension is enabled.</p>
<p>On the MS-DOS and PC DOS for Chinese, Japanese and Korean (DOS/DBCS), extended characters are recorded to the SFN entry without up-case conversion and compared in case-sensitive. This causes a problem on compatibility with Windows system when the object with extended characters is created on the volume by DOS/DBCS system; therfore the object names with DBCS extended characters should not be used on the FAT volume shared by those systems. FatFs works with case-sensitive to the extended characters in only non-LFN with DBCS configuration (DOS/DBCS specs). However, FatFs works with case-insensitive to the extended character (WindowsNT specs) in LFN configuration.</p>
</div>
<div class="para doc" id="uni">
@ -84,11 +82,12 @@ PARTITION VolToPart[FF_VOLUMES] = {
<li>On the MBR format drive, up to four primary partitions (1-4) can be specified. The partition number 1 specifies the first item in the partition table and the partition number 2 specifies the second one, and so on. The logical patitions (5-) in the extended partition is not supported.</li>
<li>On the GPT format drive, the partition number 1 specifies the first Microsoft BDP found in the partition table and the partition number 2 specifies the second one found, and so on.</li>
<li>Windows 10 earlier than 1703 does not support multiple volumes on the physical drive with removable class. Only the first parition found on the drive will be mounted. Windows OS does not support SFD format on the physical drive with non-removable class.</li>
<li>Some systems manage the on-board storage in non-standard partition format and each partition is mapped as physical drive in <tt>disk_*</tt> functions. For such system, <tt>FF_MULTI_PARTITION</tt> should be always 0.</li>
<li>For further information about the volume management, refer to the description in <tt><a href="fdisk.html">f_fdisk</a></tt> and <tt><a href="mkfs.html">f_mkfs</a></tt>.</li>
<li>Some systems manage the on-board storage in non-standard partition format and each partition is mapped as physical drive in <tt>disk_*</tt> functions. For such system, <tt>FF_MULTI_PARTITION</tt> should be always 0 and use <tt>FM_SFD</tt> flag in <tt><a href="mkfs.html">f_mkfs</a></tt>.</li>
<li>For further information about the volume management, refer to the description in <tt>f_mkfs</tt> and <tt><a href="fdisk.html">f_fdisk</a></tt>.</li>
</ul>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/findfirst.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_findfirst</title>
</head>
@ -28,7 +26,7 @@ FRESULT f_findfirst (
<h4>Parameters</h4>
<dl class="par">
<dt>dp</dt>
<dd>Pointer to the blank directory object.</dd>
<dd>Pointer to the blank directory object. If a null pointer is given, the function fails with <tt>FR_INVALID_OBJECT</tt>.</dd>
<dt>fno</dt>
<dd>Pointer to the <a href="sfileinfo.html">file information structure</a> to store the information about the found item.</dd>
<dt>path</dt>
@ -99,10 +97,10 @@ void find_image_file (void)
while (fr == FR_OK &amp;&amp; fno.fname[0]) { <span class="c">/* Repeat while an item is found */</span>
printf("%s\n", fno.fname); <span class="c">/* Print the object name */</span>
fr = f_findnext(&amp;dj, &amp;fno); <span class="c">/* Search for next item */</span>
fr = <em>f_findnext</em>(&amp;dj, &amp;fno); <span class="c">/* Search for next item */</span>
}
f_closedir(&amp;dj);
<em>f_closedir</em>(&amp;dj);
}
</pre>
</div>

View File

@ -3,8 +3,6 @@
<head>
<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/findnext.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_findnext</title>
</head>
@ -64,6 +62,7 @@ FRESULT f_findnext (
<p><tt><a href="findfirst.html">f_findfirst</a>, <a href="closedir.html">f_closedir</a>, <a href="sdir.html">DIR</a>, <a href="sfileinfo.html">FILINFO</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/forward.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_forward</title>
</head>
@ -28,13 +26,13 @@ FRESULT f_forward (
<h4>Parameters</h4>
<dl class="par">
<dt>fp</dt>
<dd>Pointer to the open file object.</dd>
<dd>Pointer to the open file object. If a null pointer is given, the function fails with <tt>FR_INVALID_OBJECT</tt>.</dd>
<dt>func</dt>
<dd>Pointer to the user-defined data streaming function. For details, refer to the sample code.</dd>
<dt>btf</dt>
<dd>Number of bytes to forward in range of <tt>UINT</tt>.</dd>
<dt>bf</dt>
<dd>Pointer to the <tt>UINT</tt> variable to return number of bytes forwarded.</dd>
<dd>Pointer to the variable in <tt>UINT</tt> type to return number of bytes forwarded.</dd>
</dl>
</div>
@ -109,11 +107,11 @@ FRESULT play_file (
UINT dmy;
<span class="c">/* Open the audio file in read only mode */</span>
rc = f_open(&amp;fil, fn, FA_READ);
rc = <em>f_open</em>(&amp;fil, fn, FA_READ);
if (rc) return rc;
<span class="c">/* Repeat until the file pointer reaches end of the file */</span>
while (rc == FR_OK &amp;&amp; !f_eof(&amp;fil)) {
while (rc == FR_OK &amp;&amp; !<em>f_eof</em>(&amp;fil)) {
<span class="c">/* some processes... */</span>
@ -122,7 +120,7 @@ FRESULT play_file (
}
<span class="c">/* Close the file and return */</span>
f_close(&amp;fil);
<em>f_close</em>(&amp;fil);
return rc;
}
</pre>
@ -134,6 +132,7 @@ FRESULT play_file (
<p><tt><a href="open.html">f_open</a>, <a href="gets.html">fgets</a>, <a href="write.html">f_write</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/getcwd.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_getcwd</title>
</head>
@ -78,6 +76,7 @@ FRESULT f_getcwd (
<p><tt><a href="chdrive.html">f_chdrive</a>, <a href="chdir.html">f_chdir</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/getfree.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_getfree</title>
</head>

View File

@ -3,8 +3,6 @@
<head>
<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/getlabel.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_getlabel</title>
</head>
@ -27,7 +25,7 @@ FRESULT f_getlabel (
<h4>Parameters</h4>
<dl class="par">
<dt>path</dt>
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. Null-string specifies the default drive.</dd>
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. Null-string specifies the default drive. If a null pointer is given, the function fails with <tt>FR_INVALID_DRIVE</tt>.</dd>
<dt>label</dt>
<dd>Pointer to the buffer to store the volume label. If the volume has no label, a null-string will be returned. Set null pointer if this information is not needed. The buffer size should be shown below at least to avoid buffer overflow.<br>
<table class="lst2">

View File

@ -3,8 +3,6 @@
<head>
<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/gets.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_gets</title>
</head>
@ -45,13 +43,13 @@ TCHAR* f_gets (
<div class="para desc">
<h4>Description</h4>
<p>The read operation continues until a <tt>'\n'</tt> is stored, reached end of the file or the buffer is filled with <tt>len - 1</tt> characters. The read string is terminated with a <tt>'\0'</tt>. When no character to read or any error occured during read operation, it returns a null pointer. The status of EOF and error can be examined with <tt>f_eof</tt> and <tt>f_error</tt> function.</p>
<p>When FatFs is configured to Unicode API (<tt><a href="config.html#lfn_unicode">FF_LFN_UNICODE</a> >= 1</tt>), data types on the srting fuctions, <tt>f_putc</tt>, <tt>f_puts</tt>, <tt>f_printf</tt> and <tt>f_gets</tt>, is also switched to Unicode. The character encoding <em>on the file</em> to be read via this function is assumed as <a href="config.html#strf_encode"><tt>FF_STRF_ENCODE</tt></a>. If the character encoding on the file differs from that on the API, it is converted in this function. In this case, input characters with wrong encoding will be lost.</p>
<p>When FatFs is configured to Unicode API (<tt><a href="config.html#lfn_unicode">FF_LFN_UNICODE</a> >= 1</tt>), data types on the srting fuctions, <tt>f_putc</tt>, <tt>f_puts</tt>, <tt>f_printf</tt> and <tt>f_gets</tt>, is also switched to Unicode. The character encoding <em>on the file</em> to be read via this function is assumed as <a href="config.html#strf_encode"><tt>FF_STRF_ENCODE</tt></a>. If the character encoding differs between file data and API, it is converted in this function. Input characters with wrong encoding for output will be lost.</p>
</div>
<div class="para comp">
<h4>QuickInfo</h4>
<p>This is a wrapper function of <a href="read.html"><tt>f_read</tt></a> function. Available when <tt><a href="config.html#use_strfunc">FF_USE_STRFUNC</a> &gt;= 1</tt>. When it is set to 2, <tt>'\r'</tt>s contained in the file are stripped out.</p>
<p>This is a wrapper function of <a href="read.html"><tt>f_read</tt></a> function. Available when <tt><a href="config.html#use_strfunc">FF_USE_STRFUNC</a> &gt;= 1</tt>. When it is set to 2, <tt>'\r'</tt>s contained in the read data are stripped off.</p>
</div>
@ -60,6 +58,7 @@ TCHAR* f_gets (
<p><tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="putc.html">f_putc</a>, <a href="puts.html">f_puts</a>, <a href="printf.html">f_printf</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/lseek.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_lseek</title>
</head>
@ -32,7 +30,7 @@ FRESULT f_rewind (
<h4>Parameters</h4>
<dl class="par">
<dt>fp</dt>
<dd>Pointer to the open file object.</dd>
<dd>Pointer to the open file object. If a null pointer is given, the function fails with <tt>FR_INVALID_OBJECT</tt>.</dd>
<dt>ofs</dt>
<dd>Byte offset from top of the file to set read/write pointer. The data type <tt>FSIZE_t</tt> is an alias of either <tt>DWORD</tt>(32-bit) or <tt>QWORD</tt>(64-bit) depends on the configuration option <tt><a href="config.html#fs_exfat">FF_FS_EXFAT</a></tt>.</dd>
</dl>
@ -53,11 +51,12 @@ FRESULT f_rewind (
<div class="para desc">
<h4>Description</h4>
<p>File read/write ponter in the open file object points the data byte to be read/written at next read/write operation. It advances as the number of bytes read/written. The <tt>f_lseek</tt> function moves the file read/write pointer without any read/write operation to the file. The <tt>f_rewind</tt> function is impremented as a macro.</p>
<p>File read/write ponter in the open file object points the data byte to be read/written at next read/write operation. It advances as the number of bytes read/written. The <tt>f_lseek</tt> function moves the file read/write pointer without read/write operation to the file. The <tt>f_rewind</tt> function is impremented as a macro.</p>
<pre>
#define <em>f_rewind</em>(fp) f_lseek((fp), 0)
</pre>
<p>If an offset beyond the file size is specified in write mode, the file size is expanded to the specified offset. The file data in the expanded part is <em>undefined</em>, because no data is written to the file in this process. This is suitable to pre-allocate a data area to the file quickly for fast write operation. When a contiguous data area needs to be allocated to the file, use <tt>f_expand</tt> function instead. After the <tt>f_lseek</tt> function succeeded, the current read/write pointer should be checked in order to make sure the read/write pointer has been moved correctry. In case of the read/write pointer is not pointing expected offset, either of followings has been occured.</p>
<p>When an offset beyond the file size is specified in write mode, the file size is expanded to the specified offset <em>in this function</em>. The file data in the expanded part is <em>undefined</em>, because no data is written to the file in this process. Be careful about these behaviours differ from POSIX <tt>fseek</tt> function. This is suitable to pre-allocate a data area to the file for subsequent fast write operation. If a contiguous data area needs to be allocated to the file, use <tt>f_expand</tt> function instead.</p>
<p>After the <tt>f_lseek</tt> function succeeded, the current read/write pointer should be checked in order to make sure the read/write pointer has been moved correctry. In case of the read/write pointer is not pointing expected offset, either of followings has been occured.</p>
<ul>
<li>End of file. The specified <tt class="arg">ofs</tt> was clipped at end of the file in read-only mode.</li>
<li>Disk full. There is no free space on the volume to expand the file.</li>
@ -78,7 +77,7 @@ FRESULT f_rewind (
<pre>
<span class="c">/* Open file */</span>
fp = malloc(sizeof (FIL));
res = f_open(fp, "file.dat", FA_READ|FA_WRITE);
res = <em>f_open</em>(fp, "file.dat", FA_READ|FA_WRITE);
if (res) ...
<span class="c">/* Set read/write pointer to 5000 */</span>
@ -96,15 +95,15 @@ FRESULT f_rewind (
<pre>
<span class="c">/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */</span>
res = f_open(fp, recfile, FA_CREATE_NEW | FA_WRITE); <span class="c">/* Create a file */</span>
res = <em>f_open</em>(fp, recfile, FA_CREATE_NEW | FA_WRITE); <span class="c">/* Create a file */</span>
res = <em>f_lseek</em>(fp, PRE_SIZE); <span class="c">/* Expand file size (cluster pre-allocation) */</span>
if (res || f_tell(fp) != PRE_SIZE) ... <span class="c">/* Check if the file has been expanded successfly */</span>
if (res || <em>f_tell</em>(fp) != PRE_SIZE) ... <span class="c">/* Check if the file has been expanded successfly */</span>
res = <em>f_lseek</em>(fp, OFS_DATA); <span class="c">/* Record data stream with free from cluster allocation delay */</span>
... <span class="c">/* Write operation should be aligned to sector boundary to optimize the write throughput */</span>
res = f_truncate(fp); <span class="c">/* Truncate unused area */</span>
res = <em>f_truncate</em>(fp); <span class="c">/* Truncate unused area */</span>
res = <em>f_lseek</em>(fp, OFS_HEADER); <span class="c">/* Set file header */</span>
...
@ -115,7 +114,7 @@ FRESULT f_rewind (
DWORD clmt[SZ_TBL]; <span class="c">/* Cluster link map table buffer */</span>
res = f_open(fp, fname, FA_READ | FA_WRITE); <span class="c">/* Open a file */</span>
res = <em>f_open</em>(fp, fname, FA_READ | FA_WRITE); <span class="c">/* Open a file */</span>
res = <em>f_lseek</em>(fp, ofs1); <span class="c">/* This is normal seek (cltbl is nulled on file open) */</span>
@ -134,6 +133,7 @@ FRESULT f_rewind (
<p><tt><a href="open.html">f_open</a>, <a href="truncate.html">f_truncate</a>, <a href="expand.html">f_expand</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/mkdir.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_mkdir</title>
</head>
@ -75,6 +73,7 @@ FRESULT f_mkdir (
</pre>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/mkfs.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_mkfs</title>
</head>
@ -36,12 +34,12 @@ FRESULT f_mkfs (
<dd>Specifies a combination of FAT type flags, <tt>FM_FAT</tt>, <tt>FM_FAT32</tt>, <tt>FM_EXFAT</tt> and bitwise-or of these three, <tt>FM_ANY</tt>. <tt>FM_EXFAT</tt> is ignored when exFAT is not enabled. These flags specify which type of FAT volume to be created. If two or more types are specified, one out of them will be selected depends on the volume size and <tt class="arg">au_size</tt>. The flag <tt>FM_SFD</tt> specifies to create the volume on the drive in SFD format. The default value is <tt>FM_ANY</tt>.</dd>
<dt>BYTE n_fat</dt>
<dd>Specifies number of FAT copies on the FAT/FAT32 volume. Valid value for this member is 1 or 2. The default value (0) and any invaid value gives 1. If the FAT type is exFAT, this member has no effect.</dd>
<dt>UINT n_align</dt>
<dd>Specifies alignment of the volume data area (file allocation pool, usually erase block boundary of flash memory media) in unit of sector. The valid value for this member is between 1 and 32768 inclusive in power of 2. If a zero (the default value) or any invalid value is given, the function obtains the block size from lower layer with <tt>disk_ioctl</tt> function.</dd>
<dt>DWORD au_size</dt>
<dd>Specifies size of the allocation unit (cluter) in unit of byte. The valid value is power of 2 between sector size and 128 * sector size inclusive for FAT/FAT32 volume, or up to 16 MB for exFAT volume. If a zero (default value) or any invalid value is given, the function uses default allocation unit size depends on the volume size.</dd>
<dt>UINT align</dt>
<dd>Specifies alignment of the volume data area (file allocation pool, usually erase block boundary of flash memory media) <em>in unit of sector</em>. The valid value for this member is between 1 and 32768 inclusive in power of 2. If a zero (the default value) or any invalid value is given, the function obtains the block size from lower layer with <tt>disk_ioctl</tt> function.</dd>
<dt>UINT n_root</dt>
<dd>Specifies number of root directory entries on the FAT volume. Valid value for this member is up to 32768 and aligned to sector size / 32. The default value (0) and any invaid value gives 512. If the FAT type is FAT32 or exFAT, this member has no effect.</dd>
<dt>DWORD au_size</dt>
<dd>Specifies size of the cluster (allocation unit) <em>in unit of byte</em>. The valid value for this member is between sector size and 128 * sector size inclusive in power of 2 for FAT/FAT32 volume and up to 16 MB in power of 2 for exFAT volume. If a zero (default value) or any invalid value is given, the function uses a default cluster size depends on the volume size.</dd>
</dl>
<dt>work</dt>
<dd>Pointer to the working buffer used for the format process. If a null pointer is given with <tt><a href="config.html#use_lfn">FF_USE_LFN</a> == 3</tt>, the function uses a <tt>len</tt> bytes of heap memory in this function.</dd>
@ -69,7 +67,7 @@ FRESULT f_mkfs (
<p>The FAT sub-type, FAT12/FAT16/FAT32, of FAT volume except exFAT is determined by only number of clusters on the volume and nothing else, according to the FAT specification issued by Microsoft. Thus the FAT sub-type of created volume depends on the volume size and the cluster size. In case of the combination of FAT type and cluter size specified by argument is not valid for the volume size, the function will fail with <tt>FR_MKFS_ABORTED</tt>.</p>
<p>The allocation unit, also known as <em>cluster</em>, is a unit of disk space allocation for files. When the size of allocation unit is 32768 bytes, a file with 100 bytes in size occupies 32768 bytes of disk space. The space efficiency of disk usage gets worse as increasing size of allocation unit, but, on the other hand, the read/write performance increases. Therefore the size of allocation unit is a trade-off between space efficiency and performance. For the large volumes in GB order, 32768 bytes or larger, automatically selected by default, is recommended for most case unless extremely many small files are created in the volume.</p>
<p>When the logical drive to be formatted is associated with a physical drive (<tt><a href="config.html#multi_partition">FF_MULTI_PARTITION</a> == 0</tt> or <tt>VolToPart[].pt == 0</tt>) and <tt>FM_SFD</tt> flag is not specified, a partition occupies entire drive space is created and then the FAT volume is created in the partition. When <tt>FM_SFD</tt> flag is specified, the FAT volume is created without any disk partitioning.</p>
<p>When the logical drive to be formatted is associated with a specific partition by multiple partition feature (<tt>FF_MULTI_PARTITION == 1</tt> and <tt>VolToPart[].pt &gt; 0</tt>), the FAT volume is created in the partition of the physical drive specified by <a href="filename.html#vol">volume mapping table</a> and <tt>FM_SFD</tt> flag is ignored. The hosting physical drive needs to be partitioned with <tt>f_fdisk</tt> function or any partitioning tool prior to create the FAT volume with this function. If the partition is not exist, the function aborts with <tt>FR_MKFS_ABORTED</tt>.</p>
<p>When the logical drive to be formatted is associated with a specific partition by multiple partition feature (<tt>FF_MULTI_PARTITION == 1</tt> and <tt>VolToPart[].pt &gt; 0</tt>), the FAT volume is created in the partition of the physical drive specified by <a href="filename.html#vol">volume mapping table</a> and <tt>FM_SFD</tt> flag is ignored. The hosting physical drive needs to be partitioned with <tt>f_fdisk</tt> function or some partitioning tool prior to create the FAT volume with this function. If the partition is not exist, the function fails with <tt>FR_MKFS_ABORTED</tt>.</p>
<p>There are three standard disk partitioning formats, MBR, GPT and SFD. The MBR format, also known as FDISK format, is usually used for harddisk, memory card and U disk. It can divide a physical drive into one or more partitions with a partition table. The GPT, GUID Partition Table, is a newly defined patitioning format for large storage devices. FatFs suppors the GPT only when 64-bit LBA is enabled. The SFD, Super-Floppy Disk, is non-partitioned disk format. The FAT volume is located at LBA 0 and occupies the entire physical drive without any disk partitioning. It is usually used for floppy disk, optical disk and most super-floppy media. Some combination of systems and media support only either partitioned format or non-partitioned format and the other is not supported.</p>
<p>Some systems manage the partitions in the on-board storage in non-standard format. The partitions are mapped as physical drives identified by <tt class="arg">pdrv</tt> in <tt>disk_*</tt> functions. For such systems, SFD format is suitable to create the FAT volume in the partition.</p>
</div>
@ -97,21 +95,21 @@ int main (void)
if (res) ...
<span class="c">/* Give a work area to the default drive */</span>
f_mount(&amp;fs, "", 0);
<em>f_mount</em>(&amp;fs, "", 0);
<span class="c">/* Create a file as new */</span>
res = f_open(&amp;fil, "hello.txt", FA_CREATE_NEW | FA_WRITE);
res = <em>f_open</em>(&amp;fil, "hello.txt", FA_CREATE_NEW | FA_WRITE);
if (res) ...
<span class="c">/* Write a message */</span>
f_write(&amp;fil, "Hello, World!\r\n", 15, &amp;bw);
<em>f_write</em>(&amp;fil, "Hello, World!\r\n", 15, &amp;bw);
if (bw != 15) ...
<span class="c">/* Close the file */</span>
f_close(&amp;fil);
<em>f_close</em>(&amp;fil);
<span class="c">/* Unregister work area */</span>
f_mount(0, "", 0);
<em>f_mount</em>(0, "", 0);
...
</pre>
@ -122,6 +120,7 @@ int main (void)
<p><a href="../res/mkfs.xlsx">Example of volume size and format parameters</a>, <a href="filename.html#vol">Volume management</a>, <tt><a href="fdisk.html">f_fdisk</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/mount.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_mount</title>
</head>
@ -92,19 +90,19 @@ int main (void)
FATFS *fs; <span class="c">/* Ponter to the filesystem object */</span>
fs = malloc(sizeof (FATFS)); <span class="c">/* Get work area for the volume */</span>
<em>f_mount</em>(fs, "", 0); <span class="c">/* Mount the default drive */</span>
fs = malloc(sizeof (FATFS)); <span class="c">/* Get work area for the volume */</span>
<em>f_mount</em>(fs, "", 0); <span class="c">/* Mount the default drive */</span>
f_open(... <span class="c">/* Here any file API can be used */</span>
f_open(... <span class="c">/* Here any file API can be used */</span>
...
<em>f_mount</em>(fs, "", 0); <span class="c">/* Re-mount the default drive to reinitialize the filesystem */</span>
<em>f_mount</em>(fs, "", 0); <span class="c">/* Re-mount the default drive to reinitialize the filesystem */</span>
...
<em>f_mount</em>(0, "", 0); <span class="c">/* Unmount the default drive */</span>
free(fs); <span class="c">/* Here the work area can be discarded */</span>
<em>f_unmount</em>(""); <span class="c">/* Unmount the default drive */</span>
free(fs); <span class="c">/* Here the work area can be discarded */</span>
...
}
@ -117,6 +115,7 @@ int main (void)
<p><tt><a href="open.html">f_open</a></tt>, <tt><a href="sfatfs.html">FATFS</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/open.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_open</title>
</head>
@ -27,19 +25,19 @@ FRESULT f_open (
<h4>Parameters</h4>
<dl class="par">
<dt>fp</dt>
<dd>Pointer to the blank file object structure.</dd>
<dd>Pointer to the blank file object structure. If a null pointer is given, the function fails with <tt>FR_INVALID_OBJECT</tt>.</dd>
<dt>path</dt>
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">file name</a> to open or create.</dd>
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">file name</a> to open or create. If a null pointer is given, the function fails with <tt>FR_INVALID_DRIVE</tt>.</dd>
<dt>mode</dt>
<dd>Mode flags that specifies the type of access and open method for the file. It is specified by a combination of following flags.<br>
<table class="lst">
<tr><th>Flags</th><th>Meaning</th></tr>
<tr><td>FA_READ</td><td>Specifies read access to the file. Data can be read from the file.</tr>
<tr><td>FA_WRITE</td><td>Specifies write access to the file. Data can be written to the file. Combine with <tt>FA_READ</tt> for read-write access.</td></tr>
<tr><td>FA_OPEN_EXISTING</td><td>Opens a file. The function fails if the file is not existing. (Default)</td></tr>
<tr><td>FA_CREATE_NEW</td><td>Creates a new file. The function fails with <tt>FR_EXIST</tt> if the file is existing.</td></tr>
<tr><td>FA_CREATE_ALWAYS</td><td>Creates a new file. If the file is existing, it will be truncated and overwritten.</td></tr>
<tr><td>FA_OPEN_ALWAYS</td><td>Opens the file if it is existing. If not, a new file will be created.</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_CREATE_ALWAYS</td><td>Creates a new file. If the file is existing, the file is truncated and overwritten.</td></tr>
<tr><td>FA_CREATE_NEW</td><td>Creates a new file. The function fails if the file is existing.</td></tr>
<tr><td>FA_OPEN_ALWAYS</td><td>Opens the file. If it is not exist, a new file is created.</td></tr>
<tr><td>FA_OPEN_APPEND</td><td>Same as <tt>FA_OPEN_ALWAYS</tt> except the read/write pointer is set end of the file.</td></tr>
</table>
Mode flags in POSIX fopen() function corresponds to FatFs mode flags as follows:<br>
@ -86,7 +84,8 @@ Mode flags in POSIX fopen() function corresponds to FatFs mode flags as follows:
<div class="para desc">
<h4>Description</h4>
<p>The <tt>f_open</tt> function opens a file and creates a <em>file object</em>. The file object is an identifier for subsequent operations to the file. Open file should be closed with <a href="close.html"><tt>f_close</tt></a> function after the session of the file access. If any change to the file has been made and not closed prior to power off, media removal or re-mount, or the file can be collapsed.</p>
<p>The <tt>f_open</tt> function opens a file and creates a <em>file object</em>. It is the identifier for subsequent read/write operations to the file. After the function succeeded, the file object is valid. If the function failed, the file object is set invalid.</p>
<p>Open file should be closed with <a href="close.html"><tt>f_close</tt></a> function after the session of the file access. If any change to the file has been made and not closed prior to power off, media removal or re-mount, or the file can be collapsed.</p>
<p>If duplicated file open is needed, read <a href="appnote.html#dup">here</a> carefully. However duplicated open of a file with any write mode flag is always prohibited.</p>
</div>
@ -112,19 +111,19 @@ int main (void)
<span class="c">/* Give a work area to the default drive */</span>
f_mount(&amp;FatFs, "", 0);
<em>f_mount</em>(&amp;FatFs, "", 0);
<span class="c">/* Open a text file */</span>
fr = <em>f_open</em>(&amp;fil, "message.txt", FA_READ);
if (fr) return (int)fr;
<span class="c">/* Read every line and display it */</span>
while (f_gets(line, sizeof line, &amp;fil)) {
while (<em>f_gets</em>(line, sizeof line, &amp;fil)) {
printf(line);
}
<span class="c">/* Close the file */</span>
f_close(&amp;fil);
<em>f_close</em>(&amp;fil);
return 0;
}
@ -142,8 +141,8 @@ int main (void)
<span class="c">/* Give work areas to each logical drive */</span>
f_mount(&amp;fs0, "0:", 0);
f_mount(&amp;fs1, "1:", 0);
<em>f_mount</em>(&amp;fs0, "0:", 0);
<em>f_mount</em>(&amp;fs1, "1:", 0);
<span class="c">/* Open source file on the drive 1 */</span>
fr = <em>f_open</em>(&amp;fsrc, "1:file.bin", FA_READ);
@ -155,19 +154,19 @@ int main (void)
<span class="c">/* Copy source to destination */</span>
for (;;) {
fr = f_read(&amp;fsrc, buffer, sizeof buffer, &amp;br); <span class="c">/* Read a chunk of data from the source file */</span>
fr = <em>f_read</em>(&amp;fsrc, buffer, sizeof buffer, &amp;br); <span class="c">/* Read a chunk of data from the source file */</span>
if (br == 0) break; <span class="c">/* error or eof */</span>
fr = f_write(&amp;fdst, buffer, br, &amp;bw); <span class="c">/* Write it to the destination file */</span>
fr = <em>f_write</em>(&amp;fdst, buffer, br, &amp;bw); <span class="c">/* Write it to the destination file */</span>
if (bw &lt; br) break; <span class="c">/* error or disk full */</span>
}
<span class="c">/* Close open files */</span>
f_close(&amp;fsrc);
f_close(&amp;fdst);
<em>f_close</em>(&amp;fsrc);
<em>f_close</em>(&amp;fdst);
<span class="c">/* Unregister work area prior to discard it */</span>
f_unmount("0:");
f_unmount("1:");
<em>f_unmount</em>("0:");
<em>f_unmount</em>("1:");
return (int)fr;
}
@ -180,6 +179,7 @@ int main (void)
<p><tt><a href="read.html">f_read</a>, <a href="write.html">f_write</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a>, <a href="sfatfs.html">FATFS</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/opendir.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_opendir</title>
</head>
@ -26,9 +24,9 @@ FRESULT f_opendir (
<h4>Parameters</h4>
<dl class="par">
<dt>dp</dt>
<dd>Pointer to the blank directory object to create a new one.</dd>
<dd>Pointer to the blank directory object to create a new one. If a null pointer is given, the function fails with <tt>FR_INVALID_OBJECT</tt>.</dd>
<dt>path</dt>
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">directory name</a> to be opened.</dd>
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">directory name</a> to be opened. If a null pointer is given, the function fails with <tt>FR_INVALID_DRIVE</tt>.</dd>
</dl>
</div>
@ -70,6 +68,7 @@ FRESULT f_opendir (
<p><tt><a href="readdir.html">f_readdir</a>, <a href="closedir.html">f_closedir</a>, <a href="sdir.html">DIR</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/printf.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_printf</title>
</head>
@ -57,19 +55,19 @@ int f_printf (
<dt>type</dt><dd>Specifies type of the output format and the argument as shown below. The length of generated string is in assumtion of int is 32-bit.
<table class="lst1">
<tr><th>Type</th><th>Format</th><th>Argument</th><th>Length</th></tr>
<tr><td><tt>c</tt></td><td>Character</td><td rowspan="6"><tt>int</tt>,<br><tt>long</tt>,<br><tt>long long</tt></td><td>1 character.</td></tr>
<tr><td><tt>c</tt></td><td>Character</td><td rowspan="6"><tt>int</tt>,<br><tt>long</tt>,<br><tt>long&nbsp;long</tt></td><td>1 character.</td></tr>
<tr><td><tt>d</tt></td><td>Signed&nbsp;decimal</td><td>1 to 11 (20 for ll) characters.</td></tr>
<tr><td><tt>u</tt></td><td>Unsigned&nbsp;decimal</td><td>1 to 10 (20 for ll) characters.</td></tr>
<tr><td><tt>o</tt></td><td>Unsigned&nbsp;octal</td><td>1 to 11 (22 for ll) characters.</td></tr>
<tr><td><tt>x X</tt></td><td>Unsigned&nbsp;hexdecimal</td><td>1 to 8 (16 for ll) characters.</td></tr>
<tr><td><tt>b</tt></td><td>Unsigned&nbsp;binary</td><td>1 to 32 characters. Limited to lower 32 digits when ll is specified.</td></tr>
<tr><td><tt>s</tt></td><td>String</td><td><tt>TCHAR*</tt></td><td>As input string. Null pointer generates a null string.</td></tr>
<tr><td><tt>f</tt></td><td>Floating point<br>(decimal)</td><td rowspan="2"><tt>double</tt></td><td>1 to 31 characters. If the number of characters exceeds 31, it writes <tt>"±OV"</tt>. Not a number and infinite write <tt>"NaN"</tt> and <tt>"±INF"</tt>.</td></tr>
<tr><td><tt>s</tt></td><td>String</td><td><tt>TCHAR*</tt></td><td>As input string. A null pointer generates a zero-length string.</td></tr>
<tr><td><tt>f</tt></td><td>Floating point<br>(decimal)</td><td rowspan="2"><tt>double</tt></td><td>1 to 31 characters. If the number of characters exceeds 31, it writes <tt>"±OV"</tt>. Not a number and infinite value write <tt>"NaN"</tt> and <tt>"±INF"</tt> respectively.</td></tr>
<tr><td><tt>e E</tt></td><td>Floating point<br>(e notation)</td><td>4 to 31 characters. If the number of characters exceeds 31 or exponent exceeds +99, it writes <tt>"±OV"</tt>.</td></tr>
</table>
</dd>
</dl>
<p>When FatFs is configured for Unicode API (<tt><a href="config.html#lfn_unicode">FF_LFN_UNICODE</a> &gt;= 1</tt>), character encoding on the string fuctions, <tt>f_putc</tt>, <tt>f_puts</tt>, <tt>f_printf</tt> and <tt>f_gets</tt> function, is also switched to Unicode. The Unicode characters in multiple encoding unit, such as surrogate pair and multi-byte sequence, should not be divided into two function calls, or the character will be lost. The character encoding <em>on the file</em> to be written via this function is selected by <tt><a href="config.html#strf_encode">FF_STRF_ENCODE</a></tt>. The characters with wrong encoding or invalid for the output encoding will be lost.</p>
<p>When FatFs is configured for Unicode API (<tt><a href="config.html#lfn_unicode">FF_LFN_UNICODE</a> &gt;= 1</tt>), character encoding on the string fuctions, <tt>f_putc</tt>, <tt>f_puts</tt>, <tt>f_printf</tt> and <tt>f_gets</tt> function, is also switched to Unicode. The Unicode characters in multiple encoding unit, such as surrogate pair and multi-byte sequence, should not be divided into two function calls, or the character will be lost. The character encoding <em>on the file</em> to be written via this function is selected by <tt><a href="config.html#strf_encode">FF_STRF_ENCODE</a></tt>. If the character encoding differs between file data and API, it is converted in this function. Input characters with wrong encoding for output will be lost.</p>
<p>If <tt>sprintf</tt> is used in the project and code conversion is not needed, <tt>f_write</tt> with <tt>sprintf</tt> will be efficient in code size and performance rather than <tt>f_printf</tt>.</p>
</div>
@ -110,6 +108,7 @@ int f_printf (
<p><tt><a href="open.html">f_open</a>, <a href="putc.html">f_putc</a>, <a href="puts.html">f_puts</a>, <a href="gets.html">f_gets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/putc.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_putc</title>
</head>
@ -55,6 +53,7 @@ int f_putc (
<p><tt><a href="open.html">f_open</a>, <a href="puts.html">f_puts</a>, <a href="printf.html">f_printf</a>, <a href="gets.html">f_gets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/puts.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_puts</title>
</head>
@ -41,7 +39,7 @@ int f_puts (
<div class="para desc">
<h4>Description</h4>
<p>When FatFs is configured for Unicode API (<tt><a href="config.html#lfn_unicode">FF_LFN_UNICODE</a> &gt;= 1</tt>), character encoding on the string fuctions, <tt>f_putc</tt>, <tt>f_puts</tt>, <tt>f_printf</tt> and <tt>f_gets</tt> function, is also switched to Unicode. The input Unicode characters in multiple encoding unit, such as surrogate pair and multi-byte sequence, should not be divided into two function calls, or the character will be lost. The character encoding <em>on the file</em> to be written via this functions is selected by <tt><a href="config.html#strf_encode">FF_STRF_ENCODE</a></tt>. The characters with wrong encoding or invalid for the output encoding will be lost.</p>
<p>When FatFs is configured for Unicode API (<tt><a href="config.html#lfn_unicode">FF_LFN_UNICODE</a> &gt;= 1</tt>), character encoding on the string fuctions, <tt>f_putc</tt>, <tt>f_puts</tt>, <tt>f_printf</tt> and <tt>f_gets</tt> function, is also switched to Unicode. The input Unicode characters in multiple encoding unit, such as surrogate pair and multi-byte sequence, should not be divided into two function calls, or the character will be lost. The character encoding <em>on the file</em> to be written via this functions is selected by <tt><a href="config.html#strf_encode">FF_STRF_ENCODE</a></tt>. If the character encoding differs between file data and API, it is converted in this function. Input characters with wrong encoding for output will be lost.</p>
</div>
@ -56,6 +54,7 @@ int f_puts (
<p><tt><a href="open.html">f_open</a>, <a href="putc.html">f_putc</a>, <a href="printf.html">f_printf</a>, <a href="gets.html">f_gets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/rc.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - API Return Code</title>
</head>
@ -75,10 +73,10 @@ Note that if once this error occured in the operation to an open file, the file
<dd>Name collision. An object with the same name is already existing in the directory.</dd>
<dt id="io">FR_INVALID_OBJECT</dt>
<dd>The file/directory object is invalid or a null pointer is given. There are some reasons as follows:
<dd>The file/directory object is invalid or the pointer is null. There are some reasons as follows:
<ul>
<li>It has been closed, or the structure has been collapsed.</li>
<li>It has been invalidated. Open objects on the volume are invalidated by voulme mount process.</li>
<li>The file/directory has been closed.</li>
<li>The file/directory object has been invalidated or the structure has been collapsed. Open objects on the volume will be invalidated by a voulme mount process.</li>
<li>Physical drive is not ready to work due to a media removal.</li>
</ul>
</dd>
@ -130,6 +128,7 @@ Note that if once this error occured in the operation to an open file, the file
<dd>The given parameter is invalid or there is an inconsistent for the volume.</dd>
</dl>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/read.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_read</title>
</head>
@ -28,13 +26,13 @@ FRESULT f_read (
<h4>Parameters</h4>
<dl class="par">
<dt>fp</dt>
<dd>Pointer to the open file object.</dd>
<dd>Pointer to the open file object structure. If a null pointer is given, the function fails with <tt>FR_INVALID_OBJECT</tt>.</dd>
<dt>buff</dt>
<dd>Pointer to the buffer to store the read data.</dd>
<dt>btr</dt>
<dd>Number of bytes to read in range of <tt>UINT</tt> type. If the file needs to be read fast, it should be read in large chunk as possible.</dd>
<dt>br</dt>
<dd>Pointer to the <tt>UINT</tt> variable that receives number of bytes read. This value is always valid after the function call regardless of the function return code. If the return value is equal to <tt class="arg">btr</tt>, the function return code should be <tt>FR_OK</tt>.</dd>
<dd>Pointer to the variable in <tt>UINT</tt> type that receives number of bytes read. This value is always valid after the function call regardless of the function return code. If the return value is equal to <tt class="arg">btr</tt>, the function return code should be <tt>FR_OK</tt>.</dd>
</dl>
</div>
@ -54,7 +52,7 @@ FRESULT f_read (
<div class="para desc">
<h4>Description</h4>
<p>The function starts to read data from the file at the file offset pointed by read/write pointer. The read/write pointer advances as number of bytes read. After the function succeeded, <tt class="arg">*br</tt> should be checked to detect end of the file. In case of <tt class="arg">*br</tt> &lt; <tt class="arg">btr</tt>, it means the read/write pointer hit end of the file during read operation.</p>
<p>The function starts to read data from the file at the file offset pointed by read/write pointer of the file object. The read/write pointer advances as number of bytes read. After the function succeeded, <tt class="arg">*br</tt> should be checked to detect end of the file. In case of <tt class="arg">*br</tt> &lt; <tt class="arg">btr</tt>, it means the read/write pointer hit end of the file during read operation.</p>
</div>
@ -75,6 +73,7 @@ FRESULT f_read (
<p><tt><a href="open.html">f_open</a>, <a href="gets.html">fgets</a>, <a href="write.html">f_write</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/readdir.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_readdir</title>
</head>
@ -53,19 +51,19 @@ FRESULT f_rewinddir (
<div class="para desc">
<h4>Description</h4>
<p>The <tt>f_readdir</tt> function reads a directory item, informations about the object, from the open directory. Items in the directory can be read in sequence by <tt>f_readdir</tt> function calls. When all items in the directory have been read and no item to read, a null string is stored into the <tt>fno-&gt;fname[]</tt> without any error. When a null pointer is given to the <tt class="arg">fno</tt>, the read index of the directory object is rewinded. The <tt>f_rewinddir</tt> function is implemented as a macro.</p>
<p>The <tt>f_readdir</tt> function reads a directory item, informations about the object, from the open directory. Items in the directory can be read by <tt>f_readdir</tt> function calls in order of the directory table. When all items in the directory have been read and no item to read any more, a null string in <tt>fno-&gt;fname[]</tt> will be returned without an error. If a null pointer is given to the <tt class="arg">fno</tt>, the read index of the directory object will be rewound. The <tt>f_rewinddir</tt> function is implemented as a macro.</p>
<pre>
#define <em>f_rewinddir</em>(dp) f_readdir((dp), 0)
</pre>
<p>When LFN is enabled, a member <tt>altname[]</tt> is defined in the file information structure to store the short file name of the object. If the long file name is not accessible due to a reason listed below, short file name is stored to the <tt>fname[]</tt> and the <tt>altname[]</tt> has a null string.</p>
<p>When LFN is enabled, a member <tt>altname[]</tt> is defined in the file information structure to store the short file name of the object. If the long file name is not accessible due to any reason listed below, short file name is stored to the <tt>fname[]</tt> and the <tt>altname[]</tt> has a null string.</p>
<ul>
<li>The item has no LFN. (Not the case in exFAT volume)</li>
<li><a href="config.html#max_lfn"><tt>FF_MAX_LFN</tt></a> is insufficient to handle the LFN. (Not the case in <tt>FF_MAX_LFN == 255</tt>)</li>
<li>The item has no LFN. (Not the case on the exFAT volume)</li>
<li><a href="config.html#max_lfn"><tt>FF_MAX_LFN</tt></a> is insufficient to handle the LFN. (Not the case when <tt>FF_MAX_LFN == 255</tt>)</li>
<li><a href="config.html#lfn_buf"><tt>FF_LFN_BUF</tt></a> is insufficient to store the LFN.</li>
<li>The LFN contains some character not defined in current CP. (Not the case in <tt>FF_LFN_UNICODE != 0</tt>)</li>
<li>The LFN contains some character not defined in current CP. (Not the case when <tt>FF_LFN_UNICODE != 0</tt>)</li>
</ul>
<p>There is an issue on read directories in exFAT volume. The exFAT does not support short file name. This means no name can be returned on the condition above. If it is the case, "?" is returned as the file name to indicate that the object is not accessible. To avoid this problem, configure FatFs <tt><a href="config.html#lfn_unicode">FF_LFN_UNICODE</a> != 0</tt> and <tt>FF_MAX_LFN == 255</tt> to support the full feature of LFN specification.</p>
<p>Dot entries (<tt>"."</tt> and <tt>".."</tt>) in the sub-directory of FAT volume are filtered out and they will never appear in the read items because exFAT lacks dot entries in the sub-directory.</p>
<p>There is an issue on read the directories on the exFAT volume. The exFAT does not support short file name. This means no name can be returned on the condition above. If it is the case, "?" is returned as the file name to indicate that the object is not accessible. To avoid this problem, configure FatFs <tt><a href="config.html#lfn_unicode">FF_LFN_UNICODE</a> != 0</tt> and <tt>FF_MAX_LFN == 255</tt> to support the full feature of LFN specification.</p>
<p>Dot entries (<tt>"."</tt> and <tt>".."</tt>) in the sub-directory of FAT volume are filtered out and they will never appear in the read items because of the consistency with exFAT which lacks dot entries in the sub-directory.</p>
</div>
@ -78,6 +76,41 @@ FRESULT f_rewinddir (
<div class="para use">
<h4>Sample Code</h4>
<pre>
<span class="c">/* List contents of a directory */</span>
FRESULT list_dir (const char *path)
{
FRESULT res;
DIR dir;
FILINFO fno;
int nfile, ndir;
res = <em>f_opendir</em>(&amp;dir, path); <span class="c">/* Open the directory */</span>
if (res == FR_OK) {
nfile = ndir = 0;
for (;;) {
res = <em>f_readdir</em>(&amp;dir, &amp;fno); <span class="c">/* Read a directory item */</span>
if (res != FR_OK || fno.fname[0] == 0) break; <span class="c">/* Error or end of dir */</span>
if (fno.fattrib &amp; AM_DIR) { <span class="c">/* Directory */</span>
printf(" &lt;DIR&gt; %s\n", fno.fname);
ndir++;
} else { <span class="c">/* File */</span>
printf("%10u %s\n", fno.fsize, fno.fname);
nfile++;
}
}
<em>f_closedir</em>(&amp;dir);
printf("%d dirs, %d files.\n", ndir, nfile);
} else {
printf("Failed to open \"%s\". (%u)\n", path, res);
}
return res;
}
</pre>
<pre>
<span class="c">/* Recursive scan of all items in the directory */</span>
FRESULT scan_files (
char* path <span class="c">/* Start node to be scanned (***also used as work area***) */</span>
)
@ -88,7 +121,7 @@ FRESULT scan_files (
static FILINFO fno;
res = f_opendir(&amp;dir, path); <span class="c">/* Open the directory */</span>
res = <em>f_opendir</em>(&amp;dir, path); <span class="c">/* Open the directory */</span>
if (res == FR_OK) {
for (;;) {
res = <em>f_readdir</em>(&amp;dir, &amp;fno); <span class="c">/* Read a directory item */</span>
@ -103,7 +136,7 @@ FRESULT scan_files (
printf("%s/%s\n", path, fno.fname);
}
}
f_closedir(&amp;dir);
<em>f_closedir</em>(&amp;dir);
}
return res;
@ -117,7 +150,7 @@ int main (void)
char buff[256];
res = f_mount(&amp;fs, "", 1);
res = <em>f_mount</em>(&amp;fs, "", 1);
if (res == FR_OK) {
strcpy(buff, "/");
res = scan_files(buff);
@ -134,6 +167,7 @@ int main (void)
<p><tt><a href="opendir.html">f_opendir</a>, <a href="closedir.html">f_closedir</a>, <a href="stat.html">f_stat</a>, <a href="sfileinfo.html">FILINFO</a>, <a href="sdir.html">DIR</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/rename.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_rename</title>
</head>

View File

@ -3,8 +3,6 @@
<head>
<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/sdir.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - DIR</title>
</head>
@ -33,6 +31,7 @@
</pre>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/getcwd.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_setcp</title>
</head>

View File

@ -3,8 +3,6 @@
<head>
<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/setlabel.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_setlabel</title>
</head>
@ -25,7 +23,7 @@ FRESULT f_setlabel (
<h4>Parameters</h4>
<dl class="par">
<dt>label</dt>
<dd>Pointer to the null-terminated string that specifies the volume label to be set.</dd>
<dd>Pointer to the null-terminated string that specifies the volume label to be set. If a null pointer is given, the function fails with <tt>FR_INVALID_DRIVE</tt>.</dd>
</dl>
</div>
@ -49,7 +47,7 @@ FRESULT f_setlabel (
<div class="para desc">
<h4>Description</h4>
<p>When the string has a drive prefix, the volume label will be set to the volume specified by the drive prefix. Unix style volume ID cannot be used to specify the volume. If drive number is not specified, the volume label will be set to the default drive. If length of the given volume label is zero, the volume label on the volume will be removed. The format of the volume label is as shown below:</p>
<p>When the string has a drive prefix, the volume label will be set to the volume specified by the drive prefix. If drive number is not specified, the volume label will be set to the default drive. If length of the given volume label is zero, the volume label on the volume will be removed. The format of the volume label is as shown below:</p>
<ul>
<li>Up to 11 bytes long as conversion of OEM code page at FAT volume.</li>
<li>Up to 11 characters long at exFAT volume.</li>
@ -77,6 +75,9 @@ FRESULT f_setlabel (
<span class="c">/* Remove volume label of the drive 2 */</span>
<em>f_setlabel</em>("2:");
<span class="c">/* Set volume label in Unix style volume id */</span>
<em>f_setlabel</em>("/tfcard/LOG DISK");
</pre>
</div>

View File

@ -3,8 +3,6 @@
<head>
<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/sfatfs.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FATFS</title>
</head>

View File

@ -3,8 +3,6 @@
<head>
<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/sfile.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FIL</title>
</head>
@ -38,6 +36,7 @@
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/sfileinfo.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FILINFO</title>
</head>
@ -73,6 +71,7 @@
<dd>Alternative object name is stored if available. This member is not available in non-LFN configuration.</dd>
</dl>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/size.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_size</title>
</head>
@ -57,6 +55,7 @@ FSIZE_t f_size (
<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/stat.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_stat</title>
</head>
@ -26,7 +24,7 @@ FRESULT f_stat (
<h4>Parameters</h4>
<dl class="par">
<dt>path</dt>
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">object</a> to get its information. The object must not be the root direcotry.</dd>
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">object</a> to get its information. The object must not be the root direcotry. If a null pointer is given, the function fails with <tt>FR_INVALID_DRIVE</tt>.</dd>
<dt>fno</dt>
<dd>Pointer to the blank <tt>FILINFO</tt> structure to store the information of the object. Set null pointer if this information is not needed.</dd>
</dl>
@ -54,8 +52,8 @@ FRESULT f_stat (
<div class="para desc">
<h4>Description</h4>
<p>The <tt>f_stat</tt> function checks the existence of a file or sub-directory in the directory. If it is not exist, the function returns with <tt>FR_NO_FILE</tt>. If it is exist, the function returns with <tt>FR_OK</tt> and the informations about the object, size, timestamp and attribute, is stored to the file information structure. For details of the file information, refer to the <tt>FILINFO</tt> structure and <a href="readdir.html"><tt>f_readdir</tt></a> function.</p>
<p>Note that the file information comes from the meta data in the directory. If the file has been opend and modified, the file will need to be synched or closed in order to obtain the latest file information.</p>
<p>The <tt>f_stat</tt> function checks the existence of a file or sub-directory. If it is not exist, the function returns with <tt>FR_NO_FILE</tt>. If it is exist, the function returns with <tt>FR_OK</tt> and the informations about the object, size, timestamp and attribute, is stored to the file information structure. For details of the file information, refer to the <tt>FILINFO</tt> structure and <a href="readdir.html"><tt>f_readdir</tt></a> function.</p>
<p>Note that the file information comes from the meta data in the directory. If the file has been opend and modified, the file will need to be synced or closed in order to obtain the latest file information. This function cannot be used to retrieve the long file name with the short file name.</p>
</div>
@ -92,6 +90,7 @@ FRESULT f_stat (
break;
case FR_NO_FILE:
case FR_NO_PATH:
printf("\"%s\" is not exist.\n", fname);
break;
@ -107,6 +106,7 @@ FRESULT f_stat (
<p><tt><a href="opendir.html">f_opendir</a>, <a href="readdir.html">f_readdir</a>, <a href="sfileinfo.html">FILINFO</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/sync.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_sync</title>
</head>
@ -68,7 +66,7 @@ C - f_close()
w - f_write()
S - f_sync()
</pre>
<p>However there is no sense in <tt>f_sync</tt> function immediataly before <tt>f_close</tt> function because it performs <tt>f_sync</tt> function in it. In other words, the differnce between those functions is that the file object is invalidated or not.</p>
<p>However there is no sense in <tt>f_sync</tt> function jsut before <tt>f_close</tt> function, because the <tt>f_close</tt> performs <tt>f_sync</tt> in it. Actually, the differnce between these functions is that the file object is invalidated or not.</p>
</div>
@ -83,6 +81,7 @@ S - f_sync()
<p><tt><a href="close.html">f_close</a></tt>, <a href="appnote.html#critical">Critical section</a></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/tell.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_tell</title>
</head>
@ -57,6 +55,7 @@ FSIZE_t f_tell (
<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/truncate.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_truncate</title>
</head>
@ -25,7 +23,7 @@ FRESULT f_truncate (
<h4>Parameter</h4>
<dl class="par">
<dt>fp</dt>
<dd>Pointer to the open file object to be truncated.</dd>
<dd>Pointer to the open file object to be truncated. If a null pointer is given, the function fails with <tt>FR_INVALID_OBJECT</tt>.</dd>
</dl>
</div>

View File

@ -3,8 +3,6 @@
<head>
<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/unlink.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_unlink</title>
</head>
@ -25,7 +23,7 @@ FRESULT f_unlink (
<h4>Parameter</h4>
<dl class="par">
<dt>path</dt>
<dd>Pointer to a null-terminated string that specifies the <a href="filename.html">file or sub-directory</a> to be removed.</dd>
<dd>Pointer to a null-terminated string that specifies the <a href="filename.html">file or sub-directory</a> to be removed. If a null pointer is given, the function fails with <tt>FR_INVALID_DRIVE</tt>.</dd>
</dl>
</div>

View File

@ -3,8 +3,6 @@
<head>
<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/utime.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_utime</title>
</head>
@ -26,7 +24,7 @@ FRESULT f_utime (
<h4>Parameters</h4>
<dl class="par">
<dt>path</dt>
<dd>Pointer to the null-terminated string that specifies an <a href="filename.html">object</a> to be changed.</dd>
<dd>Pointer to the null-terminated string that specifies an <a href="filename.html">object</a> to be changed. If a null pointer is given, the function fails with <tt>FR_INVALID_DRIVE</tt>.</dd>
<dt>fno</dt>
<dd>Pointer to the file information structure that has a timestamp to be set in member fdate and ftime. Do not care any other members.</dd>
</dl>
@ -94,6 +92,7 @@ FRESULT set_timestamp (
<p><tt><a href="stat.html">f_stat</a>, <a href="sfileinfo.html">FILINFO</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -3,8 +3,6 @@
<head>
<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/write.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_write</title>
</head>
@ -28,13 +26,13 @@ FRESULT f_write (
<h4>Parameters</h4>
<dl class="par">
<dt>fp</dt>
<dd>Pointer to the open file object structure.</dd>
<dd>Pointer to the open file object structure. If a null pointer is given, the function fails with <tt>FR_INVALID_OBJECT</tt>.</dd>
<dt>buff</dt>
<dd>Pointer to the data to be written.</dd>
<dt>btw</dt>
<dd>Specifies number of bytes to write in range of <tt>UINT</tt> type. If the data needs to be written fast, it should be written in large chunk as possible.</dd>
<dt>bw</dt>
<dd>Pointer to the <tt>UINT</tt> variable that receives the number of bytes written. This value is always valid after the function call regardless of the function return code. If the return value is equal to <tt class="arg">btw</tt>, the function return code should be <tt>FR_OK</tt>.</dd>
<dd>Pointer to the variable in <tt>UINT</tt> type that receives the number of bytes written. This value is always valid after the function call regardless of the function return code. If the return value is equal to <tt class="arg">btw</tt>, the function return code should be <tt>FR_OK</tt>.</dd>
</dl>
</div>
@ -54,7 +52,7 @@ FRESULT f_write (
<div class="para desc">
<h4>Description</h4>
<p>The function starts to write data to the file at the file offset pointed by read/write pointer. The read/write pointer advances as number of bytes written. After the function succeeded, <tt class="arg">*bw</tt> should be checked to detect the disk full. In case of <tt class="arg">*bw</tt> &lt; <tt class="arg">btw</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>
<p>The function starts to write data to the file at the file offset pointed by read/write pointer of the file object. The read/write pointer advances as number of bytes written. After the function succeeded, <tt class="arg">*bw</tt> should be checked to detect the disk full. In case of <tt class="arg">*bw</tt> &lt; <tt class="arg">btw</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>
@ -75,6 +73,7 @@ FRESULT f_write (
<p><tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="putc.html">fputc</a>, <a href="puts.html">fputs</a>, <a href="printf.html">fprintf</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>

View File

@ -367,3 +367,11 @@ R0.15 (November 6, 2022)
Fixed string functions cannot write the unicode characters not in BMP when FF_LFN_UNICODE == 2 (UTF-8).
Fixed a compatibility issue in identification of GPT header.
R0.15a (November 22, 2024)
Fixed a complie error when FF_FS_LOCK != 0.
Fixed a potential issue when work FatFs concurrency with FF_FS_REENTRANT, FF_VOLUMES >= 2 and FF_FS_LOCK > 0.
Made f_setlabel() accept a volume label in Unix style volume ID when FF_STR_VOLUME_ID == 2.
Made FatFs update PercInUse field in exFAT VBR. (A preceding f_getfree() is needed for the accuracy)

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
/*----------------------------------------------------------------------------/
/ FatFs - Generic FAT Filesystem module R0.15 /
/ FatFs - Generic FAT Filesystem module R0.15a /
/-----------------------------------------------------------------------------/
/
/ Copyright (C) 2022, ChaN, all right reserved.
/ Copyright (C) 2024, ChaN, all right reserved.
/
/ FatFs module is an open source software. Redistribution and use of FatFs in
/ source and binary forms, with or without modification, are permitted provided
@ -20,14 +20,15 @@
#ifndef FF_DEFINED
#define FF_DEFINED 80286 /* Revision ID */
#define FF_DEFINED 5380 /* Revision ID */
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(FFCONF_DEF)
#include "ffconf.h" /* FatFs configuration options */
#endif
#if FF_DEFINED != FFCONF_DEF
#error Wrong configuration file (ffconf.h).
#endif
@ -48,18 +49,18 @@ typedef unsigned __int64 QWORD;
#include <stdint.h>
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
typedef unsigned char BYTE; /* char must be 8-bit */
typedef uint16_t WORD; /* 16-bit unsigned integer */
typedef uint32_t DWORD; /* 32-bit unsigned integer */
typedef uint64_t QWORD; /* 64-bit unsigned integer */
typedef WORD WCHAR; /* UTF-16 character type */
typedef uint16_t WORD; /* 16-bit unsigned */
typedef uint32_t DWORD; /* 32-bit unsigned */
typedef uint64_t QWORD; /* 64-bit unsigned */
typedef WORD WCHAR; /* UTF-16 code unit */
#else /* Earlier than C99 */
#define FF_INTDEF 1
typedef unsigned int UINT; /* int must be 16-bit or 32-bit */
typedef unsigned char BYTE; /* char must be 8-bit */
typedef unsigned short WORD; /* 16-bit unsigned integer */
typedef unsigned long DWORD; /* 32-bit unsigned integer */
typedef WORD WCHAR; /* UTF-16 character type */
typedef unsigned short WORD; /* short must be 16-bit */
typedef unsigned long DWORD; /* long must be 32-bit */
typedef WORD WCHAR; /* UTF-16 code unit */
#endif
@ -113,15 +114,15 @@ typedef char TCHAR;
#if FF_MULTI_PARTITION /* Multiple partition configuration */
typedef struct {
BYTE pd; /* Physical drive number */
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
BYTE pd; /* Associated physical drive */
BYTE pt; /* Associated partition (0:Auto detect, 1-4:Forced partition) */
} PARTITION;
extern PARTITION VolToPart[]; /* Volume - Partition mapping table */
extern PARTITION VolToPart[]; /* Volume to partition mapping table */
#endif
#if FF_STR_VOLUME_ID
#ifndef FF_VOLUME_STRS
extern const char* VolumeStr[FF_VOLUMES]; /* User defied volume ID */
extern const char* VolumeStr[FF_VOLUMES]; /* User defined volume ID table */
#endif
#endif
@ -130,12 +131,12 @@ extern const char* VolumeStr[FF_VOLUMES]; /* User defied volume ID */
/* Filesystem object structure (FATFS) */
typedef struct {
BYTE fs_type; /* Filesystem type (0:not mounted) */
BYTE fs_type; /* Filesystem type (0:blank filesystem object) */
BYTE pdrv; /* Volume hosting physical drive */
BYTE ldrv; /* Logical drive number (used only when FF_FS_REENTRANT) */
BYTE n_fats; /* Number of FATs (1 or 2) */
BYTE wflag; /* win[] status (b0:dirty) */
BYTE fsi_flag; /* FSINFO status (b7:disabled, b0:dirty) */
BYTE wflag; /* win[] status (1:dirty) */
BYTE fsi_flag; /* Allocation information control (b7:disabled, b0:dirty) */
WORD id; /* Volume mount ID */
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
WORD csize; /* Cluster size [sectors] */
@ -146,11 +147,11 @@ typedef struct {
WCHAR* lfnbuf; /* LFN working buffer */
#endif
#if FF_FS_EXFAT
BYTE* dirbuf; /* Directory entry block scratchpad buffer for exFAT */
BYTE* dirbuf; /* Directory entry block scratch pad buffer for exFAT */
#endif
#if !FF_FS_READONLY
DWORD last_clst; /* Last allocated cluster */
DWORD free_clst; /* Number of free clusters */
DWORD last_clst; /* Last allocated cluster (Unknown if >= n_fatent) */
DWORD free_clst; /* Number of free clusters (Unknown if >= n_fatent-2) */
#endif
#if FF_FS_RPATH
DWORD cdir; /* Current directory start cluster (0:root) */
@ -272,24 +273,24 @@ typedef struct {
/* File function return code (FRESULT) */
typedef enum {
FR_OK = 0, /* (0) Succeeded */
FR_OK = 0, /* (0) Function succeeded */
FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
FR_INT_ERR, /* (2) Assertion failed */
FR_NOT_READY, /* (3) The physical drive cannot work */
FR_NOT_READY, /* (3) The physical drive does not work */
FR_NO_FILE, /* (4) Could not find the file */
FR_NO_PATH, /* (5) Could not find the path */
FR_INVALID_NAME, /* (6) The path name format is invalid */
FR_DENIED, /* (7) Access denied due to prohibited access or directory full */
FR_EXIST, /* (8) Access denied due to prohibited access */
FR_DENIED, /* (7) Access denied due to a prohibited access or directory full */
FR_EXIST, /* (8) Access denied due to a prohibited access */
FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
FR_NOT_ENABLED, /* (12) The volume has no work area */
FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any problem */
FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
FR_NO_FILESYSTEM, /* (13) Could not find a valid FAT volume */
FR_MKFS_ABORTED, /* (14) The f_mkfs function aborted due to some problem */
FR_TIMEOUT, /* (15) Could not take control of the volume within defined period */
FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated or given buffer is insufficient in size */
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > FF_FS_LOCK */
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
} FRESULT;
@ -375,7 +376,7 @@ DWORD ff_wtoupper (DWORD uni); /* Unicode upper-case conversion */
void* ff_memalloc (UINT msize); /* Allocate memory block */
void ff_memfree (void* mblock); /* Free memory block */
#endif
#if FF_FS_REENTRANT /* Sync functions */
#if FF_FS_REENTRANT /* Sync functions */
int ff_mutex_create (int vol); /* Create a sync object */
void ff_mutex_delete (int vol); /* Delete a sync object */
int ff_mutex_take (int vol); /* Lock sync object */
@ -389,7 +390,7 @@ void ff_mutex_give (int vol); /* Unlock sync object */
/* Flags and Offset Address */
/*--------------------------------------------------------------*/
/* File access mode and open method flags (3rd argument of f_open) */
/* File access mode and open method flags (3rd argument of f_open function) */
#define FA_READ 0x01
#define FA_WRITE 0x02
#define FA_OPEN_EXISTING 0x00
@ -398,10 +399,10 @@ void ff_mutex_give (int vol); /* Unlock sync object */
#define FA_OPEN_ALWAYS 0x10
#define FA_OPEN_APPEND 0x30
/* Fast seek controls (2nd argument of f_lseek) */
/* Fast seek controls (2nd argument of f_lseek function) */
#define CREATE_LINKMAP ((FSIZE_t)0 - 1)
/* Format options (2nd argument of f_mkfs) */
/* Format options (2nd argument of f_mkfs function) */
#define FM_FAT 0x01
#define FM_FAT32 0x02
#define FM_EXFAT 0x04

View File

@ -2,7 +2,7 @@
/ Configurations of FatFs Module
/---------------------------------------------------------------------------*/
#define FFCONF_DEF 80286 /* Revision ID */
#define FFCONF_DEF 5380 /* Revision ID */
/*---------------------------------------------------------------------------/
/ Function Configurations
@ -31,45 +31,45 @@
#define FF_USE_MKFS 0
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
/* This option switches f_mkfs(). (0:Disable or 1:Enable) */
#define FF_USE_FASTSEEK 0
/* This option switches fast seek function. (0:Disable or 1:Enable) */
/* This option switches fast seek feature. (0:Disable or 1:Enable) */
#define FF_USE_EXPAND 0
/* This option switches f_expand function. (0:Disable or 1:Enable) */
/* This option switches f_expand(). (0:Disable or 1:Enable) */
#define FF_USE_CHMOD 0
/* This option switches attribute manipulation functions, f_chmod() and f_utime().
/* This option switches attribute control API functions, f_chmod() and f_utime().
/ (0:Disable or 1:Enable) Also FF_FS_READONLY needs to be 0 to enable this option. */
#define FF_USE_LABEL 0
/* This option switches volume label functions, f_getlabel() and f_setlabel().
/* This option switches volume label API functions, f_getlabel() and f_setlabel().
/ (0:Disable or 1:Enable) */
#define FF_USE_FORWARD 0
/* This option switches f_forward() function. (0:Disable or 1:Enable) */
/* This option switches f_forward(). (0:Disable or 1:Enable) */
#define FF_USE_STRFUNC 0
#define FF_PRINT_LLI 1
#define FF_PRINT_FLOAT 1
#define FF_PRINT_LLI 0
#define FF_PRINT_FLOAT 0
#define FF_STRF_ENCODE 3
/* FF_USE_STRFUNC switches string functions, f_gets(), f_putc(), f_puts() and
/ f_printf().
/* FF_USE_STRFUNC switches the string API functions, f_gets(), f_putc(), f_puts()
/ and f_printf().
/
/ 0: Disable. FF_PRINT_LLI, FF_PRINT_FLOAT and FF_STRF_ENCODE have no effect.
/ 1: Enable without LF-CRLF conversion.
/ 2: Enable with LF-CRLF conversion.
/ 1: Enable without LF - CRLF conversion.
/ 2: Enable with LF - CRLF conversion.
/
/ FF_PRINT_LLI = 1 makes f_printf() support long long argument and FF_PRINT_FLOAT = 1/2
/ makes f_printf() support floating point argument. These features want C99 or later.
/ When FF_LFN_UNICODE >= 1 with LFN enabled, string functions convert the character
/ When FF_LFN_UNICODE >= 1 with LFN enabled, string API functions convert the character
/ encoding in it. FF_STRF_ENCODE selects assumption of character encoding ON THE FILE
/ to be read/written via those functions.
/
@ -118,15 +118,15 @@
/* The FF_USE_LFN switches the support for LFN (long file name).
/
/ 0: Disable LFN. FF_MAX_LFN has no effect.
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
/ 2: Enable LFN with dynamic working buffer on the STACK.
/ 3: Enable LFN with dynamic working buffer on the HEAP.
/
/ To enable the LFN, ffunicode.c needs to be added to the project. The LFN function
/ To enable the LFN, ffunicode.c needs to be added to the project. The LFN feature
/ requiers certain internal working buffer occupies (FF_MAX_LFN + 1) * 2 bytes and
/ additional (FF_MAX_LFN + 44) / 15 * 32 bytes when exFAT is enabled.
/ The FF_MAX_LFN defines size of the working buffer in UTF-16 code unit and it can
/ be in range of 12 to 255. It is recommended to be set it 255 to fully support LFN
/ be in range of 12 to 255. It is recommended to be set 255 to fully support the LFN
/ specification.
/ When use stack for the working buffer, take care on stack overflow. When use heap
/ memory for the working buffer, memory management functions, ff_memalloc() and
@ -156,9 +156,9 @@
#define FF_FS_RPATH 0
/* This option configures support for relative path.
/
/ 0: Disable relative path and remove related functions.
/ 0: Disable relative path and remove related API functions.
/ 1: Enable relative path. f_chdir() and f_chdrive() are available.
/ 2: f_getcwd() function is available in addition to 1.
/ 2: f_getcwd() is available in addition to 1.
*/
@ -175,7 +175,7 @@
/* FF_STR_VOLUME_ID switches support for volume ID in arbitrary strings.
/ When FF_STR_VOLUME_ID is set to 1 or 2, arbitrary strings can be used as drive
/ number in the path name. FF_VOLUME_STRS defines the volume ID strings for each
/ logical drives. Number of items must not be less than FF_VOLUMES. Valid
/ logical drive. Number of items must not be less than FF_VOLUMES. Valid
/ characters for the volume ID strings are A-Z, a-z and 0-9, however, they are
/ compared in case-insensitive. If FF_STR_VOLUME_ID >= 1 and FF_VOLUME_STRS is
/ not defined, a user defined volume string table is needed as:
@ -188,9 +188,9 @@
/* This option switches support for multiple volumes on the physical drive.
/ By default (0), each logical drive number is bound to the same physical drive
/ number and only an FAT volume found on the physical drive will be mounted.
/ When this function is enabled (1), each logical drive number can be bound to
/ When this feature is enabled (1), each logical drive number can be bound to
/ arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
/ function will be available. */
/ will be available. */
#define FF_MIN_SS 512
@ -198,8 +198,8 @@
/* This set of options configures the range of sector size to be supported. (512,
/ 1024, 2048 or 4096) Always set both 512 for most systems, generic memory card and
/ harddisk, but a larger value may be required for on-board flash memory and some
/ type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is configured
/ for variable sector size mode and disk_ioctl() function needs to implement
/ type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is
/ configured for variable sector size mode and disk_ioctl() needs to implement
/ GET_SECTOR_SIZE command. */
@ -209,14 +209,14 @@
#define FF_MIN_GPT 0x10000000
/* Minimum number of sectors to switch GPT as partitioning format in f_mkfs and
/ f_fdisk function. 0x100000000 max. This option has no effect when FF_LBA64 == 0. */
/* Minimum number of sectors to switch GPT as partitioning format in f_mkfs() and
/ f_fdisk(). 2^32 sectors maximum. This option has no effect when FF_LBA64 == 0. */
#define FF_USE_TRIM 0
/* This option switches support for ATA-TRIM. (0:Disable or 1:Enable)
/ To enable Trim function, also CTRL_TRIM command should be implemented to the
/ disk_ioctl() function. */
/ To enable this feature, also CTRL_TRIM command should be implemented to
/ the disk_ioctl(). */
@ -238,22 +238,22 @@
#define FF_FS_NORTC 0
#define FF_NORTC_MON 1
#define FF_NORTC_MON 11
#define FF_NORTC_MDAY 1
#define FF_NORTC_YEAR 2022
#define FF_NORTC_YEAR 2024
/* The option FF_FS_NORTC switches timestamp feature. If the system does not have
/ an RTC or valid timestamp is not needed, set FF_FS_NORTC = 1 to disable the
/ timestamp feature. Every object modified by FatFs will have a fixed timestamp
/ defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR in local time.
/ To enable timestamp function (FF_FS_NORTC = 0), get_fattime() function need to be
/ added to the project to read current time form real-time clock. FF_NORTC_MON,
/ To enable timestamp function (FF_FS_NORTC = 0), get_fattime() need to be added
/ to the project to read current time form real-time clock. FF_NORTC_MON,
/ FF_NORTC_MDAY and FF_NORTC_YEAR have no effect.
/ These options have no effect in read-only configuration (FF_FS_READONLY = 1). */
#define FF_FS_NOFSINFO 0
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
/ option, and f_getfree() function at the first time after volume mount will force
/ option, and f_getfree() at the first time after volume mount will force
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
/
/ bit0=0: Use free cluster count in the FSINFO if available.
@ -280,13 +280,13 @@
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
/ module itself. Note that regardless of this option, file access to different
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
/ and f_fdisk() function, are always not re-entrant. Only file/directory access
/ to the same volume is under control of this featuer.
/ and f_fdisk(), are always not re-entrant. Only file/directory access to
/ the same volume is under control of this featuer.
/
/ 0: Disable re-entrancy. FF_FS_TIMEOUT have no effect.
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
/ ff_mutex_create(), ff_mutex_delete(), ff_mutex_take() and ff_mutex_give()
/ function, must be added to the project. Samples are available in ffsystem.c.
/ ff_mutex_create(), ff_mutex_delete(), ff_mutex_take() and ff_mutex_give(),
/ must be added to the project. Samples are available in ffsystem.c.
/
/ The FF_FS_TIMEOUT defines timeout period in unit of O/S time tick.
*/