fatfs v0.07e Nov 03,2009:
- Separated out configuration options from ff.h to ffconf.h. - Added a configuration option, _LFN_UNICODE. - Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH. - Fixed name matching error on the 13 char boundary. - Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
This commit is contained in:
parent
25f499b847
commit
e6cd91ca0b
@ -3,8 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||||
<link rel="start" title="Site Top" href="../../">
|
<meta name="description" content="Open souece FAT file system module for embedded projects">
|
||||||
<link rel="up" title="Freewares" href="../../fsw_e.html">
|
|
||||||
<link rel="alternate" hreflang="ja" title="Japanese version" href="00index_j.html">
|
<link rel="alternate" hreflang="ja" title="Japanese version" href="00index_j.html">
|
||||||
<link rel="stylesheet" href="css_e.css" type="text/css" media="screen" title="ELM Default">
|
<link rel="stylesheet" href="css_e.css" type="text/css" media="screen" title="ELM Default">
|
||||||
<title>ELM - FAT File System Module</title>
|
<title>ELM - FAT File System Module</title>
|
||||||
@ -16,20 +15,21 @@
|
|||||||
|
|
||||||
<div class="abst">
|
<div class="abst">
|
||||||
<img src="img/layers.png" class="rset" width="245" height="255" alt="layer">
|
<img src="img/layers.png" class="rset" width="245" height="255" alt="layer">
|
||||||
<p>FatFs is a generic FAT file system module for small embedded systems. The FatFs is written in compliance with ANSI C and completely separated from the disk I/O layer. Therefore it is independent of hardware architecture. It can be incorporated into cheap microcontrollers, such as 8051, PIC, AVR, SH, Z80, H8, ARM and etc..., without any change. Petit FatFs module is also available <a href="http://elm-chan.org/fsw/ff/00index_p.html">here</a>.</p>
|
<p>FatFs is a generic FAT file system module for small embedded systems. The FatFs is written in compliance with ANSI C and completely separated from the disk I/O layer. Therefore it is independent of hardware architecture. It can be incorporated into low cost microcontrollers, such as AVR, 8051, PIC, ARM, Z80 and etc..., without any change. Petit FatFs module is also available <a href="http://elm-chan.org/fsw/ff/00index_p.html">here</a>.</p>
|
||||||
|
|
||||||
<h4>Features</h4>
|
<h4>Features</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li>FAT12, FAT16 and FAT32.</li>
|
<li>Windows compatible FAT file system.</li>
|
||||||
<li>Multiple volumes (physical drives and partitions).</li>
|
<li>Platform independent. Easy to port.</li>
|
||||||
<li>Two partitioning rules: FDISK and Super-floppy.</li>
|
<li>Very small footprint for code and work area.</li>
|
||||||
<li>Various configuration options:
|
<li>Various configuration options:
|
||||||
<ul>
|
<ul>
|
||||||
<li>Long file name (LFN) support.</li>
|
<li>Multiple volumes (physical drives and partitions).</li>
|
||||||
<li>Selectable code pages including DBCS.</li>
|
<li>Multiple OEM code pages including DBCS.</li>
|
||||||
<li>Multitask support.</li>
|
<li>Long file name (LFN) support in OEM code or Unicode.</li>
|
||||||
|
<li>RTOS support.</li>
|
||||||
<li>Multiple sector size support.</li>
|
<li>Multiple sector size support.</li>
|
||||||
<li>Read-only, minimized API, buffer configuration and etc...</li>
|
<li>Read-only, minimized API, I/O buffer and etc...</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h3>Application Interface</h3>
|
<h3>Application Interface</h3>
|
||||||
<p>FatFs module provides following functions.</p>
|
<p>FatFs module provides following functions to access the FAT volumes.</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="en/mount.html">f_mount</a> - Register/Unregister a Work Area</li>
|
<li><a href="en/mount.html">f_mount</a> - Register/Unregister a Work Area</li>
|
||||||
<li><a href="en/open.html">f_open</a> - Open/Create a File</li>
|
<li><a href="en/open.html">f_open</a> - Open/Create a File</li>
|
||||||
@ -71,7 +71,7 @@
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h3>Disk I/O Interface</h3>
|
<h3>Disk I/O Interface</h3>
|
||||||
<p>Since the FatFs module is completely separated from disk I/O layer, it requires following functions to lower layer to read/write the physical disk and to get current time. The low level disk I/O module is not a part of FatFs module and it must be provided by user. The sample drivers are also available in the resources.</p>
|
<p>Since the FatFs module is completely separated from disk I/O layer, it requires following functions to lower layer to read/write the physical disk and to get current time. The low level disk I/O module is not a part of FatFs module so that it must be provided by user. The sample drivers are also available in the resources.</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="en/dinit.html">disk_initialize</a> - Initialize disk drive</li>
|
<li><a href="en/dinit.html">disk_initialize</a> - Initialize disk drive</li>
|
||||||
<li><a href="en/dstat.html">disk_status</a> - Get disk status</li>
|
<li><a href="en/dstat.html">disk_status</a> - Get disk status</li>
|
||||||
@ -85,10 +85,10 @@
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h3>Resources</h3>
|
<h3>Resources</h3>
|
||||||
<p>The FatFs module is a free software and is opened for education, research and development. You can use, modify and/or republish it for personal, non-profit or commercial use without any restriction under your responsibility.</p>
|
<p>The FatFs module is a free software opened for education, research and development. You can use, modify and/or redistribute it for personal, non-profit use or commercial products without any restriction under your responsibility. For further information, refer to the application note.</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFs User Forum</em></a></li>
|
<li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFs User Forum</em></a></li>
|
||||||
<li><a href="en/appnote.html">FatFs module application note</a> <span class="mfd">Jun 21, 2009</span></li>
|
<li><a href="en/appnote.html">FatFs module application note</a> <span class="mfd">Jan 28, 2010</span></li>
|
||||||
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/">ARM-Projects by Martin THOMAS</a> (examples for LPC2000, AT91SAM and STM32)</li>
|
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/">ARM-Projects by Martin THOMAS</a> (examples for LPC2000, AT91SAM and STM32)</li>
|
||||||
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FAT32 Specification by Microsoft</a> (The reference document on FAT file system)</li>
|
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FAT32 Specification by Microsoft</a> (The reference document on FAT file system)</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/docs/mmc/mmc_e.html">How to Use MMC/SDC</a></li>
|
||||||
@ -98,7 +98,5 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
<p class="foot"><a href="../../fsw_e.html">Return</a></p>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -3,8 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
|
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
|
||||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||||
<link rel="start" title="Site Top" href="../../index_j.html">
|
<meta name="description" content="組み込みシステム向けFATファイル・システム">
|
||||||
<link rel="up" title="Freewares" href="../../fsw.html">
|
|
||||||
<link rel="alternate" hreflang="en" title="英文" href="00index_e.html">
|
<link rel="alternate" hreflang="en" title="英文" href="00index_e.html">
|
||||||
<link rel="stylesheet" href="css_j.css" type="text/css" media="screen" title="ELM Default">
|
<link rel="stylesheet" href="css_j.css" type="text/css" media="screen" title="ELM Default">
|
||||||
<title>ELM - 汎用FATファイルシステム・モジュール</title>
|
<title>ELM - 汎用FATファイルシステム・モジュール</title>
|
||||||
@ -16,19 +15,20 @@
|
|||||||
|
|
||||||
<div class="abst">
|
<div class="abst">
|
||||||
<img src="img/layers.png" class="rset" width="245" height="255" alt="layer">
|
<img src="img/layers.png" class="rset" width="245" height="255" alt="layer">
|
||||||
<p>小規模な組み込みシステム向けの汎用FATファイルシステム・モジュールです。ANSI C準拠でハードウェア・アーキテクチャには依存しないので、必要なワーク・エリアが確保できれば、8051, PIC, AVR, SH, Z80, H8, ARMなど安価なマイコンでそのまま使用可能です。</p>
|
<p>FatFsは小規模な組み込みシステム向けの汎用FATファイルシステム・モジュールです。ANSI C準拠でハードウェア・アーキテクチャには依存しないので、必要なワーク・エリアが確保できれば、8051, PIC, AVR, SH, Z80, H8, ARMなど安価なマイコンでも使用可能です。FatFsをシュリンクした<a href="http://elm-chan.org/fsw/ff/00index_p.html">ぷちFatFs</a>もあります。</p>
|
||||||
<h4>FatFsモジュールの特徴</h4>
|
<h4>FatFsモジュールの特徴</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li>FAT12, FAT16, FAT32に対応</li>
|
<li>Windows互換 FATファイル・システム</li>
|
||||||
<li>複数のボリューム(物理ドライブ・区画)に対応</li>
|
<li>プラットフォーム非依存</li>
|
||||||
<li>2種類の区画フォーマット(FDISKとSuper-floppy)に対応</li>
|
<li>コンパクトなコード・サイズとRAM使用量</li>
|
||||||
<li>多くの構成オプション:
|
<li>多くの構成オプション:
|
||||||
<ul>
|
<ul>
|
||||||
<li>長いファイル名(LFN)</li>
|
<li>複数のボリューム(物理ドライブ・区画)</li>
|
||||||
<li>複数のコード・ページ</li>
|
<li>DBCSを含む複数のOEMコード・ページ</li>
|
||||||
|
<li>長いファイル名(LFN)対応 (Unicode APIも選択可)</li>
|
||||||
<li>マルチタスク対応</li>
|
<li>マルチタスク対応</li>
|
||||||
<li>マルチ・セクタ・サイズ対応</li>
|
<li>マルチ・セクタ・サイズ対応</li>
|
||||||
<li>リードオンリー、一部機能の削除、バッファ構成等...</li>
|
<li>リード・オンリー、一部APIの削除、バッファ構成、その他…</li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -70,7 +70,7 @@
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h3>下位レイヤI/F</h3>
|
<h3>下位レイヤI/F</h3>
|
||||||
<p>FatFsモジュールは、物理ドライブへのアクセスや現在時刻を得るため、下位レイヤに次のインターフェースを要求します。これらのインターフェースを持つそれぞれの記録メディアに対応したディスクI/Oモジュールは、ユーザにより用意する必要があります。資料にサンプル・ドライバあり。</p>
|
<p>FatFsモジュールは、物理ドライブ等へのアクセスのため、下位レイヤに次のインターフェースを要求します。それぞれの記録メディアに対応したディスクI/Oモジュールは、ユーザによって用意される必要があります。資料にドライバを含むサンプル・プロジェクトあり。</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="ja/dinit.html">disk_initialize</a> - ディスク・ドライブの初期化</li>
|
<li><a href="ja/dinit.html">disk_initialize</a> - ディスク・ドライブの初期化</li>
|
||||||
<li><a href="ja/dstat.html">disk_status</a> - ディスク・ドライブの状態取得</li>
|
<li><a href="ja/dstat.html">disk_status</a> - ディスク・ドライブの状態取得</li>
|
||||||
@ -84,10 +84,10 @@
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h3>資料</h3>
|
<h3>資料</h3>
|
||||||
<p>FatFsモジュールはフリー・ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的(個人・非商用・商用)でも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。</p>
|
<p>FatFsモジュールはフリー・ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的(個人・非商用・商用)でも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。詳しくはアプリケーション・ノートを参照してください。</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFsユーザ・フォーラム</em></a></li>
|
<li><a href="http://elm-chan.org/fsw/ff/bd/"><em>FatFsユーザ・フォーラム</em></a></li>
|
||||||
<li><a href="ja/appnote.html">FatFsモジュール・アプリケーション・ノート</a> <span class="mfd">2009. 6. 21</span></li>
|
<li><a href="ja/appnote.html">FatFsモジュール・アプリケーション・ノート</a> <span class="mfd">2010. 1. 28</span></li>
|
||||||
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/">ARM-Projects by Martin THOMAS</a> (examples for LPC2000, AT91SAM and STM32)</li>
|
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/">ARM-Projects by Martin THOMAS</a> (examples for LPC2000, AT91SAM and STM32)</li>
|
||||||
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FATファイル・システム仕様書 by Microsoft</a> (FATの理解・実装に必要な唯一のリファレンス)</li>
|
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FATファイル・システム仕様書 by Microsoft</a> (FATの理解・実装に必要な唯一のリファレンス)</li>
|
||||||
<li><a href="http://elm-chan.org/docs/fat.html">FATファイル・システム概要</a></li>
|
<li><a href="http://elm-chan.org/docs/fat.html">FATファイル・システム概要</a></li>
|
||||||
@ -97,8 +97,5 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<hr>
|
|
||||||
<p class="foot"><a href="../../fsw.html">戻る</a></p>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -12,7 +12,7 @@ pre em {font-style: italic; font-weight: normal;}
|
|||||||
strong {}
|
strong {}
|
||||||
pre {margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; background-color: white;}
|
pre {margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; background-color: white;}
|
||||||
tt {margin: 0 0.2em;}
|
tt {margin: 0 0.2em;}
|
||||||
ol {margin: 0 2em;}
|
ol {margin: 0 2.5em;}
|
||||||
ul {margin: 0 2em;}
|
ul {margin: 0 2em;}
|
||||||
dl {margin: 0 1em;}
|
dl {margin: 0 1em;}
|
||||||
dt {font-family: monospace;}
|
dt {font-family: monospace;}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ pre em {font-style: italic; font-weight: normal;}
|
|||||||
strong {}
|
strong {}
|
||||||
pre {margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; letter-spacing: 0; background-color: white;}
|
pre {margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; letter-spacing: 0; background-color: white;}
|
||||||
tt {margin: 0 0.2em; letter-spacing: 0;}
|
tt {margin: 0 0.2em; letter-spacing: 0;}
|
||||||
ol {margin: 0 2em;}
|
ol {margin: 0 2.5em;}
|
||||||
ul {margin: 0 2em;}
|
ul {margin: 0 2em;}
|
||||||
dl {margin: 0 1em;}
|
dl {margin: 0 1em;}
|
||||||
dt {font-family: monospace;}
|
dt {font-family: monospace;}
|
||||||
|
|||||||
@ -13,29 +13,59 @@
|
|||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h3>Considerations on porting to various platform</h3>
|
<h3>Basic considerations on porting</h3>
|
||||||
<p>The FatFs module is assuming following terms on portability.</p>
|
<p>The FatFs module is assuming following terms on portability.</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>ANSI C<br>
|
<li>ANSI C<br>
|
||||||
The FatFs module is a middleware that written in ANSI C. There is no platform dependence, so long as the compiler is in compliance with ANSI C.</li>
|
The FatFs module is a middleware that written in ANSI C. There is no platform dependence, so long as the compiler is in compliance with ANSI C.</li>
|
||||||
<li>Size of integer types<br>
|
<li>Size of integer types<br>
|
||||||
The FatFs module assumes that size of char/short/long are 8/16/32-bit and int is 16 or 32 bit. These correspondence are defined in integer.h. This will not be a problem on most compilers. When any conflict with existing definitions is occured, you must resolve it with care.</li>
|
The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is 16 or 32 bit. These correspondence are defined in integer.h. This will not be a problem on most compilers. When any conflict with existing definitions is occured, you must resolve it with care.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h3>Memory Usage (R0.07c)</h3>
|
<h3>How to port</h3>
|
||||||
|
<p>You need to provide only low level disk I/O functions that required by FatFs module and nothing else. If a working disk module for the target is already existing, you need to write only glue functions to attach it to the FatFs module. If not, you need to port any other disk module or write it from scratch. All defined functions are not that always required. For example, disk write function is not required in read-only configuration. Following table shows which function is required depends on configuration options.</p>
|
||||||
<table class="lst2">
|
<table class="lst2">
|
||||||
<tr><th></th><th>AVR</th><th>H8/300H</th><th>PIC</th><th>TLCS-870/C</th><th>V850ES</th><th>SH2</th><th>ARM7TDMI</th><th>IA-32</th></tr>
|
<tr><th>Function</th><th>Required when:</th></tr>
|
||||||
<tr><td>Compiler</td><td>WinAVR(gcc)</td><td>CH38</td><td>C30(gcc)</td><td>CC870C</td><td>CA850</td><td>SHC</td><td>WinARM(gcc)</td><td>MSC</td></tr>
|
<tr><td>disk_initialize</td><td>Always</td></tr>
|
||||||
|
<tr><td>disk_status</td><td>Always</td></tr>
|
||||||
|
<tr><td>disk_read</td><td>Always</td></tr>
|
||||||
|
<tr><td>disk_write</td><td>_FS_READONLY == 0</td></tr>
|
||||||
|
<tr><td>disk_ioctl (CTRL_SYNC)</td><td>_FS_READONLY == 0</td></tr>
|
||||||
|
<tr><td>disk_ioctl (GET_SECTOR_COUNT)</td><td>_USE_MKFS == 1</td></tr>
|
||||||
|
<tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS >= 1024</td></tr>
|
||||||
|
<tr><td>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr>
|
||||||
|
<tr><td>get_fattime</td><td>_FS_READONLY == 0</td></tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h3>Limits</h3>
|
||||||
|
<ul>
|
||||||
|
<li>FAT sub-types: FAT12, FAT16 and FAT32.</li>
|
||||||
|
<li>Number of open files: Unlimited. Depends on available memory.</li>
|
||||||
|
<li>Number of volumes: Upto 10.</li>
|
||||||
|
<li>File size: Depends on FAT specs (4G-1 bytes). </li>
|
||||||
|
<li>Volume size: Depends on FAT specs (upto 2T,4T or 8T bytes). </li>
|
||||||
|
<li>Cluster size: Upto 64K bytes. Upto 32K bytes for f_mkfs().</li>
|
||||||
|
<li>Sector size: Depends on FAT specs (upto 4K bytes).</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h3>Memory Usage (R0.07e)</h3>
|
||||||
|
<table class="lst2">
|
||||||
|
<tr><th></th><th>AVR</th><th>H8/300H</th><th>PIC</th><th>TLCS-870/C</th><th>V850ES</th><th>SH2</th><th>ARM7TDMI</th><th>x86</th></tr>
|
||||||
|
<tr><td>Compiler</td><td>WinAVR(gcc)</td><td>CH38</td><td>C30(gcc)</td><td>CC870C</td><td>CA850</td><td>SHC</td><td>WinARM(gcc)</td><td>VC6</td></tr>
|
||||||
<tr><td>_WORD_ACCESS</td><td>1</td><td>0</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>1</td></tr>
|
<tr><td>_WORD_ACCESS</td><td>1</td><td>0</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>1</td></tr>
|
||||||
<tr class="lst3"><td>ROM (Full, R/W)</td><td>11962</td><td>10433</td><td>10753</td><td>15153</td><td>7747</td><td>8707</td><td>10584</td><td>7337</td></tr>
|
<tr class="lst3"><td>text (Full, R/W)</td><td>12194</td><td>10559</td><td>10924</td><td>15229</td><td>7686</td><td>8727</td><td>10564</td><td>7342</td></tr>
|
||||||
<tr><td>ROM (Min, R/W)</td><td>7466</td><td>6799</td><td>6772</td><td>9906</td><td>4901</td><td>5599</td><td>6548</td><td>4787</td></tr>
|
<tr> <td>text (Min, R/W)</td><td>7988</td><td>6903</td><td>7108</td><td>9960</td><td>4884</td><td>5651</td><td>6544</td><td>4764</td></tr>
|
||||||
<tr><td>ROM (Full, R/O)</td><td>5400</td><td>4687</td><td>4804</td><td>6744</td><td>3539</td><td>3799</td><td>4676</td><td>3380</td></tr>
|
<tr><td>text (Full, R/O)</td><td>5532</td><td>4753</td><td>5020</td><td>6760</td><td>3462</td><td>3777</td><td>4624</td><td>3316</td></tr>
|
||||||
<tr><td>ROM (Min, R/O)</td><td>3804</td><td>3527</td><td>3421</td><td>5040</td><td>2561</td><td>2867</td><td>3276</td><td>2533</td></tr>
|
<tr> <td>text (Min, R/O)</td><td>4040</td><td>3631</td><td>3736</td><td>5083</td><td>2556</td><td>2907</td><td>3284</td><td>2510</td></tr>
|
||||||
<tr><td>RAM (Static)</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
|
<tr><td>bss</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
|
||||||
<tr><td>RAM (Dynamic)<br>(_FS_TINY == 0)</td><td>D*560 +<br>F*544</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*544</td><td></td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td></tr>
|
<tr><td>Work area<br>(_FS_TINY == 0)</td><td>D*560 +<br>F*544</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*544</td><td></td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td></tr>
|
||||||
<tr><td>RAM (Dynamic)<br>(_FS_TINY == 1)</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td></tr>
|
<tr><td>Work area<br>(_FS_TINY == 1)</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p>These are the memory usage on some target systems with following condition. The memory sizes are in unit of byte, D means number of volumes and F means number of open files. All samples are optimezed in code size.</p>
|
<p>These are the memory usage on some target systems with following condition. The memory sizes are in unit of byte, D means number of volumes and F means number of open files. All samples are optimezed in code size.</p>
|
||||||
<pre>
|
<pre>
|
||||||
@ -89,17 +119,17 @@ _FS_REENTRANT 0 (Disable reentrancy)
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h3>Long File Name</h3>
|
<h3>Long File Name</h3>
|
||||||
<p>The FatFs module supports long file name (LFN) from revision 0.07. The two different file names, SFN and LFN, of a file is transparent in the file functions except for f_readdir function. To enable LFN feature, set <tt>_USE_LFN</tt> to 1 or 2, and add a Unicode code conversion function ff_convert and ff_wtoupper to the project. This function is available in <tt>cc*.c</tt>. The LFN feature requiers a certain working buffer in addition. The buffer size can be configured by <tt>_MAX_LFN</tt> corresponding to the available memory size. The size of long file name will reach up to 255 characters so that the <tt>_MAX_LFN</tt> should be set to 255 for full featured LFN operation. When the size of working buffer is insufficient for the given file name, the file function will fail with <tt>FR_INVALID_NAME</tt>. When enable the LFN feature with re-entrant feature, <tt>_USE_LFN</tt> must be set to 2. In this case, the file funciton allocates the working buffer on the stack. The working buffer occupies <tt>(_MAX_LFN + 1) * 2</tt> bytes so that the caller's stack must be a sufficient size considering the working buffer.</p>
|
<p>The FatFs module supports long file name (LFN) from revision 0.07. The two different file names, SFN and LFN, of a file is transparent in the file functions except for f_readdir function. To enable LFN feature, set <tt>_USE_LFN</tt> to 1 or 2, and add a Unicode code conversion function ff_convert and ff_wtoupper to the project. This function is available in <tt>cc*.c</tt>. The LFN feature requiers a certain working buffer in addition. The buffer size can be configured by <tt>_MAX_LFN</tt> corresponding to the available memory size. The size of long file name will reach up to 255 characters so that the <tt>_MAX_LFN</tt> should be set to 255 for full featured LFN operation. If the size of working buffer is insufficient for the given file name, the file function fails with <tt>FR_INVALID_NAME</tt>. When enable the LFN feature with re-entrant feature, <tt>_USE_LFN</tt> must be set to 2. In this case, the file function allocates the working buffer on the stack. The working buffer occupies <tt>(_MAX_LFN + 1) * 2</tt> bytes so that the caller's stack must be a sufficient size considering the working buffer.</p>
|
||||||
<table class="lst2 rset">
|
<table class="lst2 rset">
|
||||||
<caption>LFN cfg on ARM7</caption>
|
<caption>LFN cfg on ARM7</caption>
|
||||||
<tr><th>Code page</th><th>ROM size [bytes]</th></tr>
|
<tr><th>Code page</th><th>Program size</th></tr>
|
||||||
<tr><td>SBCS</td><td>+3721</td></tr>
|
<tr><td>SBCS</td><td>+3.7K</td></tr>
|
||||||
<tr><td>932(Shift-JIS)</td><td>+62609</td></tr>
|
<tr><td>932(Shift-JIS)</td><td>+62K</td></tr>
|
||||||
<tr><td>936(GBK)</td><td>+177797</td></tr>
|
<tr><td>936(GBK)</td><td>+177K</td></tr>
|
||||||
<tr><td>949(Korean)</td><td>+139857</td></tr>
|
<tr><td>949(Korean)</td><td>+139K</td></tr>
|
||||||
<tr><td>950(Big5)</td><td>+111497</td></tr>
|
<tr><td>950(Big5)</td><td>+111K</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p>When the LFN feature is enabled, the module size will be increased depends on the selected code page. Right table shows the difference in module size when LFN is enabled with some code pages. We are the Japanese, Chinese and Korean have tens of thousands of characters. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased that shown in the table. As the result, the FatFs with LFN will not able to be implemented to most 8-bit microcontrollers including AVR. <small>This is the reason why I had not been interested in implementing the LFN feature for a long time :-)</small></p>
|
<p>When the LFN feature is enabled, the module size will be increased depends on the selected code page. Right table shows how many bytes increased when LFN feature is enabled with some code pages. We are the Japanese, Chinese and Korean have tens of thousands of characters. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased that shown in the table. As the result, the FatFs with LFN will not able to be implemented to most 8-bit microcontrollers including AVR. <small>This is the reason why I had not been interested in implementing the LFN feature for a long time :-)</small></p>
|
||||||
<p>Note that the LFN feature on the FAT file system is a patent of Microsoft Corporation. When enable it on the commercial products, a license from Microsoft may be required depends on the final destination.</p>
|
<p>Note that the LFN feature on the FAT file system is a patent of Microsoft Corporation. When enable it on the commercial products, a license from Microsoft may be required depends on the final destination.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -135,7 +165,7 @@ _FS_REENTRANT 0 (Disable reentrancy)
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h3>Critical Section</h3>
|
<h3>Critical Section</h3>
|
||||||
<p>When write operation to the FAT file system is interrupted due to any accidental failure, such as sudden blackout, incorrect disk removal and unrecoverable disk error, the FAT structure can be collapted. Following images shows the critical section on the FatFs module.</p>
|
<p>When write operation to the FAT file system is interrupted due to any accidental failure, such as sudden blackout, incorrect disk removal and unrecoverable disk error, the FAT structure can be collapted. Following images shows the critical section on the FatFs application.</p>
|
||||||
<div class="lset">
|
<div class="lset">
|
||||||
Figure 4. Long critical section<br>
|
Figure 4. Long critical section<br>
|
||||||
<img src="../img/f4.png" width="320" height="436" alt="fig.4">
|
<img src="../img/f4.png" width="320" height="436" alt="fig.4">
|
||||||
@ -158,7 +188,29 @@ Figure 5. Minimized critical section<br>
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h3>Unicode API</h3>
|
<h3>Unicode API</h3>
|
||||||
<p>FatFs supports to switch the character encoding to Unicode on the API. For more information, refer to the description in the <a href="filename.html">file name</a>.</p>
|
<p>FatFs supports OEM code set on the API in default but FatFs can also switch the code set to Unicode. For more information, refer to the description in the <a href="filename.html">file name</a>.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h3>About FatFs License</h3>
|
||||||
|
<p>This is a copy of the FatFs license document that included in the source codes.</p>
|
||||||
|
<pre>/*----------------------------------------------------------------------------/
|
||||||
|
/ FatFs - FAT file system module R0.07e (C)ChaN, 2009
|
||||||
|
/-----------------------------------------------------------------------------/
|
||||||
|
/ FatFs module is a generic FAT file system module for small embedded systems.
|
||||||
|
/ This is a free software that opened for education, research and commercial
|
||||||
|
/ developments under license policy of following trems.
|
||||||
|
/
|
||||||
|
/ Copyright (C) 2009, ChaN, all right reserved.
|
||||||
|
/
|
||||||
|
/ * The FatFs module is a free software and there is NO WARRANTY.
|
||||||
|
/ * No restriction on use. You can use, modify and redistribute it for
|
||||||
|
/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
|
||||||
|
/ * Redistributions of source code must retain the above copyright notice.
|
||||||
|
/
|
||||||
|
/-----------------------------------------------------------------------------/</pre>
|
||||||
|
<p>Therefore FatFs license is one of the BSD-style license but there is a big difference. Because FatFs is for embedded projects, the conditions for redistributions in binary form, such as embedded code, hex file and binary library, are not specified to increase its usability. The documentation of the distributions need not include about FatFs and its license document, and it may also. Of course FatFs is compatible with the projects under GNU GPL. When redistribute it with any modification, the license can also be changed to GNU GPL or BSD license.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||||
|
|||||||
@ -49,14 +49,20 @@ FRESULT f_chdir (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>The logical drive has no work area.</dd>
|
<dd>The logical drive has no work area.</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>There is no valid FAT partition on the disk.</dd>
|
<dd>There is no valid FAT volume on the disk.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_chdir function changes the current directory of the logical drive. The current directory of a drive is initialized to the root directory when the drive is auto-mounted. Note that the current directory is retained in the each file system object so that it also affects other tasks that using the drive. This function is available when <tt>_FS_RPATH == 1</tt>.</p>
|
<p>The f_chdir function changes the current directory of the logical drive. The current directory of a drive is initialized to the root directory when the drive is auto-mounted. Note that the current directory is retained in the each file system object so that it also affects other tasks that using the drive.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_RPATH == 1</tt>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -72,7 +78,7 @@ FRESULT f_chdir (
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>See Also</h4>
|
||||||
<p><tt><a href="chdrive.html">f_chdrive</a></tt></p>
|
<p><tt><a href="chdrive.html">f_chdrive</a></tt></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -42,11 +42,17 @@ FRESULT f_chdrive (
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_chdrive function changes the current drive. The initial value of the current drive number is 0. Note that the current drive is retained in a static variable so that it also affects other tasks that using the file functions. This function is available when <tt>_FS_RPATH == 1</tt>.</p>
|
<p>The f_chdrive function changes the current drive. The initial value of the current drive number is 0. Note that the current drive is retained in a static variable so that it also affects other tasks that using the file functions.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_RPATH == 1</tt>.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>See Also</h4>
|
||||||
<p><tt><a href="chdir.html">f_chdir</a></tt></p>
|
<p><tt><a href="chdir.html">f_chdir</a></tt></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -67,14 +67,20 @@ FRESULT f_chmod (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>The logical drive has no work area.</dd>
|
<dd>The logical drive has no work area.</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>There is no valid FAT partition on the disk.</dd>
|
<dd>There is no valid FAT volume on the disk.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_chmod function changes the attribute of a file or directory. This function is not available in read-only configuration and minimization level of >=1.</p>
|
<p>The f_chmod function changes the attribute of a file or directory.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -53,7 +53,13 @@ FRESULT f_close (
|
|||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Always available.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>See Also</h4>
|
||||||
<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>
|
<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>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -32,12 +32,12 @@ DSTATUS disk_initialize (
|
|||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Return Values</h4>
|
<h4>Return Values</h4>
|
||||||
<p>This function returns a disk status as the result. For details of the disk status, refer to the <a href="dstat.html">disk_status</a> function.</p>
|
<p>This function returns a disk status as the result. For details of the disk status, refer to the <a href="dstat.html">disk_status</a> function.</p>
|
||||||
<p>This function is called from volume mount process in the FatFs module to manage the media change. Application program must not call this function while FatFs module is active, or FAT structure on the drive may be collapted.</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The disk_initialize function initializes a physical drive. When the function succeeded, <tt>STA_NOINIT</tt> flag in the return value is cleard.</p>
|
<p>The disk_initialize function initializes a physical drive. When the function succeeded, <tt>STA_NOINIT</tt> flag in the return value is cleard.</p>
|
||||||
|
<p>This function is called from volume mount process in the FatFs module to manage the media change. <em>Application program must not call this function while FatFs module is active, or FAT structure on the volume can be collapted. To re-initialize the file system, use f_mount function.</em></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
||||||
|
|||||||
@ -55,10 +55,9 @@ DRESULT disk_ioctl (
|
|||||||
<p>The FatFs module uses only device independent commands described below. Any device dependent function is not used.</p>
|
<p>The FatFs module uses only device independent commands described below. Any device dependent function is not used.</p>
|
||||||
<table class="lst">
|
<table class="lst">
|
||||||
<tr><th>Command</th><th>Description</th></tr>
|
<tr><th>Command</th><th>Description</th></tr>
|
||||||
<tr><td>CTRL_SYNC</td><td>Make sure that the disk drive has finished pending write process. When the disk I/O module has a write back cache, flush the dirty sector immediately. This function is not required in read-only configuration.</p>
|
<tr><td>CTRL_SYNC</td><td>Make sure that the disk drive has finished pending write process. When the disk I/O module has a write back cache, flush the dirty sector immediately. This command is not required in read-only configuration.</td></tr>
|
||||||
</td></tr>
|
<tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the drive into the WORD variable pointed by Buffer. This command is not required in single sector size configuration, _MAX_SS is 512.</td></tr>
|
||||||
<tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the drive into the WORD variable pointed by Buffer. This functions is not required in single sector size configuration, _MAX_SS is 512.</td></tr>
|
<tr><td>GET_SECTOR_COUNT</td><td>Returns total sectors on the drive into the DWORD variable pointed by Buffer. This command is used in only f_mkfs function.</td></tr>
|
||||||
<tr><td>GET_SECTOR_COUNT</td><td>Returns total sectors on the drive into the DWORD variable pointed by Buffer. This function is used in only f_mkfs function.</td></tr>
|
|
||||||
<tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the memory array in unit of sector into the DWORD variable pointed by Buffer. When the erase block size is unknown or magnetic disk device, return 1. This command is used in only f_mkfs function.</td></tr>
|
<tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the memory array in unit of sector into the DWORD variable pointed by Buffer. When the erase block size is unknown or magnetic disk device, return 1. This command is used in only f_mkfs function.</td></tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -29,7 +29,7 @@ DRESULT disk_read (
|
|||||||
<dt>Drive</dt>
|
<dt>Drive</dt>
|
||||||
<dd>Specifies the physical drive number.</dd>
|
<dd>Specifies the physical drive number.</dd>
|
||||||
<dt>Buffer</dt>
|
<dt>Buffer</dt>
|
||||||
<dd>Pointer to the byte array to store the read data. The buffer size of number of bytes to be read is required. The start address specified by upper layer may be aligned or non-aligned.</dd>
|
<dd>Pointer to the byte array to store the read data. The buffer size of number of bytes to be read, sector size * sector count, is required. The memory address specified by upper layer may or may not be aligned to word boundary.</dd>
|
||||||
<dt>SectorNumber</dt>
|
<dt>SectorNumber</dt>
|
||||||
<dd>Specifies the start sector number in logical block address (LBA).</dd>
|
<dd>Specifies the start sector number in logical block address (LBA).</dd>
|
||||||
<dt>SectorCount</dt>
|
<dt>SectorCount</dt>
|
||||||
|
|||||||
@ -29,7 +29,7 @@ DRESULT disk_write (
|
|||||||
<dt>Drive</dt>
|
<dt>Drive</dt>
|
||||||
<dd>Specifies the physical drive number.</dd>
|
<dd>Specifies the physical drive number.</dd>
|
||||||
<dt>Buffer</dt>
|
<dt>Buffer</dt>
|
||||||
<dd>Pointer to the byte array to be written. The start address specified by upper layer may be aligned or non-aligned.</dd>
|
<dd>Pointer to the byte array to be written. The memory address specified by upper layer may or may not be aligned to word boundary.</dd>
|
||||||
<dt>SectorNumber</dt>
|
<dt>SectorNumber</dt>
|
||||||
<dd>Specifies the start sector number in logical block address (LBA).</dd>
|
<dd>Specifies the start sector number in logical block address (LBA).</dd>
|
||||||
<dt>SectorCount</dt>
|
<dt>SectorCount</dt>
|
||||||
|
|||||||
@ -41,7 +41,7 @@ DWORD get_fattime (void);
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The get_fattime function must return any valid time even if the system does not support a real time clock. This fucntion is not required in read only configuration.</p>
|
<p>The get_fattime function must return any valid time even if the system does not support a real time clock. If a zero is returned, the file will not have a valid time. This fucntion is not required in read only configuration.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -12,13 +12,13 @@
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h2>Format of the path names</h2>
|
<h2>Format of the path names</h2>
|
||||||
<p>The path name format on the FatFs module is similer to MS-DOS as follows.</p>
|
<p>The path name format on the FatFs module is similer to the filename specs of DOS/Windos as follows:</p>
|
||||||
<pre>
|
<pre>
|
||||||
"[<em>drive#</em>:][/]<em>directory</em>/<em>file</em>"
|
"[<em>drive#</em>:][/]<em>directory</em>/<em>file</em>"
|
||||||
</pre>
|
</pre>
|
||||||
<p>The FatFs module supports long file name and 8.3 format file name. The long file name can be handled in LFN configuration <tt>(_USE_LFN == 1)</tt>. The path names are input/output in local code (SBCS/MBCS) or Unicode string depends on the configuration options. The sub directories are separated with a / or \. The logical drive number is specified in a numeral with a colon. When the drive number is omitted, it is assumed as default drive (0 or current drive).</p>
|
<p>The FatFs module supports long file name (LFN) and 8.3 format file name (SFN). The LFN can be used when LFN feature is enabled <tt>(_USE_LFN > 0)</tt>. The differences between DOS/Windows are directory separator and logical drive number. The sub directories are separated with a / or \. The logical drive is specified in a numeral with a colon. When the drive number is omitted, it is assumed as default drive (0 or current drive). Leading/embedded spaces in the given path name are valid as a part of the name on LFN configuration but they are recognized as end of the path name on non-LFN configuration.</p>
|
||||||
<p>In default configuration <tt>(_FS_RPATH == 0)</tt>, it does not have a concept of current directory like OS oriented file system. All objects on the volume are always specified in full path name following from the root directory. Dot names are not available. Heading separator is ignored and it can be exist or omitted. The default drive number is fixed to 0.</p>
|
<p>In default configuration <tt>(_FS_RPATH == 0)</tt>, it does not have a concept of current directory like OS oriented file system. All objects on the volume are always specified in full path name that follows from the root directory. Dot directory names are not allowed. Heading separator is ignored and it can be exist or omitted. The default drive number is fixed to 0.</p>
|
||||||
<p>When relative path feature is enabled <tt>(_FS_RPATH == 1)</tt>, specified path is followed from the root directory if a heading separator is exist. If not, the path is followed from the current directory set with <a href="chdir.html">f_chdir</a> function. Dot names are also available for the path name. The default drive number is the current drive number set with <a href="chdrive.html">f_chdrive</a> function.</p>
|
<p>When relative path feature is enabled <tt>(_FS_RPATH == 1)</tt>, specified path is followed from the root directory if a heading separator is exist. If not, the path is followed from the current directory set with <a href="chdir.html">f_chdir</a> function. Dot names are also allowed for the directory name. The default drive number is the current drive number set with <a href="chdrive.html">f_chdrive</a> function.</p>
|
||||||
<table class="lst2">
|
<table class="lst2">
|
||||||
<tr><td>Path name</td><td>_FS_RPATH == 0</td><td>_FS_RPATH == 1</td></tr>
|
<tr><td>Path name</td><td>_FS_RPATH == 0</td><td>_FS_RPATH == 1</td></tr>
|
||||||
<tr class="lst3"><td>file.txt</td><td>A file in the root directory on the drive 0</td><td>A file in the current directory on the current drive</td></tr>
|
<tr class="lst3"><td>file.txt</td><td>A file in the root directory on the drive 0</td><td>A file in the current directory on the current drive</td></tr>
|
||||||
@ -38,7 +38,7 @@
|
|||||||
<p><br></p>
|
<p><br></p>
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h2>Unicode API</h2>
|
<h2>Unicode API</h2>
|
||||||
<p>The type of arguments that specifies the file names are defined as <tt>XCHAR</tt>, which is the alias of <tt>char</tt> in default. The code set of the file name string is the local code set that specifid by <tt>_CODE_PAGE</tt>. When <tt>_LFN_UNICODE</tt> is set to 1 with LFN configuration, the type of the <tt>XCHAR</tt> is switched to <tt>unsigned short</tt> (wide character) to support Unicode. In this case, the LFN feature is fully supported and the Unicode specific characters, such as ♥, ☭ and ❶, can also be used.</p>
|
<p>The path names are input/output in either OEM code (SBCS/DBCS) or Unicode depends on the configuration options. The type of arguments that specifies the file names are defined as <tt>XCHAR</tt> which is an alias of <tt>char</tt> in default. The code set of the file name string is the OEM code set specifid by <tt>_CODE_PAGE</tt>. When <tt>_LFN_UNICODE</tt> is set to 1 under LFN configuration, the type of the <tt>XCHAR</tt> is switched to <tt>unsigned short</tt> (wide character) to support Unicode. In this case, the LFN feature is fully supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p><br></p>
|
<p><br></p>
|
||||||
@ -56,11 +56,11 @@ const PARTITION Drives[] = {
|
|||||||
{1, 0} /* Logical drive 3 ==> Physical drive 1 */
|
{1, 0} /* Logical drive 3 ==> Physical drive 1 */
|
||||||
};
|
};
|
||||||
</pre>
|
</pre>
|
||||||
<p>There are some consideration when use <tt>_MULTI_PARTITION</tt> configuration.</p>
|
<p>There are some considerations when use <tt>_MULTI_PARTITION</tt> configuration.</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Only pri-partition (0-3) can be mounted.</li>
|
<li>Only pri-partition (0-3) can be mounted.</li>
|
||||||
<li>When the physical drive has no partition table (SFD format), the partition number is ignored.</li>
|
<li>When the physical drive has no partition table (SFD format), the partition number is ignored.</li>
|
||||||
<li>The physical drive that has two or more logical drives must not be removable drive.</li>
|
<li>The physical drive that has two or more logical drives must be a fixed drive.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,12 @@ FRESULT f_forward (
|
|||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_forward function reads the data from the file and forward it to the outgoing stream without data buffer. This is suitable for small memory system because it does not require any data buffer at application module. The file pointer of the file object increases in number of bytes forwarded. In case of <tt>*ByteFwd < ByteToFwd</tt> without error, it means the requested bytes could not be transferred due to end of file or stream goes busy during data transfer.</p>
|
<p>The f_forward function reads the data from the file and forward it to the outgoing stream without data buffer. This is suitable for small memory system because it does not require any data buffer at application module. The file pointer of the file object increases in number of bytes forwarded. In case of <tt>*ByteFwd < ByteToFwd</tt> without error, it means the requested bytes could not be transferred due to end of file or stream goes busy during data transfer.</p>
|
||||||
<p>This function is available on <tt>_USE_FORWARD == 1</tt> and <tt>_FS_TINY == 1</tt>.</p>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_USE_FORWARD == 1</tt> and <tt>_FS_TINY == 1</tt>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -128,7 +133,7 @@ FRESULT play_file (
|
|||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>See Also</h4>
|
||||||
<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>
|
<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>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -59,7 +59,12 @@ FRESULT f_getfree (
|
|||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Descriptions</h4>
|
<h4>Descriptions</h4>
|
||||||
<p>The f_getfree function gets number of free clusters on the drive. The member <tt>csize</tt> in the file system object is refrecting number of sectors per cluster, so that the free space in unit of sector can be calcurated with this. When FSInfo structure on FAT32 volume is not in sync, this function can return an incorrect free cluster count.</p>
|
<p>The f_getfree function gets number of free clusters on the drive. The member <tt>csize</tt> in the file system object is refrecting number of sectors per cluster, so that the free space in unit of sector can be calcurated with this. When FSInfo structure on FAT32 volume is not in sync, this function can return an incorrect free cluster count.</p>
|
||||||
<p>This function is not supported in read-only configuration and minimization level of >= 1.</p>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -70,15 +75,15 @@ FRESULT f_getfree (
|
|||||||
DWORD fre_clust, fre_sect, tot_sect;
|
DWORD fre_clust, fre_sect, tot_sect;
|
||||||
|
|
||||||
|
|
||||||
// Get drive information and free clusters
|
/* Get drive information and free clusters */
|
||||||
res = f_getfree("/", &fre_clust, &fs);
|
res = f_getfree("/", &fre_clust, &fs);
|
||||||
if (res) die(res);
|
if (res) die(res);
|
||||||
|
|
||||||
// Get total sectors and free sectors
|
/* Get total sectors and free sectors */
|
||||||
tot_sect = (fs->max_clust - 2) * fs->csize;
|
tot_sect = (fs->max_clust - 2) * fs->csize;
|
||||||
fre_sect = fre_clust * fs->csize;
|
fre_sect = fre_clust * fs->csize;
|
||||||
|
|
||||||
// Print free space in unit of KB (assuming 512B/sector)
|
/* Print free space in unit of KB (assuming 512B/sector) */
|
||||||
printf("%lu KB total drive space.\n"
|
printf("%lu KB total drive space.\n"
|
||||||
"%lu KB available.\n",
|
"%lu KB available.\n",
|
||||||
fre_sect / 2, tot_sect / 2);
|
fre_sect / 2, tot_sect / 2);
|
||||||
@ -87,7 +92,7 @@ FRESULT f_getfree (
|
|||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>See Also</h4>
|
||||||
<p><tt><a href="sfatfs.html">FATFS</a></tt></p>
|
<p><tt><a href="sfatfs.html">FATFS</a></tt></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -44,12 +44,17 @@ char* f_gets (
|
|||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_gets() is a wrapper function of <a href="read.html">f_read()</a>. The read operation continues until a <tt>'\n'</tt> is stored, reached end of file or buffer is filled with Size - 1 characters. The read string is terminated with a <tt>'\0'</tt>. When the file has reached end of the file or any error occured during read operation, f_gets() returns a <tt>NULL</tt>. The EOF and error status can be examined with <tt>f_eof()</tt> and <tt>f_error()</tt> macro.</p>
|
<p>The f_gets() is a wrapper function of <a href="read.html">f_read()</a>. The read operation continues until a <tt>'\n'</tt> is stored, reached end of file or buffer is filled with Size - 1 characters. The read string is terminated with a <tt>'\0'</tt>. When the file has reached end of the file or any error occured during read operation, f_gets() returns a <tt>NULL</tt>. The EOF and error status can be examined with <tt>f_eof()</tt> and <tt>f_error()</tt> macro.</p>
|
||||||
<p>This function is available when <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\r'</tt> contained in the file is stripped.</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\r'</tt>s contained in the file are stripped out.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>See Also</h4>
|
||||||
<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>
|
<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>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h2>f_lseek</h2>
|
<h2>f_lseek</h2>
|
||||||
<p>The f_lseek function moves the file read/write pointer of an open file object. It can also be used to extend the file size (cluster pre-allocation).</p>
|
<p>The f_lseek function moves the file read/write pointer of an open file object. It can also be used to increase the file size (cluster pre-allocation).</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
FRESULT f_lseek (
|
FRESULT f_lseek (
|
||||||
@ -52,51 +52,57 @@ FRESULT f_lseek (
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_lseek function moves the file R/W pointer of an open file. The offset can be specified in only origin from top of the file. When an offset above the file size is specified in write mode, the file size is extended to the offset and the data in the extended area is undefined. This is suitable to create a large file quickly, for fast write operation. After the f_lseek function succeeded, member fptr in the file object should be checked in order to make sure the R/W pointer has been moved correctry. In case of fptr is less than expected value, any of the followings has been occured.</p>
|
<p>The f_lseek function moves the file R/W pointer of an open file. The offset can be specified in only origin from top of the file. When an offset above the file size is specified in write mode, the file size is increased and the data in the expanded area is undefined. This is suitable to create a large file quickly, for fast write operation. After the f_lseek function succeeded, member fptr in the file object should be checked in order to make sure the R/W pointer has been moved correctry. In case of fptr is not the expected value, either of followings has been occured.</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>In read-only mode, the Offset was clipped in file size.</li>
|
<li>End of file. The specified Offset was clipped at the file size because the file has been opened in read-only mode.</li>
|
||||||
<li>The drive gets full during the file extending process.</li>
|
<li>Disk full. There is insufficient free space on the volume to expand the file size.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>This function is not supported in minimization level of >= 3.</p></div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_MINIMIZE <= 2</tt>.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Example</h4>
|
<h4>Example</h4>
|
||||||
<pre>
|
<pre>
|
||||||
// Move to offset of 5000 from top of the file.
|
/* Move to offset of 5000 from top of the file */
|
||||||
res = f_lseek(&file, 5000);
|
res = f_lseek(file, 5000);
|
||||||
|
|
||||||
// Move to end of the file to append data
|
/* Move to end of the file to append data */
|
||||||
res = f_lseek(&file, file.fsize);
|
res = f_lseek(file, file->fsize);
|
||||||
|
|
||||||
// Forward 3000 bytes
|
/* Forward 3000 bytes */
|
||||||
res = f_lseek(&file, file.fptr + 3000);
|
res = f_lseek(file, file->fptr + 3000);
|
||||||
|
|
||||||
// Rewind 2000 bytes (take care on overflow)
|
/* Rewind 2000 bytes (take care on overflow) */
|
||||||
res = f_lseek(&file, file.fptr - 2000);
|
res = f_lseek(file, file->fptr - 2000);
|
||||||
</pre>
|
</pre>
|
||||||
<pre>
|
<pre>
|
||||||
// Cluster pre-allocation (to prevent buffer overrun on streaming write)
|
/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */
|
||||||
|
|
||||||
res = f_open(&file, recfile, FA_CREATE_NEW | FA_WRITE); // Create a file
|
res = f_open(file, recfile, FA_CREATE_NEW | FA_WRITE); /* Create a file */
|
||||||
|
|
||||||
res = f_lseek(&file, PRE_SIZE); // Pre-allocate clusters
|
res = f_lseek(file, PRE_SIZE); /* Pre-allocate clusters */
|
||||||
if (res || file.fptr != PRE_SIZE) .... // Check if the file is extended corrctly
|
if (res || file->fptr != PRE_SIZE) ... /* Check if the file size has been increased correctly */
|
||||||
|
|
||||||
res = f_lseek(&file, DATA_START); // Record data stream without cluster allocation delay
|
res = f_lseek(file, DATA_START); /* Record data stream without cluster allocation delay */
|
||||||
...
|
...
|
||||||
|
|
||||||
res = f_truncate(&file); // Truncate unused area
|
res = f_truncate(file); /* Truncate unused area */
|
||||||
res = f_lseek(&file, 0); // Put file header
|
res = f_lseek(file, 0); /* Put file header */
|
||||||
...
|
...
|
||||||
|
|
||||||
res = f_close(&file);
|
res = f_close(file);
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>See Also</h4>
|
||||||
<p><tt><a href="open.html">f_open</a>, <a href="truncate.html">f_truncate</a>, <a href="sfile.html">FIL</a></tt></p>
|
<p><tt><a href="open.html">f_open</a>, <a href="truncate.html">f_truncate</a>, <a href="sfile.html">FIL</a></tt></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -55,14 +55,20 @@ FRESULT f_mkdir (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>The logical drive has no work area.</dd>
|
<dd>The logical drive has no work area.</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>There is no valid FAT partition on the disk.</dd>
|
<dd>There is no valid FAT volume on the disk.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_mkdir function creates a new directory. This function is not supported in read-only configuration and minimization level of >= 1.</p>
|
<p>The f_mkdir function creates a new directory.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
FRESULT f_mkfs (
|
FRESULT f_mkfs (
|
||||||
BYTE <em>Drive</em>, /* Logical drive number */
|
BYTE <em>Drive</em>, /* Logical drive number */
|
||||||
BYTE <em>PartitioningRule</em>, /* Partitioning rule */
|
BYTE <em>PartitioningRule</em>, /* Partitioning rule */
|
||||||
WORD <em>AllocSize</em> /* Allocation unit size */
|
WORD <em>AllocSize</em> /* Size of the allocation unit */
|
||||||
);
|
);
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
@ -28,9 +28,9 @@ FRESULT f_mkfs (
|
|||||||
<dt>Drive</dt>
|
<dt>Drive</dt>
|
||||||
<dd>Logical drive number (0-9) to be formatted.</dd>
|
<dd>Logical drive number (0-9) to be formatted.</dd>
|
||||||
<dt>PartitioningRule</dt>
|
<dt>PartitioningRule</dt>
|
||||||
<dd>When 0 is given, a partition table is created into first sector on the drive and then the file system is created on the partition. This is called FDISK format. When 1 is given, the file system starts from the first sector without partition table. This is often called super floppy (SFD) format.</dd>
|
<dd>When 0 is given, a partition table is created into the first sector on the drive and then the file system is created on the partition. This is called FDISK format and used for harddisk and memory card. When 1 is given, the file system starts from the first sector without partition table. This is often called super floppy disk (SFD) format and used for floppy disk and removable disk.</dd>
|
||||||
<dt>AllocSize</dt>
|
<dt>AllocSize</dt>
|
||||||
<dd>Specifies allocation unit size in number of bytes per cluster. The value must be 0 or power of 2 in range of from 512 to 32768. When 0 is specified, the cluster size is determined by the drive size. FAT64 (64KB/cluster on FAT16) cannot be created by this function.</dd>
|
<dd>Specifies allocation unit size in number of bytes per cluster. The value must be 0 or power of 2 in range of from 512 to 32768. When 0 is specified, the cluster size is determined depends on the volume size. FAT64 (64KB/cluster on FAT16) cannot be created by this function.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -63,8 +63,13 @@ FRESULT f_mkfs (
|
|||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_mkfs function creates a FAT file system on the drive. There are two partitioning rules, FDISK and SFD, for removable media. It can be selected with an argument. The FDISK format is recommended for the most case. This function currently <em>does not support multiple partition</em>, so that existing partitions on the physical dirve will be deleted and re-created a new partition occupies entire disk space.</p>
|
<p>The f_mkfs function creates a FAT file system on the drive. There are two partitioning rules, FDISK and SFD, for removable media. It can be selected with an argument. The FDISK format is recommended for the most case. This function currently <em>does not support multiple partition</em>, so that existing partitions on the physical dirve will be deleted and re-created a new partition occupies entire disk space.</p>
|
||||||
<p>The FAT sub-type, FAT12/FAT16/FAT32, is determined by number of clusters on the drive and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the partition size and the specified cluster size. The cluster size affects performance of the file system and large cluster increases the performance.</p>
|
<p>The FAT sub-type, FAT12/FAT16/FAT32, is determined by number of clusters on the drive and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the volume size and the specified cluster size. The cluster size affects performance of the file system and large cluster increases the performance.</p>
|
||||||
<p>This function is supported on only _USE_MKFS option is selected.</p>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_READOLNY == 0</tt> and <tt>_USE_MKFS == 1</tt>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -44,13 +44,19 @@ FRESULT f_mount (
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_mount function registers/unregisters a work area to the FatFs module. The work area must be given to the logical drive with this function prior to any other file function. To unregister a work area, specify a NULL to the <em>FileSystemObject</em>, and then the work area can be discarded.</p>
|
<p>The f_mount function registers/unregisters a work area to the FatFs module. The work area must be given to the each volume with this function prior to use any other file function. To unregister a work area, specify a NULL to the <em>FileSystemObject</em>, and then the work area can be discarded.</p>
|
||||||
<p>This function only initializes the given work area and registers its address to the internal table, any access to the disk I/O layer does not occure. The volume mount process is performed on first file access after f_mount or media change.</p>
|
<p>This function only initializes the given work area and registers its address to the internal table, any access to the disk I/O layer does not occure. The volume mount process is performed on first file access after f_mount function or media change.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Always available.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>See Also</h4>
|
||||||
<p><tt><a href="sfatfs.html">FATFS</a></tt></p>
|
<p><tt><a href="sfatfs.html">FATFS</a></tt></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ FRESULT f_open (
|
|||||||
<h4>Parameters</h4>
|
<h4>Parameters</h4>
|
||||||
<dl class="par">
|
<dl class="par">
|
||||||
<dt>FileObject</dt>
|
<dt>FileObject</dt>
|
||||||
<dd>Pointer to the file object structure to be created. After the f_open funciton succeeded, the file can be accessed with the file object structure until it is closed.</dd>
|
<dd>Pointer to the file object structure to be created.</dd>
|
||||||
<dt>FileName</dt>
|
<dt>FileName</dt>
|
||||||
<dd>Pointer to a null-terminated string that specifies the <a href="filename.html">file name</a> to create or open.</dd>
|
<dd>Pointer to a null-terminated string that specifies the <a href="filename.html">file name</a> to create or open.</dd>
|
||||||
<dt>ModeFlags</dt>
|
<dt>ModeFlags</dt>
|
||||||
@ -36,7 +36,7 @@ FRESULT f_open (
|
|||||||
<tr><td>FA_READ</td><td>Specifies read access to the object. Data can be read from the file.<br>Combine with FA_WRITE for read-write access.</td></tr>
|
<tr><td>FA_READ</td><td>Specifies read access to the object. Data can be read from the file.<br>Combine with FA_WRITE for read-write access.</td></tr>
|
||||||
<tr><td>FA_WRITE</td><td>Specifies write access to the object. Data can be written to the file.<br>Combine with FA_READ for read-write access.</td></tr>
|
<tr><td>FA_WRITE</td><td>Specifies write access to the object. Data can be written to the file.<br>Combine with FA_READ for read-write access.</td></tr>
|
||||||
<tr><td>FA_OPEN_EXISTING</td><td>Opens the file. The function fails if the file is not existing. (Default)</td></tr>
|
<tr><td>FA_OPEN_EXISTING</td><td>Opens the file. The function fails if the file is not existing. (Default)</td></tr>
|
||||||
<tr><td>FA_OPEN_ALWAYS</td><td>Opens the file, if it is existing. If not, the function creates the new file.</td></tr>
|
<tr><td>FA_OPEN_ALWAYS</td><td>Opens the file, if it is existing. If not, a new file is created.</td></tr>
|
||||||
<tr><td>FA_CREATE_NEW</td><td>Creates a new file. The function fails if the file is already existing.</td></tr>
|
<tr><td>FA_CREATE_NEW</td><td>Creates a new file. The function fails if the file is already existing.</td></tr>
|
||||||
<tr><td>FA_CREATE_ALWAYS</td><td>Creates a new file. If the file is existing, it is truncated and overwritten.</td></tr>
|
<tr><td>FA_CREATE_ALWAYS</td><td>Creates a new file. If the file is existing, it is truncated and overwritten.</td></tr>
|
||||||
</table>
|
</table>
|
||||||
@ -76,16 +76,21 @@ FRESULT f_open (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>The logical drive has no work area.</dd>
|
<dd>The logical drive has no work area.</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>There is no valid FAT partition on the disk.</dd>
|
<dd>There is no valid FAT volume on the disk.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The created file object is used for subsequent calls to refer to the file. When close an open file object, use <a href="close.html">f_close</a> function. If the modified file is not closed, the file may be collapsed.</p>
|
<p>A file object is created when the function succeeded. The file object is used for subsequent read/write functions to refer to the file. When close an open file object, use <a href="close.html">f_close</a> function. If the modified file is not closed, the file may be collapsed.</p>
|
||||||
<p>Before using any file function, a work area (file system object) must be given to the logical drive with <a href="mount.html">f_mount</a> function. All file functions can work after this procedure.</p>
|
<p>Before using any file function, a work area (file system object) must be given to the logical drive with <a href="mount.html">f_mount</a> function. All file functions can work after this procedure.</p>
|
||||||
<p>The mode flags, <tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>, are not available in read-only configuration.</p>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Always available. The mode flags, <tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>, are not available when <tt>_FS_READONLY == 1</tt>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -94,38 +99,38 @@ FRESULT f_open (
|
|||||||
<pre>
|
<pre>
|
||||||
void main (void)
|
void main (void)
|
||||||
{
|
{
|
||||||
FATFS fs[2]; // Work area (file system object) for logical drives
|
FATFS fs[2]; /* Work area (file system object) for logical drives */
|
||||||
FIL fsrc, fdst; // file objects
|
FIL fsrc, fdst; /* file objects */
|
||||||
BYTE buffer[4096]; // file copy buffer
|
BYTE buffer[4096]; /* file copy buffer */
|
||||||
FRESULT res; // FatFs function common result code
|
FRESULT res; /* FatFs function common result code */
|
||||||
UINT br, bw; // File R/W count
|
UINT br, bw; /* File R/W count */
|
||||||
|
|
||||||
|
|
||||||
// Register work area for logical drives
|
/* Register work area for logical drives */
|
||||||
f_mount(0, &fs[0]);
|
f_mount(0, &fs[0]);
|
||||||
f_mount(1, &fs[1]);
|
f_mount(1, &fs[1]);
|
||||||
|
|
||||||
// Open source file on the drive 1
|
/* Open source file on the drive 1 */
|
||||||
res = f_open(&fsrc, "1:srcfile.dat", FA_OPEN_EXISTING | FA_READ);
|
res = f_open(&fsrc, "1:srcfile.dat", FA_OPEN_EXISTING | FA_READ);
|
||||||
if (res) die(res);
|
if (res) die(res);
|
||||||
|
|
||||||
// Create destination file on the drive 0
|
/* Create destination file on the drive 0 */
|
||||||
res = f_open(&fdst, "0:dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE);
|
res = f_open(&fdst, "0:dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE);
|
||||||
if (res) die(res);
|
if (res) die(res);
|
||||||
|
|
||||||
// Copy source to destination
|
/* Copy source to destination */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
res = f_read(&fsrc, buffer, sizeof(buffer), &br);
|
res = f_read(&fsrc, buffer, sizeof(buffer), &br);
|
||||||
if (res || br == 0) break; // error or eof
|
if (res || br == 0) break; /* error or eof */
|
||||||
res = f_write(&fdst, buffer, br, &bw);
|
res = f_write(&fdst, buffer, br, &bw);
|
||||||
if (res || bw < br) break; // error or disk full
|
if (res || bw < br) break; /* error or disk full */
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close all files
|
/* Close open files */
|
||||||
f_close(&fsrc);
|
f_close(&fsrc);
|
||||||
f_close(&fdst);
|
f_close(&fdst);
|
||||||
|
|
||||||
// Unregister work area before discard it
|
/* Unregister work area prior to discard it */
|
||||||
f_mount(0, NULL);
|
f_mount(0, NULL);
|
||||||
f_mount(1, NULL);
|
f_mount(1, NULL);
|
||||||
}
|
}
|
||||||
@ -134,7 +139,7 @@ void main (void)
|
|||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>See Also</h4>
|
||||||
<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>
|
<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>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -52,19 +52,25 @@ FRESULT f_opendir (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>The logical drive has no work area.</dd>
|
<dd>The logical drive has no work area.</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>There is no valid FAT partition on the disk.</dd>
|
<dd>There is no valid FAT volume on the disk.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_opendir function opens an exsisting directory and creates the directory object for subsequent calls. The directory object structure can be discarded at any time without any procedure. This function is not supported in minimization level of >=2.</p>
|
<p>The f_opendir function opens an exsisting directory and creates the directory object for subsequent calls. The directory object structure can be discarded at any time without any procedure.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_MINIMIZE <= 1</tt>.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>See Also</h4>
|
||||||
<p><tt><a href="readdir.html">f_readdir</a>, <a href="sdir.html">DIR</a></tt></p>
|
<p><tt><a href="readdir.html">f_readdir</a>, <a href="sdir.html">DIR</a></tt></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -44,26 +44,36 @@ int f_printf (
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_printf() is a wrapper function of <a href="putc.html">f_putc()</a> and <a href="puts.html">f_puts()</a>. The format control directive is a sub-set of standard library. It supports <tt>c s d u X</tt> for the data type, <tt>l</tt> for the precision and <tt>0</tt> for the flags.</p>
|
<p>The f_printf() is a wrapper function of <a href="putc.html">f_putc()</a> and <a href="puts.html">f_puts()</a>. The format control directive is a sub-set of standard library shown as follos:</p>
|
||||||
<p>This function is available when read-write configuration and <tt>_USE_STRFUNC</tt> is 1 or 2.</p>
|
<ul>
|
||||||
|
<li>Type: <tt>c s d u X</tt></li>
|
||||||
|
<li>Size: <tt>l</tt></li>
|
||||||
|
<li>Flag: <tt>0</tt></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\n'</tt>s contained in the output are converted to <tt>"\r\n"</tt>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Example</h4>
|
<h4>Example</h4>
|
||||||
<pre>
|
<pre>
|
||||||
f_printf(&fil, "%6d", -200); // " -200"
|
f_printf(&fil, "%6d", -200); /* " -200" */
|
||||||
f_printf(&fil, "%02u", 5); // "05"
|
f_printf(&fil, "%02u", 5); /* "05" */
|
||||||
f_printf(&fil, "%ld", 12345678L); // "12345678"
|
f_printf(&fil, "%ld", 12345678L); /* "12345678" */
|
||||||
f_printf(&fil, "%08lX", 1194684UL); // "00123ABC"
|
f_printf(&fil, "%08lX", 1194684UL); /* "00123ABC" */
|
||||||
f_printf(&fil, "%s", "String"); // "String"
|
f_printf(&fil, "%s", "String"); /* "String" */
|
||||||
f_printf(&fil, "%c", 'a'); // "a"
|
f_printf(&fil, "%c", 'a'); /* "a" */
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>See Also</h4>
|
||||||
<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>
|
<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>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -40,12 +40,18 @@ int f_putc (
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_putc() is a wrapper function of <a href="write.html">f_write()</a>. This function is available when read-write configuration and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set 2, a <tt>'\n'</tt> is extended to <tt>"\r\n"</tt>.</p>
|
<p>The f_putc() is a wrapper function of <a href="write.html">f_write()</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Reference</h4>
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, a <tt>'\n'</tt> is converted to <tt>"\r\n"</tt>.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>See Also</h4>
|
||||||
<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>
|
<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>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -34,18 +34,24 @@ int f_puts (
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Return Value</h4>
|
<h4>Return Value</h4>
|
||||||
<p>When the function succeeded, number of characters written (not minus value) is returned. When the function failed due to disk full or any error, an <tt>EOF</tt> will be returned.</p>
|
<p>When the function succeeded, number of characters written that is not minus value is returned. When the function failed due to disk full or any error, an <tt>EOF</tt> will be returned.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_puts() is a wrapper function of <a href="putc.html">f_putc()</a>. This function is available when read-write configuration and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set 2, a <tt>'\n'</tt> is extended to <tt>"\r\n"</tt>.</p>
|
<p>The f_puts() is a wrapper function of <a href="putc.html">f_putc()</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Reference</h4>
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\n'</tt>s contained in the string are converted to <tt>"\r\n"</tt>.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>See Also</h4>
|
||||||
<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>
|
<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>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@ FRESULT f_read (
|
|||||||
<dt>ByteToRead</dt>
|
<dt>ByteToRead</dt>
|
||||||
<dd>Number of bytes to read in range of UINT.</dd>
|
<dd>Number of bytes to read in range of UINT.</dd>
|
||||||
<dt>ByteRead</dt>
|
<dt>ByteRead</dt>
|
||||||
<dd>Pointer to the UINT variable to return number of bytes read. Return value is always valid after the function call.</dd>
|
<dd>Pointer to the UINT variable to return number of bytes read. The value is always valid after the function call regardless of the result.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -59,12 +59,18 @@ FRESULT f_read (
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The file pointer of the file object increases in number of bytes read. After the function succeeded, <tt>*ByteRead</tt> should be checked to detect end of file. In case of <tt>*ByteRead < ByteToRead</tt>, it means the R/W pointer reached end of file during read operation.</p>
|
<p>The file pointer of the file object increases in number of bytes read. After the function succeeded, <tt>*ByteRead</tt> should be checked to detect the end of file. In case of <tt>*ByteRead < ByteToRead</tt>, it means the R/W pointer reached end of the file during read operation.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Always available.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>See Also</h4>
|
||||||
<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>
|
<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>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -52,9 +52,14 @@ FRESULT f_readdir (
|
|||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_readdir function reads directory entries in sequence. All items in the directory can be read by calling f_readdir function repeatedly. When all directory entries have been read and no item to read, the function returns a null string into <tt>f_name[]</tt> member without any error. When a null pointer is given to the <tt>FileInfo</tt>, the read index of the directory object will be rewinded.</p>
|
<p>The f_readdir function reads directory entries in sequence. All items in the directory can be read by calling f_readdir function repeatedly. When all directory entries have been read and no item to read, the function returns a null string into <tt>f_name[]</tt> member without any error. When a null pointer is given to the <tt>FileInfo</tt>, the read index of the directory object will be rewinded.</p>
|
||||||
<p>When LFN feature is enabled, <tt>lfname</tt> and <tt>lfsize</tt> in the file information structure must be initialized with valid value prior to calling the f_readdir function. The <tt>lfname</tt> is a pointer to the string buffer to return the long file name. The <tt>lfsize</tt> is the size of the string buffer. If either the size of read buffer or LFN working buffer is insufficient for the LFN or the entry has no LFN, a null string will be returned to the LFN read buffer. If the LFN contains any charactrer that cannot be converted to OEM code, a null string will be returned but this is not the case on Unicode API configuration. When <tt>lfname</tt> is a NULL, nothing of the LFN is returned.</p>
|
<p>When LFN feature is enabled, <tt>lfname</tt> and <tt>lfsize</tt> in the file information structure must be initialized with valid value prior to use the f_readdir function. The <tt>lfname</tt> is a pointer to the string buffer to return the long file name. The <tt>lfsize</tt> is the size of the string buffer in unit of character. If either the size of read buffer or LFN working buffer is insufficient for the LFN or the object has no LFN, a null string will be returned to the LFN read buffer. If the LFN contains any charactrer that cannot be converted to OEM code, a null string will be returned but this is not the case on Unicode API configuration. When <tt>lfname</tt> is a NULL, nothing of the LFN is returned. When the object has no LFN, any small capitals can be contained in the SFN.</p>
|
||||||
<p>When relative path feature is enabled <tt>(_FS_RPATH == 1)</tt>, "." and ".." entries are not filtered out and it will appear in the read entries.</p>
|
<p>When relative path feature is enabled <tt>(_FS_RPATH == 1)</tt>, "." and ".." entries are not filtered out and it will appear in the read entries.</p>
|
||||||
<p>This function is not supported in minimization level of >=2.</p>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_MINIMIZE <= 1</tt>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -81,12 +86,12 @@ FRESULT scan_files (char* path)
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
res = f_readdir(&dir, &fno);
|
res = f_readdir(&dir, &fno);
|
||||||
if (res != FR_OK || fno.fname[0] == 0) break;
|
if (res != FR_OK || fno.fname[0] == 0) break;
|
||||||
|
if (fno.fname[0] == '.') continue;
|
||||||
#if _USE_LFN
|
#if _USE_LFN
|
||||||
fn = *fno.lfname ? fno.lfname : fno.fname;
|
fn = *fno.lfname ? fno.lfname : fno.fname;
|
||||||
#else
|
#else
|
||||||
fn = fno.fname;
|
fn = fno.fname;
|
||||||
#endif
|
#endif
|
||||||
if (*fn == '.') continue;
|
|
||||||
if (fno.fattrib & AM_DIR) {
|
if (fno.fattrib & AM_DIR) {
|
||||||
sprintf(&path[i], "/%s", fn);
|
sprintf(&path[i], "/%s", fn);
|
||||||
res = scan_files(path);
|
res = scan_files(path);
|
||||||
@ -105,7 +110,7 @@ FRESULT scan_files (char* path)
|
|||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>See Also</h4>
|
||||||
<p><tt><a href="opendir.html">f_opendir</a>, <a href="stat.html">f_stat</a>, <a href="sfileinfo.html">FILINFO</a>, <a href="sdir.html">DIR</a></tt></p>
|
<p><tt><a href="opendir.html">f_opendir</a>, <a href="stat.html">f_stat</a>, <a href="sfileinfo.html">FILINFO</a>, <a href="sdir.html">DIR</a></tt></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -12,11 +12,11 @@
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h2>f_rename</h2>
|
<h2>f_rename</h2>
|
||||||
<p>Rename file or directory.</p>
|
<p>Renames an object.</p>
|
||||||
<pre>
|
<pre>
|
||||||
FRESULT f_rename (
|
FRESULT f_rename (
|
||||||
const XCHAR* <em>OldName</em>, /* Pointer to old file/directory name */
|
const XCHAR* <em>OldName</em>, /* Pointer to old object name */
|
||||||
const XCHAR* <em>NewName</em> /* Pointer to new file/directory name */
|
const XCHAR* <em>NewName</em> /* Pointer to new object name */
|
||||||
);
|
);
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
@ -25,9 +25,9 @@ FRESULT f_rename (
|
|||||||
<h4>Parameters</h4>
|
<h4>Parameters</h4>
|
||||||
<dl class="par">
|
<dl class="par">
|
||||||
<dt>OldName</dt>
|
<dt>OldName</dt>
|
||||||
<dd>Pointer to a null-terminated string specifies the old <a href="filename.html">file/directory name</a> to be renamed.</dd>
|
<dd>Pointer to a null-terminated string specifies the old <a href="filename.html">object name</a> to be renamed.</dd>
|
||||||
<dt>NewName</dt>
|
<dt>NewName</dt>
|
||||||
<dd>Pointer to a null-terminated string specifies the new file/directory name without drive number. Existing object nannot be specified.</dd>
|
<dd>Pointer to a null-terminated string specifies the new object name without drive number.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ FRESULT f_rename (
|
|||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd>
|
<dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd>
|
||||||
<dt>FR_EXIST</dt>
|
<dt>FR_EXIST</dt>
|
||||||
<dd>There is an object that have a name equal to new name.</dd>
|
<dd>The new name is colliding with an existing name.</dd>
|
||||||
<dt>FR_DENIED</dt>
|
<dt>FR_DENIED</dt>
|
||||||
<dd>The new name could not be created due to any reason.</dd>
|
<dd>The new name could not be created due to any reason.</dd>
|
||||||
<dt>FR_WRITE_PROTECTED</dt>
|
<dt>FR_WRITE_PROTECTED</dt>
|
||||||
@ -60,24 +60,30 @@ FRESULT f_rename (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>The logical drive has no work area.</dd>
|
<dd>The logical drive has no work area.</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>There is no valid FAT partition on the disk.</dd>
|
<dd>There is no valid FAT volume on the disk.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>Rename a file or directory and can move it to other directory. Logical drive number is determined by old name, new name must not contain logical drive number. This function is not supported in read-only configuration or minimization level of >= 1.</p>
|
<p>Renames an object and can also move it to other directory. The logical drive number is determined by old name, new name must not contain a logical drive number. <em>Do not rename open objects</em>.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Example</h4>
|
<h4>Example</h4>
|
||||||
<pre>
|
<pre>
|
||||||
// Rename a file or directory
|
/* Rename an object */
|
||||||
f_rename("oldname.txt", "newname.txt");
|
f_rename("oldname.txt", "newname.txt");
|
||||||
|
|
||||||
// Rename and move a file or directory to other directory simultaneously
|
/* Rename and move an object to other directory */
|
||||||
f_rename("oldname.txt", "dir1/newname.txt");
|
f_rename("oldname.txt", "dir1/newname.txt");
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -20,6 +20,7 @@ typedef struct _FATFS_ {
|
|||||||
BYTE csize; /* Number of sectors per cluster */
|
BYTE csize; /* Number of sectors per cluster */
|
||||||
BYTE n_fats; /* Number of FAT copies */
|
BYTE n_fats; /* Number of FAT copies */
|
||||||
BYTE wflag; /* win[] dirty flag (1:must be written back) */
|
BYTE wflag; /* win[] dirty flag (1:must be written back) */
|
||||||
|
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
|
||||||
WORD id; /* File system mount ID */
|
WORD id; /* File system mount ID */
|
||||||
WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */
|
WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */
|
||||||
#if _FS_REENTRANT
|
#if _FS_REENTRANT
|
||||||
@ -29,7 +30,6 @@ typedef struct _FATFS_ {
|
|||||||
WORD s_size; /* Sector size */
|
WORD s_size; /* Sector size */
|
||||||
#endif
|
#endif
|
||||||
#if !_FS_READONLY
|
#if !_FS_READONLY
|
||||||
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
|
|
||||||
DWORD last_clust; /* Last allocated cluster */
|
DWORD last_clust; /* Last allocated cluster */
|
||||||
DWORD free_clust; /* Number of free clusters */
|
DWORD free_clust; /* Number of free clusters */
|
||||||
DWORD fsi_sector; /* fsinfo sector */
|
DWORD fsi_sector; /* fsinfo sector */
|
||||||
|
|||||||
@ -57,7 +57,7 @@ typedef struct _FILINFO_ {
|
|||||||
<dt>fattrib</dt>
|
<dt>fattrib</dt>
|
||||||
<dd>Indicates the file/directory attribute in combination of <tt>AM_DIR</tt>, <tt>AM_RDO</tt>, <tt>AM_HID</tt>, <tt>AM_SYS</tt> and <tt>AM_ARC</tt>.</dd>
|
<dd>Indicates the file/directory attribute in combination of <tt>AM_DIR</tt>, <tt>AM_RDO</tt>, <tt>AM_HID</tt>, <tt>AM_SYS</tt> and <tt>AM_ARC</tt>.</dd>
|
||||||
<dt>fname[]</dt>
|
<dt>fname[]</dt>
|
||||||
<dd>Indicates the file/directory name in 8.3 format null-terminated string.</dd>
|
<dd>Indicates the file/directory name in 8.3 format null-terminated string. It is always returnd with upper case on non-LFN configuration but it can be returned with lower case on LFN configuration.</dd>
|
||||||
<dt>lfname</dt>
|
<dt>lfname</dt>
|
||||||
<dd>Pointer to the LFN buffer to store the read LFN. This member must be initialized by application prior to use this structure. Not available on non-LFN configuration.</dd>
|
<dd>Pointer to the LFN buffer to store the read LFN. This member must be initialized by application prior to use this structure. Not available on non-LFN configuration.</dd>
|
||||||
<dt>lfsize</dt>
|
<dt>lfsize</dt>
|
||||||
|
|||||||
@ -54,7 +54,7 @@ FRESULT f_stat (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>The logical drive has no work area.</dd>
|
<dd>The logical drive has no work area.</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>There is no valid FAT partition on the disk.</dd>
|
<dd>There is no valid FAT volume on the disk.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -48,12 +48,18 @@ FRESULT f_sync (
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_sync function performs the same process as f_close function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for applications that open files for a long time in writing mode, such as data logger. Performing f_sync of periodic or immediataly after f_write can minimize risk of data loss due to a sudden blackout or an unintentional disk removal. However f_sync immediataly before f_close has no advantage because f_close performs f_sync in it. This function is not available in read-only configuration.</p>
|
<p>The f_sync function performs the same process as f_close function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing f_sync of periodic or immediataly after f_write can minimize the risk of data loss due to a sudden blackout or an unintentional disk removal. However f_sync immediataly before f_close has no advantage because f_close performs f_sync in it. In other words, the differnce between those functions is that the file object is invalidated or not. </p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_READONLY == 0</tt>.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>See Also</h4>
|
||||||
<p><tt><a href="close.html">f_close</a></tt></p>
|
<p><tt><a href="close.html">f_close</a></tt></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -50,12 +50,18 @@ FRESULT f_truncate (
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_truncate function truncates the file size to the current file R/W point. When the file R/W pointer is already pointing end of the file, this function has no effect. This function is not available in read-only configuration or minimization level of >=1.</p>
|
<p>The f_truncate function truncates the file size to the current file R/W point. When the file R/W pointer is already pointing end of the file, this function has no effect.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>See Also</h4>
|
||||||
<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
|
<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>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -12,10 +12,10 @@
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h2>f_unlink</h2>
|
<h2>f_unlink</h2>
|
||||||
<p>The f_unlink removes file or directory.</p>
|
<p>The f_unlink removes an object.</p>
|
||||||
<pre>
|
<pre>
|
||||||
FRESULT f_unlink (
|
FRESULT f_unlink (
|
||||||
const XCHAR* <em>FileName</em> /* Pointer to the file or directory name */
|
const XCHAR* <em>FileName</em> /* Pointer to the object name */
|
||||||
);
|
);
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
@ -24,7 +24,7 @@ FRESULT f_unlink (
|
|||||||
<h4>Parameter</h4>
|
<h4>Parameter</h4>
|
||||||
<dl class="par">
|
<dl class="par">
|
||||||
<dt>FileName</dt>
|
<dt>FileName</dt>
|
||||||
<dd>Pointer to the null-terminated string that specifies a <a href="filename.html">file or directory</a> to be removed.</dd>
|
<dd>Pointer to the null-terminated string that specifies an <a href="filename.html">object</a> to be removed.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ FRESULT f_unlink (
|
|||||||
<dd>The drive number is invalid.</dd>
|
<dd>The drive number is invalid.</dd>
|
||||||
<dt>FR_DENIED</dt>
|
<dt>FR_DENIED</dt>
|
||||||
<dd>The function was denied due to either of following reasons:
|
<dd>The function was denied due to either of following reasons:
|
||||||
<ul><li>The file or directory has read-only attribute</li><li>The directory is not empty.</li></ul></dd>
|
<ul><li>The object has read-only attribute</li><li>The directory is not empty.</li></ul></dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd>
|
<dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd>
|
||||||
<dt>FR_WRITE_PROTECTED</dt>
|
<dt>FR_WRITE_PROTECTED</dt>
|
||||||
@ -56,14 +56,20 @@ FRESULT f_unlink (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>The logical drive has no work area.</dd>
|
<dd>The logical drive has no work area.</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>There is no valid FAT partition on the disk.</dd>
|
<dd>There is no valid FAT volume on the disk.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_unlink function removes a file or directory. In read-only configuration or minimization level is >= 1, this function is not available.</p>
|
<p>The f_unlink function removes an object. <em>Do not remove open objects and current directory</em>.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -56,19 +56,25 @@ FRESULT f_utime (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>The logical drive has no work area.</dd>
|
<dd>The logical drive has no work area.</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>There is no valid FAT partition on the disk.</dd>
|
<dd>There is no valid FAT volume on the disk.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The f_utime function changes the timestamp of a file or directory. This function is not supported in read-only configuration and minimization level of >=1.</p>
|
<p>The f_utime function changes the timestamp of a file or directory</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>See Also</h4>
|
||||||
<p><tt><a href="stat.html">f_stat</a>, <a href="sfileinfo.html">FILINFO</a></tt></p>
|
<p><tt><a href="stat.html">f_stat</a>, <a href="sfileinfo.html">FILINFO</a></tt></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@ FRESULT f_write (
|
|||||||
<dt>ByteToWrite</dt>
|
<dt>ByteToWrite</dt>
|
||||||
<dd>Specifies number of bytes to write in range of UINT.</dd>
|
<dd>Specifies number of bytes to write in range of UINT.</dd>
|
||||||
<dt>ByteWritten</dt>
|
<dt>ByteWritten</dt>
|
||||||
<dd>Pointer to the UINT variable to return number of bytes written. Return value is always valid after the function call.</dd>
|
<dd>Pointer to the UINT variable to return the number of bytes written. The value is always valid after the function call regardless of the result.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -59,13 +59,18 @@ FRESULT f_write (
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>Description</h4>
|
<h4>Description</h4>
|
||||||
<p>The read/write pointer in the file object is increased in number of bytes written. After the function succeeded, <tt>*ByteWritten</tt> should be checked to detect disk full. In case of <tt>*ByteWritten < ByteToWrite</tt>, it means the disk got full during write operation.</p>
|
<p>The R/W pointer in the file object is increased in number of bytes written. After the function succeeded, <tt>*ByteWritten</tt> should be checked to detect the disk full. In case of <tt>*ByteWritten < ByteToWrite</tt>, it means the volume got full during the write operation.</p>
|
||||||
<p>This function is not available in read-only configuration.</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>References</h4>
|
<h4>QuickInfo</h4>
|
||||||
|
<p>Available when <tt>_FS_READONLY == 0</tt>.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>See Also</h4>
|
||||||
<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>
|
<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>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -19,23 +19,53 @@
|
|||||||
<li>処理系はANSI C準拠であること。<br>
|
<li>処理系はANSI C準拠であること。<br>
|
||||||
FatFsモジュールはANSI C準拠で記述されているので、ANSI C準拠のコンパイラなら特に処理系依存な点はありません。</li>
|
FatFsモジュールはANSI C準拠で記述されているので、ANSI C準拠のコンパイラなら特に処理系依存な点はありません。</li>
|
||||||
<li>char/short/longのサイズは、それぞれ8/16/32ビットで、intは16または32ビットであること。<br>
|
<li>char/short/longのサイズは、それぞれ8/16/32ビットで、intは16または32ビットであること。<br>
|
||||||
使用される整数の型は integer.h 内で typedef されています。整数の型とサイズに関しては、まっとうな処理系なら問題ないはずですが、既存の定義と衝突した場合はユーザによって解決されなければなりません。</li>
|
サイズを明示する整数の型が integer.h 内で定義されています。整数の型とサイズに関しては、まっとうな処理系なら問題ないはずですが、既存の定義と衝突した場合はユーザによって解決されなければなりません。</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h3>メモリ使用量 (R0.07c)</h3>
|
<h3>ポーティングのしかた</h3>
|
||||||
|
<p>必要なのは FatFsモジュールの要求するディスク関数を用意することだけで、それ以外にすることはありません。既に動作しているディスク関数があるならその APIを FatFsに合わせるだけで済みますが、無い場合はほかから移植するか、最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード・オンリー構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。</p>
|
||||||
<table class="lst2">
|
<table class="lst2">
|
||||||
<tr><th></th><th>AVR</th><th>H8/300H</th><th>PIC</th><th>TLCS-870/C</th><th>V850ES</th><th>SH2</th><th>ARM7TDMI</th><th>IA-32</th></tr>
|
<tr><th>ユーザ作成関数</th><th>必要となる条件</th></tr>
|
||||||
<tr><td>Compiler</td><td>WinAVR(gcc)</td><td>CH38</td><td>C30(gcc)</td><td>CC870C</td><td>CA850</td><td>SHC</td><td>WinARM(gcc)</td><td>MSC</td></tr>
|
<tr><td>disk_initialize</td><td>常時</td></tr>
|
||||||
|
<tr><td>disk_status</td><td>常時</td></tr>
|
||||||
|
<tr><td>disk_read</td><td>常時</td></tr>
|
||||||
|
<tr><td>disk_write</td><td>_FS_READONLY == 0</td></tr>
|
||||||
|
<tr><td>disk_ioctl (CTRL_SYNC)</td><td>_FS_READONLY == 0</td></tr>
|
||||||
|
<tr><td>disk_ioctl (GET_SECTOR_COUNT)</td><td>_USE_MKFS == 1</td></tr>
|
||||||
|
<tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS >= 1024</td></tr>
|
||||||
|
<tr><td>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr>
|
||||||
|
<tr><td>get_fattime</td><td>_FS_READONLY == 0</td></tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h3>限界値</h3>
|
||||||
|
<ul>
|
||||||
|
<li>FATタイプ: FAT12, FAT16, FAT32。</li>
|
||||||
|
<li>同時オープン・ファイル数: 無制限(利用可能メモリによる)。</li>
|
||||||
|
<li>ボリューム数: 最大 10。</li>
|
||||||
|
<li>ファイル・サイズ: FAT規格に依存 (4G-1バイト)。</li>
|
||||||
|
<li>ボリューム・サイズ: FAT規格に依存 (最大 2T,4Tまたは8Tバイト)。</li>
|
||||||
|
<li>クラスタ・サイズ: 最大 64Kバイト。f_mkfs()では 32Kバイト。</li>
|
||||||
|
<li>セクタ・サイズ: FAT規格に依存 (最大 4Kバイト)。</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h3>メモリ使用量 (R0.07e)</h3>
|
||||||
|
<table class="lst2">
|
||||||
|
<tr><th></th><th>AVR</th><th>H8/300H</th><th>PIC</th><th>TLCS-870/C</th><th>V850ES</th><th>SH2</th><th>ARM7TDMI</th><th>x86</th></tr>
|
||||||
|
<tr><td>Compiler</td><td>WinAVR(gcc)</td><td>CH38</td><td>C30(gcc)</td><td>CC870C</td><td>CA850</td><td>SHC</td><td>WinARM(gcc)</td><td>VC6</td></tr>
|
||||||
<tr><td>_WORD_ACCESS</td><td>1</td><td>0</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>1</td></tr>
|
<tr><td>_WORD_ACCESS</td><td>1</td><td>0</td><td>0</td><td>1</td><td>1</td><td>0</td><td>0</td><td>1</td></tr>
|
||||||
<tr class="lst3"><td>ROM (Full, R/W)</td><td>11962</td><td>10433</td><td>10753</td><td>15153</td><td>7747</td><td>8707</td><td>10584</td><td>7337</td></tr>
|
<tr class="lst3"><td>text (Full, R/W)</td><td>12194</td><td>10559</td><td>10924</td><td>15229</td><td>7686</td><td>8727</td><td>10564</td><td>7342</td></tr>
|
||||||
<tr><td>ROM (Min, R/W)</td><td>7466</td><td>6799</td><td>6772</td><td>9906</td><td>4901</td><td>5599</td><td>6548</td><td>4787</td></tr>
|
<tr> <td>text (Min, R/W)</td><td>7988</td><td>6903</td><td>7108</td><td>9960</td><td>4884</td><td>5651</td><td>6544</td><td>4764</td></tr>
|
||||||
<tr><td>ROM (Full, R/O)</td><td>5400</td><td>4687</td><td>4804</td><td>6744</td><td>3539</td><td>3799</td><td>4676</td><td>3380</td></tr>
|
<tr><td>text (Full, R/O)</td><td>5532</td><td>4753</td><td>5020</td><td>6760</td><td>3462</td><td>3777</td><td>4624</td><td>3316</td></tr>
|
||||||
<tr><td>ROM (Min, R/O)</td><td>3804</td><td>3527</td><td>3421</td><td>5040</td><td>2561</td><td>2867</td><td>3276</td><td>2533</td></tr>
|
<tr> <td>text (Min, R/O)</td><td>4040</td><td>3631</td><td>3736</td><td>5083</td><td>2556</td><td>2907</td><td>3284</td><td>2510</td></tr>
|
||||||
<tr><td>RAM (Static)</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
|
<tr><td>bss</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
|
||||||
<tr><td>RAM (Dynamic)<br>(_FS_TINY == 0)</td><td>D*560 +<br>F*544</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*544</td><td></td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td></tr>
|
<tr><td>Work area<br>(_FS_TINY == 0)</td><td>D*560 +<br>F*544</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*544</td><td></td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td></tr>
|
||||||
<tr><td>RAM (Dynamic)<br>(_FS_TINY == 1)</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td></tr>
|
<tr><td>Work area<br>(_FS_TINY == 1)</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*36</td></tr>
|
||||||
</table>
|
</table>
|
||||||
<p>上の表にいくつかのターゲットにおけるメモリ使用量の例を示します。テスト時の構成オプションは次の通りです。数値の単位はバイトで、<em>D</em>は論理ドライブ数、<em>F</em>は同時オープン・ファイル数を示します。コンパイラの最適化オプションはコード・サイズとしています。</p>
|
<p>上の表にいくつかのターゲットにおけるメモリ使用量の例を示します。テスト時の構成オプションは次の通りです。数値の単位はバイトで、<em>D</em>は論理ドライブ数、<em>F</em>は同時オープン・ファイル数を示します。コンパイラの最適化オプションはコード・サイズとしています。</p>
|
||||||
<pre>
|
<pre>
|
||||||
@ -106,15 +136,15 @@ _FS_REENTRANT 0 (Disable reentrancy)
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h3>リエントランシー</h3>
|
<h3>リエントランシー</h3>
|
||||||
<p>異なるボリューム(論理ドライブ)に対するファイル操作は、リエントラント設定によらず常に同時平行に動作できます。同じボリュームに対するリエントランシーは<tt>_FS_REENTRANT</tt>オプションで有効にされることができます。この場合、OS依存の同期オブジェクト操作関数 ff_cre_syncobj, ff_del_syncobj, ff_req_grant と ff_rel_grant もまたプロジェクトに追加されなければなりません。サンプル・コードと解説は<tt>syncobj.c</tt>にあります。</p>
|
<p>互いに異なるボリューム(論理ドライブ)に対するファイル操作は、常に同時平行に動作できます。同じボリュームに対してはデフォルトではリエントラントではありませんが、<tt>_FS_REENTRANT</tt>オプションでリエントラントにすることもできます。この場合、OS依存の同期オブジェクト操作関数 ff_cre_syncobj, ff_del_syncobj, ff_req_grant と ff_rel_grant もまたプロジェクトに追加されなければなりません。サンプル・コードと解説は<tt>syncobj.c</tt>にあります。</p>
|
||||||
<p>他のタスクがそのボリュームを使用中にファイル関数が呼び出されると、そのアクセスはそのタスクがファイル関数を抜けるまでブロックされます。もし、待ち時間が<tt>_TIMEOUT</tt>で指定された期間を越すと、その関数は<tt>FR_TIMEOUT</tt>でアボートします。いくつかのRTOSではタイムアウト機能はサポートされないかも知れません。</p>
|
<p>あるタスクがボリュームを使用中に他のタスクからそのボリュームに対するファイル関数が呼び出されると、そのアクセスは先のタスクがファイル関数を抜けるまでブロックされます。もし、待ち時間が<tt>_TIMEOUT</tt>で指定された期間を越すと、その関数は<tt>FR_TIMEOUT</tt>でアボートします。いくつかのRTOSではタイムアウト機能はサポートされないかも知れません。</p>
|
||||||
<p>ひとつの例外がf_mountとf_mkfs関数にあります。これらの関数は同じボリュームに対してリエントラントではありません。これらの関数を使用するときは、他のスレッドは関連するファイルを閉じ、そのボリュームへのアクセスを避けなければなりません。</p>
|
<p>ひとつの例外がf_mountとf_mkfs関数にあります。これらの関数は同じボリュームに対してリエントラントではありません。これらの関数を使用するときは、アプリケーション・レベルで排他制御しなければなりません。</p>
|
||||||
<p>注: このセクションはFatFsモジュールそれ自体のリエントランシーについて説明しています。ディスクI/Oモジュールのリエントランシーに関しては何の前提もありません。</p>
|
<p>注: このセクションはFatFsモジュールそれ自体のリエントランシーについて説明しています。ディスクI/Oモジュールのリエントランシーに関しては何の前提もありません。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h3>多重ファイル・アクセス</h3>
|
<h3>多重ファイル・アクセス</h3>
|
||||||
<p>FatFsモジュールでは多重アクセス機能はサポートされません。ファイルに対する多重アクセスは、そのアクセス・モードによって制限されます。一つのファイルに対する多重オープンは、それらが全てリード・モードのとき許可されます。書き込みモードを含む多重オープン、また開かれているファイルに対するリネームや消去を行ってはなりません。さもないと、そのボリュームのFAT構造が破壊される可能性があります。</p>
|
<p>FatFsモジュールでは多重アクセス機能はサポートされません。ファイルに対する多重アクセスは、そのアクセス・モードによって制限されます。一つのファイルに対する多重オープンは、それらが全てリード・モードのときに限って許可されます。書き込みモードを含む多重オープン、また開かれているファイルに対するリネームや消去を行ってはなりません。さもないと、そのボリュームのFAT構造が破壊される可能性があります。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
@ -148,7 +178,7 @@ _FS_REENTRANT 0 (Disable reentrancy)
|
|||||||
<br class="clr">
|
<br class="clr">
|
||||||
<p>赤で示したセクションを実行中に障害が発生した場合、クロス・リンクが発生して操作対象のファイル・ディレクトリが失われる可能性があります。黄色で示したセクションを実行中に障害が発生した場合、つぎのうちいずれかまたは複数の結果が生じる可能性があります。</p>
|
<p>赤で示したセクションを実行中に障害が発生した場合、クロス・リンクが発生して操作対象のファイル・ディレクトリが失われる可能性があります。黄色で示したセクションを実行中に障害が発生した場合、つぎのうちいずれかまたは複数の結果が生じる可能性があります。</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>書き換え中のファイルの内容が破壊される。</li>
|
<li>書き換え中のファイルのデータが破壊される。</li>
|
||||||
<li>追記中のファイルがオープン前の状態に戻る。</li>
|
<li>追記中のファイルがオープン前の状態に戻る。</li>
|
||||||
<li>新規に作成されたファイルが消える。</li>
|
<li>新規に作成されたファイルが消える。</li>
|
||||||
<li>新規または上書きで作成されたファイルの長さがゼロになって残る。</li>
|
<li>新規または上書きで作成されたファイルの長さがゼロになって残る。</li>
|
||||||
@ -158,13 +188,34 @@ _FS_REENTRANT 0 (Disable reentrancy)
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h3>ファイル名の大文字変換</h3>
|
<h3>日本語ファイル名の大文字変換</h3>
|
||||||
<p>CP932(Shift_JIS)でかつ非LFN構成のときは、拡張文字(2バイトの英字・キリル文字・ギリシャ文字)に対して大文字変換を行わず、小文字は小文字でディレクトリに記録・比較されます。これは日本語MSDOSと同じ仕様となります。このため、全角小文字を含むファイルを作成すると、Windows環境でそのファイルを開けなくなります。LFN構成では大文字変換を行います(Windows仕様)。</p>
|
<p>CP932(Shift_JIS)でかつ非LFN構成のときは、拡張文字の小文字(2バイト英字・キリル文字・ギリシャ文字)に対して大文字変換を行わず、小文字のままSFNエントリに記録・検索されます。これは日本語MSDOSと同じ仕様となります。このため、全角小文字を含むファイルを作成すると、NT系Windowsでそのファイルを開けなくなります。LFN構成では大文字変換を行います(NT系Windows仕様)。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h3>Unicode入出力への対応</h3>
|
<h3>Unicode入出力への対応</h3>
|
||||||
<p>ファイル関数のファイル名入出力をUnicodeに切り替えることができます。詳細は、<a href="filename.html">ファイル名</a>を参照してください。</p>
|
<p>ファイル関数のファイル名入出力はデフォルトでは OEMコードですが、これをUnicodeに切り替えることもできます。詳細は、<a href="filename.html">ファイル名</a>を参照してください。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h3>FatFsのライセンスについて</h3>
|
||||||
|
<p>ソース・ファイルのヘッダにライセンス条件が記述されているので、利用の際はそれに従うこと。英語を読めない方のために以下に日本語訳を示しておきます。</p>
|
||||||
|
<pre>/*----------------------------------------------------------------------------/
|
||||||
|
/ FatFs - FAT file system module R0.07e (C)ChaN, 2009
|
||||||
|
/-----------------------------------------------------------------------------/
|
||||||
|
/ FatFsモジュールは、小規模な組み込みシステム向けの汎用FATファイルシステム・
|
||||||
|
/ モジュールです。これはフリー・ソフトウェアとして、教育・研究・開発のために
|
||||||
|
/ 以下のライセンス・ポリシーの下で公開されています。
|
||||||
|
/
|
||||||
|
/ Copyright (C) 2009, ChaN, all right reserved.
|
||||||
|
/
|
||||||
|
/ * FatFsモジュールはフリー・ソフトウェアであり、また<em>無保証です</em>。
|
||||||
|
/ * 用途に制限はありません。<em>あなたの責任の下において</em>、個人的・非営利的な
|
||||||
|
/ ものから商用製品の開発に及ぶ目的に使用・改変・再配布することができます。
|
||||||
|
/ * ソース・コードを再配布するときは、上記の著作権表示を保持しなければなりません。
|
||||||
|
/
|
||||||
|
/-----------------------------------------------------------------------------/</pre>
|
||||||
|
<p>要するにFatFsはタダで自由に使えるということです。ソース・コードを再配布するときは、このブロックをそのまま保持しておくこと。このようにFatFsはBSDライクなライセンスとしていますが、一つ大きな違いがあります。特に組み込み用途での利用価値を高めるため、バイナリ形式(ソース・コードを含まない形式全て)での再配布については、条件は設けていません。その場合は、FatFsおよびそのライセンス文書についてはドキュメントに明記してもしなくてもかまいません。もちろんGNU GPLプロジェクトとも共存可能です。何らかの変更を加えて再配布する際は、他のライセンス(GNU GPLかBSDライセンス)に変更することも可能です。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
||||||
|
|||||||
@ -43,7 +43,7 @@ FRESULT f_chdir (
|
|||||||
<dt>FR_INVALID_DRIVE</dt>
|
<dt>FR_INVALID_DRIVE</dt>
|
||||||
<dd>ドライブ番号が不正。</dd>
|
<dd>ドライブ番号が不正。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_WRITE_PROTECTED</dt>
|
<dt>FR_WRITE_PROTECTED</dt>
|
||||||
<dd>メディアが書き込み禁止状態。</dd>
|
<dd>メディアが書き込み禁止状態。</dd>
|
||||||
<dt>FR_DISK_ERR</dt>
|
<dt>FR_DISK_ERR</dt>
|
||||||
@ -53,14 +53,20 @@ FRESULT f_chdir (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>その論理ドライブにワーク・エリアが与えられていない。</dd>
|
<dd>その論理ドライブにワーク・エリアが与えられていない。</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
|
<dd>ディスク上に有効なFATボリュームが見つからない。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>解説</h4>
|
<h4>解説</h4>
|
||||||
<p>f_chdir関数は各ボリュームのカレント・ディレクトリを変更します。カレント・ディレクトリはファイル・システム・オブジェクトの初期化が行われたとき、ルート・ディレクトリに設定されます。カレント・ディレクトリは、ファイル・システム・オブジェクトに記録されるため、そのボリュームを使用する全てのタスクに対して影響を与えます。この関数は相対パスが有効なとき<tt>(_FS_RPATH == 1)</tt>に使用可能となります。</p>
|
<p>f_chdir関数は各ボリュームのカレント・ディレクトリを変更します。カレント・ディレクトリはファイル・システム・オブジェクトの初期化が行われたとき、ルート・ディレクトリに設定されます。カレント・ディレクトリは、ファイル・システム・オブジェクトに記録されるため、そのボリュームを使用する全てのタスクに対して影響を与えます。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_RPATH == 1</tt>のときに使用可能となります。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -42,9 +42,16 @@ FRESULT f_chdrive (
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>‰ð<EFBFBD>à</h4>
|
<h4>‰ð<EFBFBD>à</h4>
|
||||||
<p>f_chdrive関数はカレント・ドライブを変更します。システム起動時の初期値は0です。この設定はFatFsモジュールの静的変数に記録されるため、全てのタスクに対して影響を与えます。この関数は相対パスが有効なとき<tt>(_FS_RPATH == 1)</tt>に使用可能となります。</p>
|
<p>f_chdrive関数はカレント・ドライブを変更します。システム起動時の初期値は0です。この設定はFatFsモジュールの静的変数に記録されるため、全てのタスクに対して影響を与えます。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_RPATH == 1</tt>のときに使用可能となります。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>ŽQ<EFBFBD>Æ</h4>
|
<h4>ŽQ<EFBFBD>Æ</h4>
|
||||||
<p><tt><a href="chdir.html">f_chdir</a></tt></p>
|
<p><tt><a href="chdir.html">f_chdir</a></tt></p>
|
||||||
|
|||||||
@ -57,7 +57,7 @@ FRESULT f_chmod (
|
|||||||
<dt>FR_INVALID_DRIVE</dt>
|
<dt>FR_INVALID_DRIVE</dt>
|
||||||
<dd>ドライブ番号が不正。</dd>
|
<dd>ドライブ番号が不正。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_WRITE_PROTECTED</dt>
|
<dt>FR_WRITE_PROTECTED</dt>
|
||||||
<dd>メディアが書き込み禁止状態。</dd>
|
<dd>メディアが書き込み禁止状態。</dd>
|
||||||
<dt>FR_DISK_ERR</dt>
|
<dt>FR_DISK_ERR</dt>
|
||||||
@ -67,21 +67,27 @@ FRESULT f_chmod (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>その論理ドライブにワーク・エリアが与えられていない。</dd>
|
<dd>その論理ドライブにワーク・エリアが与えられていない。</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
|
<dd>ディスク上に有効なFATボリュームが見つからない。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>解説</h4>
|
<h4>解説</h4>
|
||||||
<p>ファイルまたはディレクトリの属性を変更します。リード・オンリー構成および<tt>_FS_MINIMIZE >= 1</tt>ではこの関数はサポートされません。</p>
|
<p>ファイルまたはディレクトリの属性を変更します。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_FS_MINIMIZE == 0</tt>のとき使用可能です。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>使用例</h4>
|
<h4>使用例</h4>
|
||||||
<pre>
|
<pre>
|
||||||
// Set read-only flag , clear archive flag and others are left unchanged.
|
/* リードオンリーをセット、アーカイブをクリア、その他は変更しない */
|
||||||
f_chmod("file.txt", AM_RDO, AM_RDO | AM_ARC);
|
f_chmod("file.txt", AM_RDO, AM_RDO | AM_ARC);
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -39,7 +39,7 @@ FRESULT f_close (
|
|||||||
<dt>FR_INT_ERR</dt>
|
<dt>FR_INT_ERR</dt>
|
||||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_INVALID_OBJECT</dt>
|
<dt>FR_INVALID_OBJECT</dt>
|
||||||
<dd>無効なファイル・オブジェクト。</dd>
|
<dd>無効なファイル・オブジェクト。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@ -52,6 +52,12 @@ FRESULT f_close (
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p>全ての構成で使用可能です。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>参照</h4>
|
<h4>参照</h4>
|
||||||
<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>
|
<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>
|
||||||
|
|||||||
@ -32,12 +32,12 @@ DSTATUS disk_initialize (
|
|||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>戻り値</h4>
|
<h4>戻り値</h4>
|
||||||
<p>この関数は戻り値としてディスク・ステータスを返します。ディスク・ステータスの詳細に関しては<tt><a href="dstat.html">disk_status()</a></tt>を参照してください。</p>
|
<p>この関数は戻り値としてディスク・ステータスを返します。ディスク・ステータスの詳細に関しては<tt><a href="dstat.html">disk_status()</a></tt>を参照してください。</p>
|
||||||
<p>FatFsモジュールは、自動マウント動作で必要に応じてこの関数を呼び出します。FatFsモジュール使用中はアプリケーションからこの関数を呼び出してはなりません。さもないとFAT構造が破壊される可能性があります。</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>解説</h4>
|
<h4>解説</h4>
|
||||||
<p>ディスク・ドライブを初期化します。関数が成功すると、戻り値の<tt>STA_NOINIT</tt>フラグがクリアされます。</p>
|
<p>ディスク・ドライブを初期化します。関数が成功すると、戻り値の<tt>STA_NOINIT</tt>フラグがクリアされます。</p>
|
||||||
|
<p>FatFsモジュールは、自動マウント動作により必要に応じてこの関数を呼び出します。<em>FatFsモジュール使用中はアプリケーションからこの関数を呼び出してはなりません。さもないとFAT構造が破壊される可能性があります。エラー等により再初期化が必要なときは、<tt>f_mount()</tt>を使用します。</em></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
||||||
|
|||||||
@ -41,7 +41,7 @@ DWORD get_fattime (void);
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>‰ð<EFBFBD>à</h4>
|
<h4>‰ð<EFBFBD>à</h4>
|
||||||
<p>RTCをサポートしないシステムでも、何らかの日付として有効な値を返さなければなりません。リード・オンリー構成ではこの関数は必要とされません。</p>
|
<p>RTCをサポートしないシステムでも、何らかの日付として有効な値を返さなければなりません。0を返した場合、そのファイルは日付を持ちません。リード・オンリー構成ではこの関数は必要とされません。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -11,13 +11,13 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h2>ファイル・ディレクトリの指定方法</h2>
|
<h2>ファイル・ディレクトリの指定方法</h2>
|
||||||
<p>FatFsモジュールでのファイル、ディレクトリ、ドライブの指定方法はMS-DOSとほぼ同じです。パス名のフォーマットは次の通りです。</p>
|
<p>FatFsモジュールでのファイル、ディレクトリ、ドライブの指定方法はDOS/Windowsとほぼ同じです。パス名のフォーマットは次の通りです。</p>
|
||||||
<pre>
|
<pre>
|
||||||
"[<em>論理ドライブ番号</em>:][/]<em>ディレクトリ名</em>/<em>ファイル名</em>"
|
"[<em>論理ドライブ番号</em>:][/]<em>ディレクトリ名</em>/<em>ファイル名</em>"
|
||||||
</pre>
|
</pre>
|
||||||
<p>FatFsモジュールは長いファイル名および8.3形式ファイル名に対応しています。長いファイル名は、<tt>_USE_LFN == 1</tt>のとき使用可能になります。ディレクトリ・セパレータには / または \ を使用します。論理ドライブ番号は、'0'~'9'の一文字の数字とコロンで指定します。省略した場合は、デフォルト・ドライブ(0またはカレント・ドライブ)が選択されます</p>
|
<p>FatFsモジュールは長いファイル名(LFN)および8.3形式ファイル名(SFN)に対応しています。LFNは、<tt>(_USE_LFN > 0)</tt>のとき使用可能になります。DOS/Windowsとの違いは、ディレクトリ・セパレータと論理ドライブ番号の指定です。ディレクトリ・セパレータには / または \ を使用します。論理ドライブ番号は、'0'~'9'の一文字の数字とコロンで指定し、省略した場合はデフォルト・ドライブ(0またはカレント・ドライブ)が選択されます。パス名に先行あるいは中に含まれるスペースは、LFN構成では名前の一部として有効ですが、非LFN構成ではパス名の終端として認識されます。</p>
|
||||||
<p>標準構成<tt>(_FS_RPATH == 0)</tt>のときは、全てのオブジェクトがルート・ディレクトリから辿る絶対パスで指定されます。OS指向なカレント・ディレクトリという概念は無く、またドット名("."や"..")は使用できません。パス名先頭のセパレータは無視されます。デフォルト・ドライブ番号は常に0になります。</p>
|
<p>標準構成<tt>(_FS_RPATH == 0)</tt>のときは、全てのオブジェクトがルート・ディレクトリから辿る絶対パスで指定されます。OS指向なカレント・ディレクトリという概念は無く、またドット・ディレクトリ("."や"..")は使用できません。パス名先頭のセパレータは無視されます。デフォルト・ドライブ番号は常に0になります。</p>
|
||||||
<p>相対パスを有効<tt>(_FS_RPATH == 1)</tt>にしたときは、先行するセパレータの有無によって検索開始ディレクトリが変わり、セパレータがある場合はルート・ディレクトリから、無い場合は<a href="chdir.html">f_chdir関数</a>で設定されるカレント・ディレクトリからになります。またパス名の指定にドット名が使用できます。デフォルト・ドライブ番号は<a href="chdrive.html">f_chdrive関数</a>で設定された値となります。</p>
|
<p>相対パスを有効<tt>(_FS_RPATH == 1)</tt>にしたときは、先行するセパレータの有無によって検索開始ディレクトリが変わり、セパレータがある場合はルート・ディレクトリから、無い場合は<a href="chdir.html">f_chdir関数</a>で設定されるカレント・ディレクトリからになります。またパス名にドット・ディレクトリが使用できます。デフォルト・ドライブ番号は<a href="chdrive.html">f_chdrive関数</a>で設定された値となります。</p>
|
||||||
<table class="lst2">
|
<table class="lst2">
|
||||||
<tr><td>パス名</td><td>_FS_RPATH == 0</td><td>_FS_RPATH == 1</td></tr>
|
<tr><td>パス名</td><td>_FS_RPATH == 0</td><td>_FS_RPATH == 1</td></tr>
|
||||||
<tr class="lst3"><td>file.txt</td><td>ドライブ0のルート・ディレクトリ下のファイル</td><td>カレント・ドライブのカレント・ディレクトリ下のファイル</td></tr>
|
<tr class="lst3"><td>file.txt</td><td>ドライブ0のルート・ディレクトリ下のファイル</td><td>カレント・ドライブのカレント・ディレクトリ下のファイル</td></tr>
|
||||||
@ -37,13 +37,13 @@
|
|||||||
<p><br></p>
|
<p><br></p>
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h2>Unicode API</h2>
|
<h2>Unicode API</h2>
|
||||||
<p>ファイル関数の入出力のうちファイル名やパス名を指定する引数の型は、<tt>XCHAR</tt>で定義されていますが、これらは<tt>char</tt>でtypedefされています。そして、<tt>_CODE_PAGE</tt>で指定されるローカル・コード(SBCSまたはDBCS)の文字列として扱われます。ファイル名入出力をUnicodeとする構成(<tt>_USE_LFN != 0</tt>で、かつ<tt>_LFN_UNICODE == 1</tt>)にしたときは、<tt>XCHAR</tt>はワイド文字(<tt>unsigned short</tt>)に切り替わります。これによりLFNフル対応となり、ローカル・コードにない文字(♥☭❶など)も使用できます。</p>
|
<p>ファイル関数の入出力のうちファイル名やパス名を指定する引数の型は、<tt>XCHAR</tt>で定義されていますが、これは<tt>char</tt>のエリアスになっています。そして、<tt>_CODE_PAGE</tt>で指定される OEMコード(SBCSまたはDBCS)の文字列として扱われます。ファイル名入出力をUnicodeとする構成(LFN構成で、かつ<tt>_LFN_UNICODE</tt>を 1)にしたときは、<tt>XCHAR</tt>はワイド文字(<tt>unsigned short</tt>)に切り替わり、パス名にUnicodeを使用するようになります。これにより LFNフル対応となり、OEMコードにない文字(たとえば ✝☪✡☸☭など)も使用できます。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p><br></p>
|
<p><br></p>
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h2>論理ドライブと物理ドライブの対応</h2>
|
<h2>論理ドライブ(ボリューム)と物理ドライブ(ディスク装置)の対応</h2>
|
||||||
<p>標準構成では、それぞれの論理ドライブは同じ番号の物理ドライブに1:1で結びつけられていて、物理ドライブの先頭の区画がマウントされます。<tt>_MULTI_PARTITION == 1</tt>を指定すると、論理ドライブに対して個別に物理ドライブ番号・区画を指定できるようになります。この構成では、論理ドライブと区画の対応を解決するためのテーブルを次に示すように定義する必要があります。</p>
|
<p>デフォルトの構成では、それぞれの論理ドライブは同じ番号の物理ドライブに1:1で結びつけられていて、物理ドライブの先頭の区画がマウントされます。<tt>_MULTI_PARTITION</tt>に 1を指定すると、論理ドライブに対して個別に物理ドライブ番号・区画を指定できるようになります。この構成では、論理ドライブと区画の対応を解決するためのテーブルを次に示すように定義する必要があります。</p>
|
||||||
<pre>
|
<pre>
|
||||||
例:論理ドライブ0~2を物理ドライブ0(固定ディスク)の3つの基本区画に割り当て、
|
例:論理ドライブ0~2を物理ドライブ0(固定ディスク)の3つの基本区画に割り当て、
|
||||||
論理ドライブ3を物理ドライブ1(リムーバブル・ディスク)に割り当てる場合。
|
論理ドライブ3を物理ドライブ1(リムーバブル・ディスク)に割り当てる場合。
|
||||||
|
|||||||
@ -50,7 +50,7 @@ FRESULT f_forward (
|
|||||||
<dt>FR_INT_ERR</dt>
|
<dt>FR_INT_ERR</dt>
|
||||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_INVALID_OBJECT</dt>
|
<dt>FR_INVALID_OBJECT</dt>
|
||||||
<dd>無効なファイル・オブジェクト。</dd>
|
<dd>無効なファイル・オブジェクト。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@ -60,7 +60,12 @@ FRESULT f_forward (
|
|||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>解説</h4>
|
<h4>解説</h4>
|
||||||
<p>ファイルのデータをバッファに読み出さずに送信ストリームに直接転送します。アプリケーション側でデータ・バッファを必要としないので、メモリの限られた環境で有効です。転送開始位置は、現在のファイルR/Wポインタからになります。ファイルR/Wポインタは転送されたバイト数だけ進みます。指定されたバイト数の転送中にファイルの終端に達した場合や送信ストリームがビジーになった場合、<tt>*ByteFwd</tt>は<tt>ByteToFwd</tt>よりも小さくなります。</p>
|
<p>ファイルのデータをバッファに読み出さずに送信ストリームに直接転送します。アプリケーション側でデータ・バッファを必要としないので、メモリの限られた環境で有効です。転送開始位置は、現在のファイルR/Wポインタからになります。ファイルR/Wポインタは転送されたバイト数だけ進みます。指定されたバイト数の転送中にファイルの終端に達した場合や送信ストリームがビジーになった場合、<tt>*ByteFwd</tt>は<tt>ByteToFwd</tt>よりも小さくなります。</p>
|
||||||
<p>この関数は、<tt>_USE_FORWARD == 1</tt>で、且つ<tt>_FS_TINY == 1</tt>のときにサポートされます。</p>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_USE_FORWARD == 1</tt>で、且つ<tt>_FS_TINY == 1</tt>のときに使用可能です。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -43,7 +43,7 @@ FRESULT f_getfree (
|
|||||||
<dt>FR_INVALID_DRIVE</dt>
|
<dt>FR_INVALID_DRIVE</dt>
|
||||||
<dd>ドライブ番号が不正。</dd>
|
<dd>ドライブ番号が不正。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、ディスクドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_DISK_ERR</dt>
|
<dt>FR_DISK_ERR</dt>
|
||||||
<dd>ディスク・エラーによる失敗。</dd>
|
<dd>ディスク・エラーによる失敗。</dd>
|
||||||
<dt>FR_INT_ERR</dt>
|
<dt>FR_INT_ERR</dt>
|
||||||
@ -59,7 +59,12 @@ FRESULT f_getfree (
|
|||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>解説</h4>
|
<h4>解説</h4>
|
||||||
<p>論理ドライブ上の空きクラスタ数を取得します。返されたファイル・システム・オブジェクトの<tt>csize</tt>メンバがクラスタあたりのセクタ数を示しているので、これを元に実際の空きサイズが計算できます。FAT32ボリュームにおいては、FSINFOの状態によっては不正確な値を返したり、処理に時間がかかったりする可能性があります。</p>
|
<p>論理ドライブ上の空きクラスタ数を取得します。返されたファイル・システム・オブジェクトの<tt>csize</tt>メンバがクラスタあたりのセクタ数を示しているので、これを元に実際の空きサイズが計算できます。FAT32ボリュームにおいては、FSINFOの状態によっては不正確な値を返したり、処理に時間がかかったりする可能性があります。</p>
|
||||||
<p>リードオンリー構成および<tt>_FS_MINIMIZE >= 1</tt>ではこの関数はサポートされません。</p>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_FS_MINIMIZE == 0</tt>のとき使用可能です。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -70,15 +75,15 @@ FRESULT f_getfree (
|
|||||||
DWORD fre_clust, fre_sect, tot_sect;
|
DWORD fre_clust, fre_sect, tot_sect;
|
||||||
|
|
||||||
|
|
||||||
// Get drive information and free clusters
|
/* Get drive information and free clusters */
|
||||||
res = f_getfree("/", &fre_clust, &fs);
|
res = f_getfree("/", &fre_clust, &fs);
|
||||||
if (res) die(res);
|
if (res) die(res);
|
||||||
|
|
||||||
// Get total sectors and free sectors
|
/* Get total sectors and free sectors */
|
||||||
tot_sect = (fs->max_clust - 2) * fs->csize;
|
tot_sect = (fs->max_clust - 2) * fs->csize;
|
||||||
fre_sect = fre_clust * fs->csize;
|
fre_sect = fre_clust * fs->csize;
|
||||||
|
|
||||||
// Print free space in unit of KB (assuming 512B/sector)
|
/* Print free space in unit of KB (assuming 512B/sector) */
|
||||||
printf("%lu KB total drive space.\n"
|
printf("%lu KB total drive space.\n"
|
||||||
"%lu KB available.\n",
|
"%lu KB available.\n",
|
||||||
fre_sect / 2, tot_sect / 2);
|
fre_sect / 2, tot_sect / 2);
|
||||||
|
|||||||
@ -44,7 +44,12 @@ char* f_gets (
|
|||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>解説</h4>
|
<h4>解説</h4>
|
||||||
<p>この関数は<a href="read.html">f_read()</a>のラッパー関数です。読み出し動作は、最初の<tt>'\n'</tt>を読み込むか、ファイル終端に達するか、<tt>Size - 1</tt>文字を読み出すまで続きます。読み込まれた文字列の終端には<tt>'\0'</tt>が付加されます。既にファイル終端で1文字も読み込まれなかったとき、または何らかのエラーが発生したときは<tt>NULL</tt>を返します。ファイル終端かエラーかは<tt>f_eof()</tt>,<tt>f_error()</tt>マクロで調べられます。</p>
|
<p>この関数は<a href="read.html">f_read()</a>のラッパー関数です。読み出し動作は、最初の<tt>'\n'</tt>を読み込むか、ファイル終端に達するか、<tt>Size - 1</tt>文字を読み出すまで続きます。読み込まれた文字列の終端には<tt>'\0'</tt>が付加されます。既にファイル終端で1文字も読み込まれなかったとき、または何らかのエラーが発生したときは<tt>NULL</tt>を返します。ファイル終端かエラーかは<tt>f_eof()</tt>,<tt>f_error()</tt>マクロで調べられます。</p>
|
||||||
<p><tt>_USE_STRFUNC</tt>が1または2のときこの関数がサポートされます。2のときは、ファイルに含まれる<tt>'\r'</tt>が取り除かれてバッファに読み込まれます。</p>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_USE_STRFUNC</tt>が 1または 2のとき使用可能です。2のときは、ファイルに含まれる<tt>'\r'</tt>が取り除かれてバッファに読み込まれます。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -42,7 +42,7 @@ FRESULT f_lseek (
|
|||||||
<dt>FR_INT_ERR</dt>
|
<dt>FR_INT_ERR</dt>
|
||||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_INVALID_OBJECT</dt>
|
<dt>FR_INVALID_OBJECT</dt>
|
||||||
<dd>無効なファイル・オブジェクト。</dd>
|
<dd>無効なファイル・オブジェクト。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@ -56,38 +56,43 @@ FRESULT f_lseek (
|
|||||||
<li>非書き込みモードのため、ファイル・サイズでクリップされた。</li>
|
<li>非書き込みモードのため、ファイル・サイズでクリップされた。</li>
|
||||||
<li>ファイル拡張中にディスクが満杯になった。</li>
|
<li>ファイル拡張中にディスクが満杯になった。</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>_FS_MINIMIZE >= 3ではこの関数はサポートされません。</p>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_MINIMIZE < 3</tt>のとき使用可能です。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>使用例</h4>
|
<h4>使用例</h4>
|
||||||
<pre>
|
<pre>
|
||||||
// ファイル・オフセット5000へ移動
|
/* オフセット5000へ移動 */
|
||||||
res = f_lseek(&file, 5000);
|
res = f_lseek(&file, 5000);
|
||||||
|
|
||||||
// ファイル追記の準備 (ファイル終端へ移動)
|
/* ファイル追記の準備 (ファイル終端へ移動) */
|
||||||
res = f_lseek(&file, file.fsize);
|
res = f_lseek(&file, file.fsize);
|
||||||
|
|
||||||
// 3000バイト進める
|
/* 3000バイト進める */
|
||||||
res = f_lseek(&file, file.fptr + 3000);
|
res = f_lseek(&file, file.fptr + 3000);
|
||||||
|
|
||||||
// 2000バイト戻す (オーバーフローに注意)
|
/* 2000バイト戻す (オーバーフローに注意) */
|
||||||
res = f_lseek(&file, file.fptr - 2000);
|
res = f_lseek(&file, file.fptr - 2000);
|
||||||
</pre>
|
</pre>
|
||||||
<pre>
|
<pre>
|
||||||
// クラスタ先行割り当て (ストリーミング・ライト時のバッファ・オーバーラン防止)
|
/* クラスタ先行割り当て (ストリーミング・ライト時のバッファ・オーバーラン防止) */
|
||||||
|
|
||||||
res = f_open(&file, "record.wav", FA_CREATE_NEW | FA_WRITE); // ファイル作成
|
res = f_open(&file, "record.wav", FA_CREATE_NEW | FA_WRITE); /* ファイル作成 */
|
||||||
|
|
||||||
res = f_lseek(&file, MAX_SIZE); // 十分なクラスタの先行割り当て
|
res = f_lseek(&file, MAX_SIZE); /* 十分なクラスタの先行割り当て */
|
||||||
if (res || file.fptr != PRE_SIZE) .... // 正しくファイルが拡張されたかチェック
|
if (res || file.fptr != PRE_SIZE) .... /* 正しくファイルが拡張されたかチェック */
|
||||||
|
|
||||||
res = f_lseek(&file, DATA_START); // データ・ストリームの記録(アロケーションディレイ無し)
|
res = f_lseek(&file, DATA_START); /* データ・ストリームの記録(アロケーションディレイ無し) */
|
||||||
...
|
...
|
||||||
|
|
||||||
res = f_truncate(&file); // 不要領域の切り捨て
|
res = f_truncate(&file); /* 不要領域の切り捨て */
|
||||||
res = f_lseek(&file, 0); // ヘッダの記録
|
res = f_lseek(&file, 0); /* ヘッダの記録 */
|
||||||
...
|
...
|
||||||
|
|
||||||
res = f_close(&file);
|
res = f_close(&file);
|
||||||
|
|||||||
@ -45,7 +45,7 @@ FRESULT f_mkdir (
|
|||||||
<dt>FR_EXIST</dt>
|
<dt>FR_EXIST</dt>
|
||||||
<dd>同名のディレクトリやファイルが存在する。</dd>
|
<dd>同名のディレクトリやファイルが存在する。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_WRITE_PROTECTED</dt>
|
<dt>FR_WRITE_PROTECTED</dt>
|
||||||
<dd>メディアが書き込み禁止状態。</dd>
|
<dd>メディアが書き込み禁止状態。</dd>
|
||||||
<dt>FR_DISK_ERR</dt>
|
<dt>FR_DISK_ERR</dt>
|
||||||
@ -55,14 +55,20 @@ FRESULT f_mkdir (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>その論理ドライブにワーク・エリアが与えられていない。</dd>
|
<dd>その論理ドライブにワーク・エリアが与えられていない。</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
|
<dd>ディスク上に有効なFATボリュームが見つからない。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>解説</h4>
|
<h4>解説</h4>
|
||||||
<p>空のディレクトリを作成します。リード・オンリー構成および<tt>_FS_MINIMIZE >= 1</tt>ではこの関数はサポートされません。</p>
|
<p>空のディレクトリを作成します。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_FS_MINIMIZE == 0</tt>のとき使用可能です。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -64,7 +64,12 @@ FRESULT f_mkfs (
|
|||||||
<h4>説明</h4>
|
<h4>説明</h4>
|
||||||
<p>f_mkfs関数はFATファイル・システムをドライブ上に作成します。リムーバブル・メディアのパーテーショニング・ルールとしてはFDISK形式とSFD形式があり、メモリ・カードではFDISK形式が普通です。この関数は<em>複数区画には対応していない</em>ので、その物理ドライブの既存の区画は全て削除され、全体が一つの区画になります。</p>
|
<p>f_mkfs関数はFATファイル・システムをドライブ上に作成します。リムーバブル・メディアのパーテーショニング・ルールとしてはFDISK形式とSFD形式があり、メモリ・カードではFDISK形式が普通です。この関数は<em>複数区画には対応していない</em>ので、その物理ドライブの既存の区画は全て削除され、全体が一つの区画になります。</p>
|
||||||
<p>FATタイプ(FAT12/FAT16/FAT32)は、その論理ドライブ上の<em>クラスタ数によってのみ決定</em>される[FAT仕様書より]決まりになっていて、それ以外の要因はありません。したがって、どのFATタイプになるかはドライブ・サイズと指定されたクラスタ・サイズに依存します。クラスタ・サイズは大きくするほど性能が上がり、逆にディスク利用効率は落ちます。</p>
|
<p>FATタイプ(FAT12/FAT16/FAT32)は、その論理ドライブ上の<em>クラスタ数によってのみ決定</em>される[FAT仕様書より]決まりになっていて、それ以外の要因はありません。したがって、どのFATタイプになるかはドライブ・サイズと指定されたクラスタ・サイズに依存します。クラスタ・サイズは大きくするほど性能が上がり、逆にディスク利用効率は落ちます。</p>
|
||||||
<p>この関数は、構成オプション<tt>_USE_MKFS</tt>を選択したときにサポートされます。</p>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_MKFS == 1</tt>のとき使用可能です。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -49,6 +49,12 @@ FRESULT f_mount (
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p>全ての構成で使用可能です。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>ŽQ<EFBFBD>Æ</h4>
|
<h4>ŽQ<EFBFBD>Æ</h4>
|
||||||
<p><tt><a href="sfatfs.html">FATFS</a></tt></p>
|
<p><tt><a href="sfatfs.html">FATFS</a></tt></p>
|
||||||
|
|||||||
@ -63,7 +63,7 @@ FRESULT f_open (
|
|||||||
<dt>FR_DENIED</dt>
|
<dt>FR_DENIED</dt>
|
||||||
<dd>アクセスが拒否された。リード・オンリー・ファイルの書き込みモード・オープン、同名のディレクトリまたはリード・オンリー・ファイルがある状態でのファイル作成、ディスクまたはディレクトリ・テーブルが満杯でファイルを作成できないなど。</dd>
|
<dd>アクセスが拒否された。リード・オンリー・ファイルの書き込みモード・オープン、同名のディレクトリまたはリード・オンリー・ファイルがある状態でのファイル作成、ディスクまたはディレクトリ・テーブルが満杯でファイルを作成できないなど。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_WRITE_PROTECTED</dt>
|
<dt>FR_WRITE_PROTECTED</dt>
|
||||||
<dd>メディアが書き込み禁止状態で書き込み系オープンをした。</dd>
|
<dd>メディアが書き込み禁止状態で書き込み系オープンをした。</dd>
|
||||||
<dt>FR_DISK_ERR</dt>
|
<dt>FR_DISK_ERR</dt>
|
||||||
@ -73,16 +73,21 @@ FRESULT f_open (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>その論理ドライブにワーク・エリアが割り当てられていない。</dd>
|
<dd>その論理ドライブにワーク・エリアが割り当てられていない。</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
|
<dd>ディスク上に有効なFATボリュームが見つからない。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>解説</h4>
|
<h4>解説</h4>
|
||||||
<p>作成されたファイル・オブジェクトは、以降そのファイルに対するアクセスに使用します。ファイルを閉じるときは、<a href="close.html">f_close()</a>を使用します。何らかの変更が行われたファイルが正しく閉じられなかった場合、そのファイルが破損する場合があります。</p>
|
<p>既存のファイルを開いたり、新しいファイルを作成します。関数が成功するとファイル・オブジェクトが作成され、以降そのファイルに対するアクセスに使用します。ファイルを閉じるときは、<a href="close.html">f_close()</a>を使用します。何らかの変更が行われたファイルがその後正しく閉じられなかった場合、そのファイルが破損する場合があります。</p>
|
||||||
<p>ファイル・アクセスを開始する前に、<a href="mount.html">f_mount()</a>を使ってそれぞれの論理ドライブにワーク・エリア(ファイル・システム・オブジェクト)を与える必要があります。この初期化の後、その論理ドライブに対して全てのファイル関数が使えるようになります。</p>
|
<p>ファイル・アクセスを開始する前に、<a href="mount.html">f_mount()</a>を使ってそれぞれの論理ドライブにワーク・エリア(ファイル・システム・オブジェクト)を与える必要があります。この初期化の後、その論理ドライブに対して全てのファイル関数が使えるようになります。</p>
|
||||||
<p>リードオンリー構成では、<tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>の各フラグはサポートされません。</p>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p>全ての構成で使用可能です。<tt>_FS_READONLY == 1</tt>のときは、<tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>の各フラグはサポートされません。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -91,37 +96,37 @@ FRESULT f_open (
|
|||||||
<pre>
|
<pre>
|
||||||
void main (void)
|
void main (void)
|
||||||
{
|
{
|
||||||
FATFS fs[2]; // 論理ドライブのワーク・エリア(ファイル・システム・オブジェクト)
|
FATFS fs[2]; /* 論理ドライブのワーク・エリア(ファイル・システム・オブジェクト) */
|
||||||
FIL fsrc, fdst; // ファイル・オブジェクト
|
FIL fsrc, fdst; /* ファイル・オブジェクト */
|
||||||
BYTE buffer[4096]; // file copy buffer
|
BYTE buffer[4096]; /* file copy buffer */
|
||||||
FRESULT res; // FatFs function common result code
|
FRESULT res; /* FatFs function common result code */
|
||||||
UINT br, bw; // File R/W count
|
UINT br, bw; /* File R/W count */
|
||||||
|
|
||||||
// ドライブ0,1にワーク・エリアを与える
|
/* ドライブ0,1にワーク・エリアを与える */
|
||||||
f_mount(0, &fs[0]);
|
f_mount(0, &fs[0]);
|
||||||
f_mount(1, &fs[1]);
|
f_mount(1, &fs[1]);
|
||||||
|
|
||||||
// ドライブ1のソース・ファイルを開く
|
/* ドライブ1のソース・ファイルを開く */
|
||||||
res = f_open(&fsrc, "1:srcfile.dat", FA_OPEN_EXISTING | FA_READ);
|
res = f_open(&fsrc, "1:srcfile.dat", FA_OPEN_EXISTING | FA_READ);
|
||||||
if (res) die(res);
|
if (res) die(res);
|
||||||
|
|
||||||
// ドライブ0にデスティネーション・ファイルを作成する
|
/* ドライブ0にデスティネーション・ファイルを作成する */
|
||||||
res = f_open(&fdst, "0:dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE);
|
res = f_open(&fdst, "0:dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE);
|
||||||
if (res) die(res);
|
if (res) die(res);
|
||||||
|
|
||||||
// ソースからデスティネーションにコピーする
|
/* ソースからデスティネーションにコピーする */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
res = f_read(&fsrc, buffer, sizeof(buffer), &br);
|
res = f_read(&fsrc, buffer, sizeof(buffer), &br);
|
||||||
if (res || br == 0) break; // error or eof
|
if (res || br == 0) break; /* エラーかファイル終端 */
|
||||||
res = f_write(&fdst, buffer, br, &bw);
|
res = f_write(&fdst, buffer, br, &bw);
|
||||||
if (res || bw < br) break; // error or disk full
|
if (res || bw < br) break; /* エラーかディスク満杯 */
|
||||||
}
|
}
|
||||||
|
|
||||||
// 全てのファイルを閉じる
|
/* 全てのファイルを閉じる */
|
||||||
f_close(&fsrc);
|
f_close(&fsrc);
|
||||||
f_close(&fdst);
|
f_close(&fdst);
|
||||||
|
|
||||||
// ワーク・エリアを開放する
|
/* ワーク・エリアを開放する */
|
||||||
f_mount(0, NULL);
|
f_mount(0, NULL);
|
||||||
f_mount(1, NULL);
|
f_mount(1, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h2>f_opendir</h2>
|
<h2>f_opendir</h2>
|
||||||
<p>ディレクトリをオープンします。</p>
|
<p>ディレクトリを開きます。</p>
|
||||||
<pre>
|
<pre>
|
||||||
FRESULT f_opendir (
|
FRESULT f_opendir (
|
||||||
DIR* <em>DirObject</em>, /* ディレクトリ・ブジェクト構造体へのポインタ */
|
DIR* <em>DirObject</em>, /* ディレクトリ・ブジェクト構造体へのポインタ */
|
||||||
@ -44,7 +44,7 @@ FRESULT f_opendir (
|
|||||||
<dt>FR_INVALID_DRIVE</dt>
|
<dt>FR_INVALID_DRIVE</dt>
|
||||||
<dd>ドライブ番号が不正。</dd>
|
<dd>ドライブ番号が不正。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_DISK_ERR</dt>
|
<dt>FR_DISK_ERR</dt>
|
||||||
<dd>ディスク・エラーによる失敗。</dd>
|
<dd>ディスク・エラーによる失敗。</dd>
|
||||||
<dt>FR_INT_ERR</dt>
|
<dt>FR_INT_ERR</dt>
|
||||||
@ -52,14 +52,20 @@ FRESULT f_opendir (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>論理ドライブにワーク・エリアが与えられていない。</dd>
|
<dd>論理ドライブにワーク・エリアが与えられていない。</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
|
<dd>ディスク上に有効なFATボリュームが見つからない。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>解説</h4>
|
<h4>解説</h4>
|
||||||
<p>ディレクトリをオープンします。正常終了したら、<tt>DirObject</tt>構造体を使ってこのディレクトリの項目を順次読み出せます。<tt>DirObject</tt>構造体は使用後は任意の時点で破棄できます。<tt>_FS_MINIMIZE >= 2</tt>ではこの関数はサポートされません。</p>
|
<p>ディレクトリを開きます。正常終了したら、<tt>DirObject</tt>構造体を使ってこのディレクトリの項目を順次読み出せます。<tt>DirObject</tt>構造体は使用後は任意の時点で破棄できます。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_MINIMIZE <= 1</tt>のとき使用可能になります。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,18 @@ int f_printf (
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>‰ð<EFBFBD>à</h4>
|
<h4>‰ð<EFBFBD>à</h4>
|
||||||
<p>この関数は<a href="putc.html">f_putc()</a>および<a href="puts.html">f_puts()</a>のラッパー関数です。書式制御機能はサブセットとなっていて、使用可能はタイプは<tt>c s d u X</tt>、精度指定は<tt>l</tt>、フラグは<tt>0</tt>となっています。リード・ライト構成で<tt>_USE_STRFUNC</tt>が1または2のときこの関数がサポートされます。</p>
|
<p>この関数は<a href="putc.html">f_putc()</a>および<a href="puts.html">f_puts()</a>のラッパー関数です。書式制御機能はサブセットとなっていて、書式制御文字は次に示すものが使用可能です。</p>
|
||||||
|
<ul>
|
||||||
|
<li>タイプ: <tt>c s d u X</tt></li>
|
||||||
|
<li>精度指定: <tt>l</tt></li>
|
||||||
|
<li>フラグ: <tt>0</tt></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_STRFUNC</tt>が 1または 2のとき使用可能になります。2の時は、出力に含まれる<tt>'\n'</tt>が<tt>"\r\n"</tt>に展開されてファイルに書き込まれます。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,13 @@ int f_putc (
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>‰ð<EFBFBD>à</h4>
|
<h4>‰ð<EFBFBD>à</h4>
|
||||||
<p>この関数は<a href="write.html">f_write()</a>のラッパー関数です。リード・ライト構成で、<tt>_USE_STRFUNC</tt>が1または2のときこの関数がサポートされます。2を指定すると、<tt>'\n'</tt>は<tt>"\r\n"</tt>に変換されて書き込まれます。</p>
|
<p>1文字をファイルに書き込みます。この関数は<a href="write.html">f_write()</a>のラッパー関数です。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_STRFUNC</tt>が 1または 2のとき使用可能です。2を指定すると、<tt>'\n'</tt>は<tt>"\r\n"</tt>に展開されてファイルに書き込まれます。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -40,7 +40,13 @@ int f_puts (
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>‰ð<EFBFBD>à</h4>
|
<h4>‰ð<EFBFBD>à</h4>
|
||||||
<p>この関数は<a href="putc.html">f_putc()</a>のラッパー関数です。リード・ライト構成で、<tt>_USE_STRFUNC</tt>が1または2のときこの関数がサポートされます。2を指定すると、文字列中の<tt>'\n'</tt>が<tt>"\r\n"</tt>に変換されて書き込まれます。</p>
|
<p>文字列をファイルに書き込みます。この関数は<a href="putc.html">f_putc()</a>のラッパー関数です。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_STRFUNC</tt>が 1または 2のとき使用可能です。2を指定すると、文字列に含まれる<tt>'\n'</tt>は<tt>"\r\n"</tt>に展開されてファイルに書き込まれます。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@ FRESULT f_read (
|
|||||||
<dt>ByteToRead</dt>
|
<dt>ByteToRead</dt>
|
||||||
<dd>読み出すバイト数(0~UINTの最大値)を指定します。</dd>
|
<dd>読み出すバイト数(0~UINTの最大値)を指定します。</dd>
|
||||||
<dt>ByteRead</dt>
|
<dt>ByteRead</dt>
|
||||||
<dd>実際に読み出されたバイト数を格納する変数を指すポインタを指定します。戻り値は常に有効です。</dd>
|
<dd>実際に読み出されたバイト数を格納する変数を指すポインタを指定します。戻り値は関数の成否にかかわらず常に有効です。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ FRESULT f_read (
|
|||||||
<dt>FR_INT_ERR</dt>
|
<dt>FR_INT_ERR</dt>
|
||||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_INVALID_OBJECT</dt>
|
<dt>FR_INVALID_OBJECT</dt>
|
||||||
<dd>無効なファイル・オブジェクト。</dd>
|
<dd>無効なファイル・オブジェクト。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@ -63,6 +63,12 @@ FRESULT f_read (
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p>全ての構成で使用可能です。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>参照</h4>
|
<h4>参照</h4>
|
||||||
<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>
|
<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>
|
||||||
|
|||||||
@ -38,7 +38,7 @@ FRESULT f_readdir (
|
|||||||
<dt>FR_OK (0)</dt>
|
<dt>FR_OK (0)</dt>
|
||||||
<dd>正常終了。</dd>
|
<dd>正常終了。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_DISK_ERR</dt>
|
<dt>FR_DISK_ERR</dt>
|
||||||
<dd>ディスク・エラーによる失敗。</dd>
|
<dd>ディスク・エラーによる失敗。</dd>
|
||||||
<dt>FR_INT_ERR</dt>
|
<dt>FR_INT_ERR</dt>
|
||||||
@ -51,9 +51,20 @@ FRESULT f_readdir (
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>解説</h4>
|
<h4>解説</h4>
|
||||||
<p>ディレクトリ項目を順次読み出します。この関数を繰り返し実行することによりディレクトリの全ての項目を読み出すことができます。全ての項目を読み出し、読み出す項目がもう無いときは、<tt>f_name[]</tt>メンバにヌル文字列が返されます。ボリューム名は読み出すときに棄てられ、現れることはありません。"."、".."は、相対パスが有効なとき(<tt>_FS_RPATH == 1</tt>)のみ現れます。得られるファイル情報の詳細については <tt>FILINFO</tt>構造体を参照してください。FileInfoにヌル・ポインタを指定すると、そのディレクトリのリード・インデックスを巻き戻します。</p>
|
<p>ディレクトリ項目を順次読み出します。この関数を繰り返し実行することによりディレクトリの全ての項目を読み出すことができます。全ての項目を読み出し、読み出す項目がもう無いときは、<tt>f_name[]</tt>メンバにヌル文字列が返されます。ボリューム名は読み出すときに棄てられ、現れることはありません。"."、".."は、相対パスが有効なとき(<tt>_FS_RPATH == 1</tt>)にのみ現れます。得られるファイル情報の詳細については <tt>FILINFO</tt>構造体を参照してください。FileInfoにヌル・ポインタを指定すると、そのディレクトリのリード・インデックスを巻き戻します。</p>
|
||||||
<p>LFN機能が有効な時は、f_readdir関数の呼び出しに先立ってFILINFO構造体の<tt>lfname</tt>と<tt>lfsize</tt>が有効な値で初期化されていなければなりません。<tt>lfname</tt>はLFNを格納するバッファで、<tt>lfsize</tt>はそのバッファ・サイズです。LFN格納バッファまたはLFN操作バッファどちらかのサイズがそのLFNのサイズに対して不十分だった場合またはLFNが存在しない場合は、LFN格納バッファにヌル文字列が返されます。LFNにローカル・コードに存在しない文字が含まれている場合も同様ですが、Unicode APIが指定されている場合は文字コードの制約はありません。<tt>lfname</tt>にヌル・ポインタを指定した場合は、LFNに関して何も返されません。</p>
|
<p>LFN機能が有効な時は、f_readdir関数の呼び出しに先立ってFILINFO構造体の<tt>lfname</tt>と<tt>lfsize</tt>が有効な値で初期化されていなければなりません。<tt>lfname</tt>はLFNを格納するバッファで、<tt>lfsize</tt>はそのバッファ・サイズ(文字数)です。次の条件に一つでも該当する場合は、LFN格納バッファにヌル文字列が返されます。</p>
|
||||||
<p><tt>_FS_MINIMIZE >= 2</tt>ではこの関数はサポートされません。</p>
|
<ul>
|
||||||
|
<li>そのディレクトリ項目にLFNが存在しない。</li>
|
||||||
|
<li>LFNの長さに対してLFN格納バッファまたはLFN操作バッファのサイズが不十分。</li>
|
||||||
|
<li>LFNにOEMコードに存在しない文字が含まれている。(Unicode APIではないとき)</li>
|
||||||
|
</ul>
|
||||||
|
<p>また、<tt>lfname</tt>にヌル・ポインタを指定した場合は、LFNに関して何も返されません。LFNが存在しないときは、<tt>f_name[]</tt>メンバのSFNにASCII英小文字が含まれる場合があります。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_MINIMIZE <= 1</tt>のときに使用可能です。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -80,12 +91,12 @@ FRESULT scan_files (char* path)
|
|||||||
for (;;) {
|
for (;;) {
|
||||||
res = f_readdir(&dir, &fno);
|
res = f_readdir(&dir, &fno);
|
||||||
if (res != FR_OK || fno.fname[0] == 0) break;
|
if (res != FR_OK || fno.fname[0] == 0) break;
|
||||||
|
if (fno.fname[0] == '.') continue;
|
||||||
#if _USE_LFN
|
#if _USE_LFN
|
||||||
fn = *fno.lfname ? fno.lfname : fno.fname;
|
fn = *fno.lfname ? fno.lfname : fno.fname;
|
||||||
#else
|
#else
|
||||||
fn = fno.fname;
|
fn = fno.fname;
|
||||||
#endif
|
#endif
|
||||||
if (*fn == '.') continue;
|
|
||||||
if (fno.fattrib & AM_DIR) {
|
if (fno.fattrib & AM_DIR) {
|
||||||
sprintf(&path[i], "/%s", fn);
|
sprintf(&path[i], "/%s", fn);
|
||||||
res = scan_files(path);
|
res = scan_files(path);
|
||||||
|
|||||||
@ -27,7 +27,7 @@ FRESULT f_rename (
|
|||||||
<dt>OldName</dt>
|
<dt>OldName</dt>
|
||||||
<dd>変更対象のオブジェクト(ファイルまたはディレクトリ)への<a href="filename.html">パス名</a>の入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd>
|
<dd>変更対象のオブジェクト(ファイルまたはディレクトリ)への<a href="filename.html">パス名</a>の入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd>
|
||||||
<dt>NewName</dt>
|
<dt>NewName</dt>
|
||||||
<dd>新しいファイルまたはディレクトリのフルパス名の入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。既に存在するものと同じ名前は使えません。また、ドライブ番号は指定できず、<tt>OldName</tt>で指定されたドライブ上のオブジェクトとして扱われます。<br>
|
<dd>新しいファイルまたはディレクトリのフルパス名の入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。既に存在する名前は使えません。また、ドライブ番号は指定できず、<tt>OldName</tt>で指定されたボリューム上のオブジェクトとして扱われます。<br>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -48,9 +48,9 @@ FRESULT f_rename (
|
|||||||
<dt>FR_DENIED</dt>
|
<dt>FR_DENIED</dt>
|
||||||
<dd>ドライブ容量の不足等の理由で新しい名前のオブジェクトが作れない。</dd>
|
<dd>ドライブ容量の不足等の理由で新しい名前のオブジェクトが作れない。</dd>
|
||||||
<dt>FR_EXIST</dt>
|
<dt>FR_EXIST</dt>
|
||||||
<dd>NewNameと同じオブジェクトが既に存在する。</dd>
|
<dd>NewNameと同じ名前が既に存在する。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_WRITE_PROTECTED</dt>
|
<dt>FR_WRITE_PROTECTED</dt>
|
||||||
<dd>メディアが書き込み禁止状態。</dd>
|
<dd>メディアが書き込み禁止状態。</dd>
|
||||||
<dt>FR_DISK_ERR</dt>
|
<dt>FR_DISK_ERR</dt>
|
||||||
@ -60,24 +60,30 @@ FRESULT f_rename (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>論理ドライブにワークエリアが割り当てられていない。</dd>
|
<dd>論理ドライブにワークエリアが割り当てられていない。</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
|
<dd>ディスク上に有効なFATボリュームが見つからない。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>解説</h4>
|
<h4>解説</h4>
|
||||||
<p>ファイルまたはディレクトリの名前を変更します。また、別のディレクトリへの移動(同じドライブ内のみ)も可能です。リード・オンリー構成および<tt>_FS_MINIMIZE >= 1</tt>ではこの関数はサポートされません。</p>
|
<p>オブジェクトの名前を変更します。また、別のディレクトリへの移動(同じドライブ内のみ)も可能です。<em>開かれているオブジェクトに対して使用してはなりません</em>。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_FS_MINIMIZE == 0</tt>のときに使用可能です。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>使用例</h4>
|
<h4>使用例</h4>
|
||||||
<pre>
|
<pre>
|
||||||
// ファイルまたはサブディレクトリの名前を変更する
|
/* ファイルまたはサブディレクトリの名前を変更する */
|
||||||
f_rename("oldname.txt", "newname.txt");
|
f_rename("oldname.txt", "newname.txt");
|
||||||
|
|
||||||
// ファイルまたはサブディレクトリの名前を変更すると同時に別のディレクトリへ移動する
|
/* ファイルまたはサブディレクトリの名前の変更と別のディレクトリへの移動 */
|
||||||
f_rename("oldname.txt", "dir1/newname.txt");
|
f_rename("oldname.txt", "dir1/newname.txt");
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -21,6 +21,7 @@ typedef struct _FATFS_ {
|
|||||||
BYTE csize; /* Number of sectors per cluster */
|
BYTE csize; /* Number of sectors per cluster */
|
||||||
BYTE n_fats; /* Number of FAT copies */
|
BYTE n_fats; /* Number of FAT copies */
|
||||||
BYTE wflag; /* win[] dirty flag (1:must be written back) */
|
BYTE wflag; /* win[] dirty flag (1:must be written back) */
|
||||||
|
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
|
||||||
WORD id; /* File system mount ID */
|
WORD id; /* File system mount ID */
|
||||||
WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */
|
WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */
|
||||||
#if _FS_REENTRANT
|
#if _FS_REENTRANT
|
||||||
@ -30,7 +31,6 @@ typedef struct _FATFS_ {
|
|||||||
WORD s_size; /* Sector size */
|
WORD s_size; /* Sector size */
|
||||||
#endif
|
#endif
|
||||||
#if !_FS_READONLY
|
#if !_FS_READONLY
|
||||||
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
|
|
||||||
DWORD last_clust; /* Last allocated cluster */
|
DWORD last_clust; /* Last allocated cluster */
|
||||||
DWORD free_clust; /* Number of free clusters */
|
DWORD free_clust; /* Number of free clusters */
|
||||||
DWORD fsi_sector; /* fsinfo sector */
|
DWORD fsi_sector; /* fsinfo sector */
|
||||||
|
|||||||
@ -57,11 +57,11 @@ typedef struct _FILINFO_ {
|
|||||||
<dt>fattrib</dt>
|
<dt>fattrib</dt>
|
||||||
<dd>属性フラグが格納されます。フラグは<tt>AM_DIR, AM_RDO, AM_HID, AM_SYS, AM_ARC</tt>の組み合わせとなります。</dd>
|
<dd>属性フラグが格納されます。フラグは<tt>AM_DIR, AM_RDO, AM_HID, AM_SYS, AM_ARC</tt>の組み合わせとなります。</dd>
|
||||||
<dt>fname[]</dt>
|
<dt>fname[]</dt>
|
||||||
<dd>8.3形式の名前が<tt>'\0'</tt>で終わる文字列として格納されます。</dd>
|
<dd>8.3形式の名前が<tt>'\0'</tt>で終わる文字列として格納されます。非LFN構成のときは、常に大文字で返されます。LFN構成のときは短い名前が返されますが、ASCII英字が小文字になる場合があります。</dd>
|
||||||
<dt>lfname</dt>
|
<dt>lfname</dt>
|
||||||
<dd>返される長いファイル名を格納するバッファへのポインタ。この構造体を使用する前にアプリケーションにより初期化されなければなりません。非LFN構成のときは存在しません。</dd>
|
<dd>返される長いファイル名を格納するバッファへのポインタ。この構造体を使用する前にアプリケーションにより初期化されなければなりません。非LFN構成のときはこのメンバは存在しません。</dd>
|
||||||
<dt>lfsize</dt>
|
<dt>lfsize</dt>
|
||||||
<dd>長いファイル名を格納するバッファのサイズ(文字数)。この構造体を使用する前にアプリケーションにより初期化されなければなりません。非LFN構成のときは存在しません。</dd>
|
<dd>長いファイル名を格納するバッファのサイズ(文字数)。この構造体を使用する前にアプリケーションにより初期化されなければなりません。非LFN構成のときはこのメンバは存在しません。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
||||||
|
|||||||
@ -45,7 +45,7 @@ FRESULT f_stat (
|
|||||||
<dt>FR_INVALID_DRIVE</dt>
|
<dt>FR_INVALID_DRIVE</dt>
|
||||||
<dd>ドライブ番号が不正。</dd>
|
<dd>ドライブ番号が不正。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_DISK_ERR</dt>
|
<dt>FR_DISK_ERR</dt>
|
||||||
<dd>ディスク・エラーによる失敗。</dd>
|
<dd>ディスク・エラーによる失敗。</dd>
|
||||||
<dt>FR_INT_ERR</dt>
|
<dt>FR_INT_ERR</dt>
|
||||||
@ -53,14 +53,20 @@ FRESULT f_stat (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>論理ドライブにワークエリアが割り当てられていない。</dd>
|
<dd>論理ドライブにワークエリアが割り当てられていない。</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
|
<dd>ディスク上に有効なFATボリュームが見つからない。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>解説</h4>
|
<h4>解説</h4>
|
||||||
<p>ファイルまたはディレクトリに関する情報を得ます。得られるファイル情報の詳細については <tt>FILINFO</tt>構造体を参照してください。<tt>_FS_MINIMIZE >= 1</tt>ではこの関数はサポートされません。</p>
|
<p>ファイルまたはディレクトリに関する情報を得ます。得られるファイル情報の詳細については <tt>FILINFO</tt>構造体を参照してください。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_MINIMIZE == 0</tt>のときに使用可能です。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,7 @@ FRESULT f_sync (
|
|||||||
<dt>FR_INT_ERR</dt>
|
<dt>FR_INT_ERR</dt>
|
||||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_INVALID_OBJECT</dt>
|
<dt>FR_INVALID_OBJECT</dt>
|
||||||
<dd>ファイル・オブジェクトが無効。</dd>
|
<dd>ファイル・オブジェクトが無効。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@ -49,7 +49,12 @@ FRESULT f_sync (
|
|||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>解説</h4>
|
<h4>解説</h4>
|
||||||
<p>この関数は<tt>f_close()</tt>と同じ処理を実行しますが、ファイルは引き続き開かれたままになり、読み書きを続行できます。ロギングなど、書き込みモードで長時間ファイルが開かれているアプリケーションにおいて、定期的または区切りの良いところでsyncすることにより、不意の電源断やメディアの取り外しにより失われるデータを最小にすることができます。実際のところ、f_closeではsyncしたあとファイル・オブジェクトを破棄しているだけなので、f_close直前のsyncは意味がありません。</p>
|
<p>この関数は<tt>f_close()</tt>と同じ処理を実行しますが、ファイルは引き続き開かれたままになり、読み書きを続行できます。ロギングなど、書き込みモードで長時間ファイルが開かれているアプリケーションにおいて、定期的または区切りの良いところでsyncすることにより、不意の電源断やメディアの取り外しにより失われるデータを最小にすることができます。実際のところ、f_closeではsyncしたあとファイル・オブジェクトを破棄しているだけなので、f_close直前のsyncは意味がありません。</p>
|
||||||
<p>リード・オンリー構成ではこの関数はサポートされません。</p>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_READONLY == 0</tt>のときに使用可能です。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,13 @@ FRESULT f_truncate (
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>‰ð<EFBFBD>à</h4>
|
<h4>‰ð<EFBFBD>à</h4>
|
||||||
<p>ファイルの長さが現在のファイルR/Wポインタに切り詰められます。ファイルR/Wポインタがファイルの終端を指しているときは、この関数は何の効果も持ちません。リード・オンリー構成および<tt>_FS_MINIMIZE >= 1</tt>ではこの関数はサポートされません。</p>
|
<p>ファイルの長さが現在のファイルR/Wポインタに切り詰められます。ファイルR/Wポインタがファイルの終端を指しているときは、この関数は何の効果も持ちません。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_FS_MINIMIZE == 0</tt>のときに使用可能です。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -12,10 +12,10 @@
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h2>f_unlink</h2>
|
<h2>f_unlink</h2>
|
||||||
<p>ファイルまたはディレクトリを削除します。</p>
|
<p>オブジェクトを削除します。</p>
|
||||||
<pre>
|
<pre>
|
||||||
FRESULT f_unlink (
|
FRESULT f_unlink (
|
||||||
const XCHAR* <em>FileName</em> /* ファイルまたはディレクトリ名へのポインタ */
|
const XCHAR* <em>FileName</em> /* オブジェクト名へのポインタ */
|
||||||
);
|
);
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
@ -43,7 +43,7 @@ FRESULT f_unlink (
|
|||||||
<dt>FR_INVALID_DRIVE</dt>
|
<dt>FR_INVALID_DRIVE</dt>
|
||||||
<dd>ドライブ番号が不正。</dd>
|
<dd>ドライブ番号が不正。</dd>
|
||||||
<dt>FR_DENIED</dt>
|
<dt>FR_DENIED</dt>
|
||||||
<dd>対象ファイル・ディレクトリがリード・オンリー状態、対象ディレクトリが空でない場合など。</dd>
|
<dd>対象オブジェクトがリード・オンリー属性、ディレクトリの場合は空でない場合など。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_WRITE_PROTECTED</dt>
|
<dt>FR_WRITE_PROTECTED</dt>
|
||||||
@ -55,16 +55,22 @@ FRESULT f_unlink (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>論理ドライブにワーク・エリアが割り当てられていない。</dd>
|
<dd>論理ドライブにワーク・エリアが割り当てられていない。</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
|
<dd>ディスク上に有効なFATボリュームが見つからない。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>解説</h4>
|
<h4>解説</h4>
|
||||||
<p>ファイルまたはディレクトリを削除します。リード・オンリー構成や<tt>_FS_MINIMIZE >= 1</tt>ではこの関数はサポートされません。</p>
|
<p>オブジェクトを削除します。<em>開かれているオブジェクトやカレント・ディレクトリは削除してはなりません</em>。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_FS_MINIMIZE == 0</tt>のときに使用可能です。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
<p class="foot"><a href="../00index_j.html">戻る</a></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@ -12,10 +12,10 @@
|
|||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h2>f_utime</h2>
|
<h2>f_utime</h2>
|
||||||
<p>ファイルまたはディレクトリのタイムスタンプを変更します。</p>
|
<p>オブジェクトのタイムスタンプを変更します。</p>
|
||||||
<pre>
|
<pre>
|
||||||
FRESULT f_utime (
|
FRESULT f_utime (
|
||||||
const XCHAR* <em>FileName</em>, /* ファイルまたはディレクトリ名へのポインタ */
|
const XCHAR* <em>FileName</em>, /* オブジェクト名へのポインタ */
|
||||||
const FILINFO* <em>TimeDate</em> /* 設定する日付 */
|
const FILINFO* <em>TimeDate</em> /* 設定する日付 */
|
||||||
);
|
);
|
||||||
</pre>
|
</pre>
|
||||||
@ -46,7 +46,7 @@ FRESULT f_utime (
|
|||||||
<dt>FR_INVALID_NAME</dt>
|
<dt>FR_INVALID_NAME</dt>
|
||||||
<dd>ドライブ番号が不正。</dd>
|
<dd>ドライブ番号が不正。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_WRITE_PROTECTED</dt>
|
<dt>FR_WRITE_PROTECTED</dt>
|
||||||
<dd>メディアが書き込み禁止状態。</dd>
|
<dd>メディアが書き込み禁止状態。</dd>
|
||||||
<dt>FR_DISK_ERR</dt>
|
<dt>FR_DISK_ERR</dt>
|
||||||
@ -56,14 +56,20 @@ FRESULT f_utime (
|
|||||||
<dt>FR_NOT_ENABLED</dt>
|
<dt>FR_NOT_ENABLED</dt>
|
||||||
<dd>その論理ドライブにワーク・エリアが与えられていない。</dd>
|
<dd>その論理ドライブにワーク・エリアが与えられていない。</dd>
|
||||||
<dt>FR_NO_FILESYSTEM</dt>
|
<dt>FR_NO_FILESYSTEM</dt>
|
||||||
<dd>ディスク上に有効なFATパーテーションが見つからない。</dd>
|
<dd>ディスク上に有効なFATボリュームが見つからない。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>解説</h4>
|
<h4>解説</h4>
|
||||||
<p>ファイルまたはディレクトリのタイムスタンプを変更します。リード・オンリー構成および<tt>_FS_MINIMIZE >= 1</tt>ではこの関数はサポートされません。</p>
|
<p>オブジェクトのタイムスタンプを変更します。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_FS_MINIMIZE == 0</tt>のときに使用可能です。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@ FRESULT f_write (
|
|||||||
<dt>ByteToWrite</dt>
|
<dt>ByteToWrite</dt>
|
||||||
<dd>書き込むバイト数(0~UINTの最大値)を指定します。</dd>
|
<dd>書き込むバイト数(0~UINTの最大値)を指定します。</dd>
|
||||||
<dt>ByteWritten</dt>
|
<dt>ByteWritten</dt>
|
||||||
<dd>書き込まれたバイト数を格納する変数を指すポインタを指定します。戻り値は常に有効です。</dd>
|
<dd>書き込まれたバイト数を格納する変数を指すポインタを指定します。戻り値は関数の成否にかかわらず常に有効です。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ FRESULT f_write (
|
|||||||
<dt>FR_INT_ERR</dt>
|
<dt>FR_INT_ERR</dt>
|
||||||
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
<dd>不正なFAT構造または内部エラーによる失敗。</dd>
|
||||||
<dt>FR_NOT_READY</dt>
|
<dt>FR_NOT_READY</dt>
|
||||||
<dd>メディアがセットされていないなど、ディスク・ドライブが動作不能状態。</dd>
|
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
|
||||||
<dt>FR_INVALID_OBJECT</dt>
|
<dt>FR_INVALID_OBJECT</dt>
|
||||||
<dd>無効なファイルオブジェクト。</dd>
|
<dd>無効なファイルオブジェクト。</dd>
|
||||||
</dl>
|
</dl>
|
||||||
@ -60,7 +60,12 @@ FRESULT f_write (
|
|||||||
<div class="para">
|
<div class="para">
|
||||||
<h4>解説</h4>
|
<h4>解説</h4>
|
||||||
<p>書き込み開始位置は、ファイルR/Wポインタの位置からになります。ファイルR/Wポインタは実際に書き込まれたバイト数だけ進みます。関数が正常終了した後、要求したバイト数が書き込まれたかどうか<tt>*ByteWritten</tt>をチェックすべきです。<tt>*ByteWritten < ByteToWrite</tt>のときは、ディスク・フルを意味します。</p>
|
<p>書き込み開始位置は、ファイルR/Wポインタの位置からになります。ファイルR/Wポインタは実際に書き込まれたバイト数だけ進みます。関数が正常終了した後、要求したバイト数が書き込まれたかどうか<tt>*ByteWritten</tt>をチェックすべきです。<tt>*ByteWritten < ByteToWrite</tt>のときは、ディスク・フルを意味します。</p>
|
||||||
<p>リード・オンリー構成ではこの関数はサポートされません。</p>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="para">
|
||||||
|
<h4>対応情報</h4>
|
||||||
|
<p><tt>_FS_READONLY == 0</tt>のときに使用可能です。</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,18 +0,0 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
||||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
|
||||||
<link rel="start" title="Site Top" href="../../">
|
|
||||||
<link rel="stylesheet" href="css_e.css" type="text/css" media="screen" title="ELM Default">
|
|
||||||
<title>Patches for FatFs R0.07b</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h2>Patches for FatFs R0.07b</h2>
|
|
||||||
<pre>
|
|
||||||
Jun 21, 2009
|
|
||||||
------------------------------------------------------------------------------
|
|
||||||
Currently no known problem.
|
|
||||||
</pre>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@ -1,17 +1,24 @@
|
|||||||
R0.07b, Jun 21, 2009
|
R0.07e, Nov 3, 2009
|
||||||
|
Separated out configuration options from ff.h to ffconf.h.
|
||||||
|
Added a configuration option, _LFN_UNICODE.
|
||||||
|
Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
|
||||||
|
Fixed name matching error on the 13 char boundary.
|
||||||
|
Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
|
||||||
|
|
||||||
|
R0.07c, Jun 21, 2009
|
||||||
Fixed f_unlink() may return FR_OK on error.
|
Fixed f_unlink() may return FR_OK on error.
|
||||||
Fixed wrong cache control in f_lseek().
|
Fixed wrong cache control in f_lseek().
|
||||||
Added relative path feature.
|
Added relative path feature.
|
||||||
Added f_chdir().
|
Added f_chdir().
|
||||||
Added f_chdrive().
|
Added f_chdrive().
|
||||||
Added proper case conversion to extended char.
|
Added proper case conversion to extended characters.
|
||||||
|
|
||||||
R0.07a, Apr 14, 2009
|
R0.07a, Apr 14, 2009
|
||||||
Separated out OS dependent code on re-entrant configuration.
|
Separated out OS dependent code on re-entrant configuration.
|
||||||
Added multiple sector size support.
|
Added multiple sector size support.
|
||||||
|
|
||||||
R0.07, Apr 01, 2009
|
R0.07, Apr 01, 2009
|
||||||
Merged Tiny-FatFs as a buffer configuration option.
|
Merged Tiny-FatFs into FatFs as a buffer configuration option.
|
||||||
Added long file name support.
|
Added long file name support.
|
||||||
Added multiple code page support.
|
Added multiple code page support.
|
||||||
Added re-entrancy for multitask operation.
|
Added re-entrancy for multitask operation.
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
FatFs Module Source Files R0.07c (C)ChaN, 2009
|
FatFs Module Source Files R0.07e (C)ChaN, 2009
|
||||||
|
|
||||||
|
|
||||||
FILES
|
FILES
|
||||||
|
|
||||||
|
ffconf.h Configuration file for FatFs module.
|
||||||
ff.h Common include file for FatFs and application module.
|
ff.h Common include file for FatFs and application module.
|
||||||
ff.c FatFs module.
|
ff.c FatFs module.
|
||||||
diskio.h Common include file for FatFs and disk I/O module.
|
diskio.h Common include file for FatFs and disk I/O module.
|
||||||
@ -100,5 +101,10 @@ REVISION HISTORY
|
|||||||
Added relative path feature.
|
Added relative path feature.
|
||||||
Added f_chdir().
|
Added f_chdir().
|
||||||
Added f_chdrive().
|
Added f_chdrive().
|
||||||
Added proper case conversion to extended char.
|
Added proper case conversion for extended characters.
|
||||||
|
|
||||||
|
Nov 03,'2009 R0.07e Separated out configuration options from ff.h to ffconf.h.
|
||||||
|
Added a configuration option, _LFN_UNICODE.
|
||||||
|
Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
|
||||||
|
Fixed name matching error on the 13 char boundary.
|
||||||
|
Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
|
||||||
|
|||||||
@ -49,7 +49,7 @@ DRESULT disk_ioctl (BYTE, BYTE, void*);
|
|||||||
/* Generic command */
|
/* Generic command */
|
||||||
#define CTRL_SYNC 0 /* Mandatory for write functions */
|
#define CTRL_SYNC 0 /* Mandatory for write functions */
|
||||||
#define GET_SECTOR_COUNT 1 /* Mandatory for only f_mkfs() */
|
#define GET_SECTOR_COUNT 1 /* Mandatory for only f_mkfs() */
|
||||||
#define GET_SECTOR_SIZE 2
|
#define GET_SECTOR_SIZE 2 /* Mandatory for multiple sector size cfg */
|
||||||
#define GET_BLOCK_SIZE 3 /* Mandatory for only f_mkfs() */
|
#define GET_BLOCK_SIZE 3 /* Mandatory for only f_mkfs() */
|
||||||
#define CTRL_POWER 4
|
#define CTRL_POWER 4
|
||||||
#define CTRL_LOCK 5
|
#define CTRL_LOCK 5
|
||||||
|
|||||||
256
src/ff.c
256
src/ff.c
@ -1,9 +1,9 @@
|
|||||||
/*----------------------------------------------------------------------------/
|
/*----------------------------------------------------------------------------/
|
||||||
/ FatFs - FAT file system module R0.07c (C)ChaN, 2009
|
/ FatFs - FAT file system module R0.07e (C)ChaN, 2009
|
||||||
/-----------------------------------------------------------------------------/
|
/-----------------------------------------------------------------------------/
|
||||||
/ FatFs module is an open source software to implement FAT file system to
|
/ FatFs module is a generic FAT file system module for small embedded systems.
|
||||||
/ small embedded systems. This is a free software and is opened for education,
|
/ This is a free software that opened for education, research and commercial
|
||||||
/ research and commercial use under license policy of following trems.
|
/ developments under license policy of following trems.
|
||||||
/
|
/
|
||||||
/ Copyright (C) 2009, ChaN, all right reserved.
|
/ Copyright (C) 2009, ChaN, all right reserved.
|
||||||
/
|
/
|
||||||
@ -63,11 +63,17 @@
|
|||||||
/ Renamed string functions to avoid name collision.
|
/ Renamed string functions to avoid name collision.
|
||||||
/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg.
|
/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg.
|
||||||
/ Added multiple sector size support.
|
/ Added multiple sector size support.
|
||||||
/ Jun 21,'09 R0.07c Fixed f_unlink() may return FR_OK on error.
|
/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error.
|
||||||
/ Fixed wrong cache control in f_lseek().
|
/ Fixed wrong cache control in f_lseek().
|
||||||
/ Added relative path feature.
|
/ Added relative path feature.
|
||||||
/ Added f_chdir() and f_chdrive().
|
/ Added f_chdir() and f_chdrive().
|
||||||
/ Added proper case conversion to extended char.
|
/ Added proper case conversion to extended char.
|
||||||
|
/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h.
|
||||||
|
/ Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
|
||||||
|
/ Fixed name matching error on the 13 char boundary.
|
||||||
|
/ Added a configuration option, _LFN_UNICODE.
|
||||||
|
/ Changed f_readdir() to return the SFN with always upper
|
||||||
|
/ case on non-LFN cfg.
|
||||||
/---------------------------------------------------------------------------*/
|
/---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "ff.h" /* FatFs configurations and declarations */
|
#include "ff.h" /* FatFs configurations and declarations */
|
||||||
@ -79,6 +85,10 @@
|
|||||||
|
|
||||||
---------------------------------------------------------------------------*/
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if _FATFS != 0x007E
|
||||||
|
#error Wrong include file (ff.h).
|
||||||
|
#endif
|
||||||
|
|
||||||
#if _FS_REENTRANT
|
#if _FS_REENTRANT
|
||||||
#if _USE_LFN == 1
|
#if _USE_LFN == 1
|
||||||
#error Static LFN work area must not be used in re-entrant configuration.
|
#error Static LFN work area must not be used in re-entrant configuration.
|
||||||
@ -99,7 +109,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Name status flags */
|
/* Name status flags */
|
||||||
#define NS_LOSS 0x01 /* Lossy conversion */
|
#define NS 11 /* Offset of name status byte */
|
||||||
|
#define NS_LOSS 0x01 /* Out of 8.3 format */
|
||||||
#define NS_LFN 0x02 /* Force to create LFN entry */
|
#define NS_LFN 0x02 /* Force to create LFN entry */
|
||||||
#define NS_LAST 0x04 /* Last segment */
|
#define NS_LAST 0x04 /* Last segment */
|
||||||
#define NS_BODY 0x08 /* Lower case flag (body) */
|
#define NS_BODY 0x08 /* Lower case flag (body) */
|
||||||
@ -115,6 +126,9 @@
|
|||||||
|
|
||||||
---------------------------------------------------------------------------*/
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#if _DRIVES < 1 || _DRIVES > 9
|
||||||
|
#error Number of drives must be 1-9.
|
||||||
|
#endif
|
||||||
static
|
static
|
||||||
FATFS *FatFs[_DRIVES]; /* Pointer to the file system objects (logical drives) */
|
FATFS *FatFs[_DRIVES]; /* Pointer to the file system objects (logical drives) */
|
||||||
|
|
||||||
@ -129,7 +143,7 @@ BYTE Drive; /* Current drive */
|
|||||||
|
|
||||||
#if _USE_LFN == 1 /* LFN with static LFN working buffer */
|
#if _USE_LFN == 1 /* LFN with static LFN working buffer */
|
||||||
static
|
static
|
||||||
WORD LfnBuf[_MAX_LFN + 1];
|
WCHAR LfnBuf[_MAX_LFN + 1];
|
||||||
#define NAMEBUF(sp,lp) BYTE sp[12]; WCHAR *lp = LfnBuf
|
#define NAMEBUF(sp,lp) BYTE sp[12]; WCHAR *lp = LfnBuf
|
||||||
#define INITBUF(dj,sp,lp) dj.fn = sp; dj.lfn = lp
|
#define INITBUF(dj,sp,lp) dj.fn = sp; dj.lfn = lp
|
||||||
|
|
||||||
@ -148,7 +162,7 @@ WORD LfnBuf[_MAX_LFN + 1];
|
|||||||
|
|
||||||
/*--------------------------------------------------------------------------
|
/*--------------------------------------------------------------------------
|
||||||
|
|
||||||
Private Functions
|
Module Private Functions
|
||||||
|
|
||||||
---------------------------------------------------------------------------*/
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -305,7 +319,7 @@ FRESULT sync ( /* FR_OK: successful, FR_DISK_ERR: failed */
|
|||||||
/* FAT access - Read value of a FAT entry */
|
/* FAT access - Read value of a FAT entry */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
static
|
|
||||||
DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Interal error, Else:Cluster status */
|
DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Interal error, Else:Cluster status */
|
||||||
FATFS *fs, /* File system object */
|
FATFS *fs, /* File system object */
|
||||||
DWORD clst /* Cluster# to get the link information */
|
DWORD clst /* Cluster# to get the link information */
|
||||||
@ -347,7 +361,7 @@ DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Interal error, Else:Cluster status *
|
|||||||
/* FAT access - Change value of a FAT entry */
|
/* FAT access - Change value of a FAT entry */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
#if !_FS_READONLY
|
#if !_FS_READONLY
|
||||||
static
|
|
||||||
FRESULT put_fat (
|
FRESULT put_fat (
|
||||||
FATFS *fs, /* File system object */
|
FATFS *fs, /* File system object */
|
||||||
DWORD clst, /* Cluster# to be changed in range of 2 to fs->max_clust - 1 */
|
DWORD clst, /* Cluster# to be changed in range of 2 to fs->max_clust - 1 */
|
||||||
@ -509,7 +523,7 @@ DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk err
|
|||||||
/* Get sector# from cluster# */
|
/* Get sector# from cluster# */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
static
|
|
||||||
DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */
|
DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */
|
||||||
FATFS *fs, /* File system object */
|
FATFS *fs, /* File system object */
|
||||||
DWORD clst /* Cluster# to be converted */
|
DWORD clst /* Cluster# to be converted */
|
||||||
@ -653,18 +667,26 @@ BOOL cmp_lfn ( /* TRUE:Matched, FALSE:Not matched */
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
int i, s;
|
int i, s;
|
||||||
WCHAR wc;
|
WCHAR wc, uc;
|
||||||
|
|
||||||
|
|
||||||
i = ((dir[LDIR_Ord] & 0xBF) - 1) * 13; /* Get offset in the LFN buffer */
|
i = ((dir[LDIR_Ord] & 0xBF) - 1) * 13; /* Get offset in the LFN buffer */
|
||||||
s = 0;
|
s = 0; wc = 1;
|
||||||
do {
|
do {
|
||||||
wc = ff_wtoupper(LD_WORD(dir+LfnOfs[s])); /* Get an LFN character */
|
uc = LD_WORD(dir+LfnOfs[s]); /* Pick an LFN character from the entry */
|
||||||
if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it with the reference character */
|
if (wc) { /* Last char has not been processed */
|
||||||
return FALSE;
|
wc = ff_wtoupper(uc); /* Convert it to upper case */
|
||||||
} while (++s < 13 && wc); /* Repeat until all chars in the entry or a NUL char is processed */
|
if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it */
|
||||||
|
return FALSE; /* Not matched */
|
||||||
|
} else {
|
||||||
|
if (uc != 0xFFFF) return FALSE; /* Check filler */
|
||||||
|
}
|
||||||
|
} while (++s < 13); /* Repeat until all chars in the entry are checked */
|
||||||
|
|
||||||
return TRUE; /* The LFN entry matched */
|
if ((dir[LDIR_Ord] & 0x40) && wc && lfnbuf[i]) /* Last segment matched but different length */
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return TRUE; /* The part of LFN matched */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -676,18 +698,21 @@ BOOL pick_lfn ( /* TRUE:Succeeded, FALSE:Buffer overflow */
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
int i, s;
|
int i, s;
|
||||||
WCHAR wc;
|
WCHAR wc, uc;
|
||||||
|
|
||||||
|
|
||||||
i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */
|
i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */
|
||||||
|
|
||||||
s = 0;
|
s = 0; wc = 1;
|
||||||
do {
|
do {
|
||||||
|
uc = LD_WORD(dir+LfnOfs[s]); /* Pick an LFN character from the entry */
|
||||||
|
if (wc) { /* Last char has not been processed */
|
||||||
if (i >= _MAX_LFN) return FALSE; /* Buffer overflow? */
|
if (i >= _MAX_LFN) return FALSE; /* Buffer overflow? */
|
||||||
wc = LD_WORD(dir+LfnOfs[s]); /* Get an LFN char */
|
lfnbuf[i++] = wc = uc; /* Store it */
|
||||||
if (!wc) break; /* End of LFN? */
|
} else {
|
||||||
lfnbuf[i++] = wc; /* Store it */
|
if (uc != 0xFFFF) return FALSE; /* Check filler */
|
||||||
} while (++s < 13); /* Repeat until last char is copied */
|
}
|
||||||
|
} while (++s < 13); /* Read all character in the entry */
|
||||||
|
|
||||||
if (dir[LDIR_Ord] & 0x40) { /* Put terminator if it is the last LFN part */
|
if (dir[LDIR_Ord] & 0x40) { /* Put terminator if it is the last LFN part */
|
||||||
if (i >= _MAX_LFN) return FALSE; /* Buffer overflow? */
|
if (i >= _MAX_LFN) return FALSE; /* Buffer overflow? */
|
||||||
@ -809,14 +834,14 @@ FRESULT dir_find (
|
|||||||
FRESULT res;
|
FRESULT res;
|
||||||
BYTE c, *dir;
|
BYTE c, *dir;
|
||||||
#if _USE_LFN
|
#if _USE_LFN
|
||||||
BYTE a, lfen, ord, sum;
|
BYTE a, ord, sum;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
res = dir_seek(dj, 0); /* Rewind directory object */
|
res = dir_seek(dj, 0); /* Rewind directory object */
|
||||||
if (res != FR_OK) return res;
|
if (res != FR_OK) return res;
|
||||||
|
|
||||||
#if _USE_LFN
|
#if _USE_LFN
|
||||||
ord = sum = 0xFF; lfen = *(dj->fn+11) & NS_LOSS;
|
ord = sum = 0xFF;
|
||||||
#endif
|
#endif
|
||||||
do {
|
do {
|
||||||
res = move_window(dj->fs, dj->sect);
|
res = move_window(dj->fs, dj->sect);
|
||||||
@ -836,18 +861,13 @@ FRESULT dir_find (
|
|||||||
c &= 0xBF; ord = c; /* LFN start order */
|
c &= 0xBF; ord = c; /* LFN start order */
|
||||||
dj->lfn_idx = dj->index;
|
dj->lfn_idx = dj->index;
|
||||||
}
|
}
|
||||||
/* Check LFN validity. Compare LFN if it is out of 8.3 format */
|
/* Check validity of the LFN entry and compare it with given name */
|
||||||
ord = (c == ord && sum == dir[LDIR_Chksum] && (!lfen || cmp_lfn(dj->lfn, dir))) ? ord - 1 : 0xFF;
|
ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dj->lfn, dir)) ? ord - 1 : 0xFF;
|
||||||
}
|
}
|
||||||
} else { /* An SFN entry is found */
|
} else { /* An SFN entry is found */
|
||||||
if (ord || sum != sum_sfn(dir)) /* Did not LFN match? */
|
if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */
|
||||||
dj->lfn_idx = 0xFFFF;
|
ord = 0xFF; dj->lfn_idx = 0xFFFF; /* Reset LFN sequence */
|
||||||
if (lfen) { /* Match LFN if it is out of 8.3 format */
|
if (!(dj->fn[NS] & NS_LOSS) && !mem_cmp(dir, dj->fn, 11)) break; /* SFN matched? */
|
||||||
if (ord == 0) break;
|
|
||||||
} else { /* Match SFN if LFN is in 8.3 format */
|
|
||||||
if (!mem_cmp(dir, dj->fn, 11)) break;
|
|
||||||
}
|
|
||||||
ord = 0xFF;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else /* Non LFN configuration */
|
#else /* Non LFN configuration */
|
||||||
@ -899,8 +919,8 @@ FRESULT dir_read (
|
|||||||
/* Check LFN validity and capture it */
|
/* Check LFN validity and capture it */
|
||||||
ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dj->lfn, dir)) ? ord - 1 : 0xFF;
|
ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dj->lfn, dir)) ? ord - 1 : 0xFF;
|
||||||
} else { /* An SFN entry is found */
|
} else { /* An SFN entry is found */
|
||||||
if (ord || sum != sum_sfn(dir)) /* Is there a valid LFN entry? */
|
if (ord || sum != sum_sfn(dir)) /* Is there a valid LFN? */
|
||||||
dj->lfn_idx = 0xFFFF; /* No LFN. */
|
dj->lfn_idx = 0xFFFF; /* It has no LFN. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -940,10 +960,10 @@ FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many
|
|||||||
fn = dj->fn; lfn = dj->lfn;
|
fn = dj->fn; lfn = dj->lfn;
|
||||||
mem_cpy(sn, fn, 12);
|
mem_cpy(sn, fn, 12);
|
||||||
|
|
||||||
if (_FS_RPATH && (sn[11] & NS_DOT)) return FR_INVALID_NAME; /* Cannot create dot entry */
|
if (_FS_RPATH && (sn[NS] & NS_DOT)) return FR_INVALID_NAME; /* Cannot create dot entry */
|
||||||
|
|
||||||
if (sn[11] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */
|
if (sn[NS] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */
|
||||||
fn[11] = 0; dj->lfn = NULL; /* Find only SFN */
|
fn[NS] = 0; dj->lfn = NULL; /* Find only SFN */
|
||||||
for (n = 1; n < 100; n++) {
|
for (n = 1; n < 100; n++) {
|
||||||
gen_numname(fn, sn, lfn, n); /* Generate a numbered name */
|
gen_numname(fn, sn, lfn, n); /* Generate a numbered name */
|
||||||
res = dir_find(dj); /* Check if the name collides with existing SFN */
|
res = dir_find(dj); /* Check if the name collides with existing SFN */
|
||||||
@ -951,10 +971,10 @@ FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many
|
|||||||
}
|
}
|
||||||
if (n == 100) return FR_DENIED; /* Abort if too many collisions */
|
if (n == 100) return FR_DENIED; /* Abort if too many collisions */
|
||||||
if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */
|
if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */
|
||||||
fn[11] = sn[11]; dj->lfn = lfn;
|
fn[NS] = sn[NS]; dj->lfn = lfn;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sn[11] & NS_LFN) { /* When LFN is to be created, reserve reserve an SFN + LFN entries. */
|
if (sn[NS] & NS_LFN) { /* When LFN is to be created, reserve reserve an SFN + LFN entries. */
|
||||||
for (ne = 0; lfn[ne]; ne++) ;
|
for (ne = 0; lfn[ne]; ne++) ;
|
||||||
ne = (ne + 25) / 13;
|
ne = (ne + 25) / 13;
|
||||||
} else { /* Otherwise reserve only an SFN entry. */
|
} else { /* Otherwise reserve only an SFN entry. */
|
||||||
@ -1012,7 +1032,7 @@ FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many
|
|||||||
dir = dj->dir;
|
dir = dj->dir;
|
||||||
mem_set(dir, 0, 32); /* Clean the entry */
|
mem_set(dir, 0, 32); /* Clean the entry */
|
||||||
mem_cpy(dir, dj->fn, 11); /* Put SFN */
|
mem_cpy(dir, dj->fn, 11); /* Put SFN */
|
||||||
dir[DIR_NTres] = *(dj->fn+11) & 0x18; /* Put NT flag */
|
dir[DIR_NTres] = *(dj->fn+NS) & (NS_BODY | NS_EXT); /* Put NT flag */
|
||||||
dj->fs->wflag = 1;
|
dj->fs->wflag = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1073,7 +1093,6 @@ FRESULT dir_remove ( /* FR_OK: Successful, FR_DISK_ERR: A disk error */
|
|||||||
/* Pick a segment and create the object name in directory form */
|
/* Pick a segment and create the object name in directory form */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
FRESULT create_name (
|
FRESULT create_name (
|
||||||
DIR *dj, /* Pointer to the directory object */
|
DIR *dj, /* Pointer to the directory object */
|
||||||
@ -1083,6 +1102,7 @@ FRESULT create_name (
|
|||||||
#ifdef _EXCVT
|
#ifdef _EXCVT
|
||||||
static const BYTE cvt[] = _EXCVT;
|
static const BYTE cvt[] = _EXCVT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if _USE_LFN /* LFN configuration */
|
#if _USE_LFN /* LFN configuration */
|
||||||
BYTE b, cf;
|
BYTE b, cf;
|
||||||
WCHAR w, *lfn;
|
WCHAR w, *lfn;
|
||||||
@ -1095,29 +1115,29 @@ FRESULT create_name (
|
|||||||
lfn = dj->lfn;
|
lfn = dj->lfn;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
w = p[si++]; /* Get a character */
|
w = p[si++]; /* Get a character */
|
||||||
if (w < L' ' || w == L'/' || w == L'\\') break; /* Break on end of segment */
|
if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */
|
||||||
if (di >= _MAX_LFN) /* Reject too long name */
|
if (di >= _MAX_LFN) /* Reject too long name */
|
||||||
return FR_INVALID_NAME;
|
return FR_INVALID_NAME;
|
||||||
#if !_LFN_UNICODE
|
#if !_LFN_UNICODE
|
||||||
w &= 0xFF;
|
w &= 0xFF;
|
||||||
if (IsDBCS1(w)) { /* If it is a DBC 1st byte */
|
if (IsDBCS1(w)) { /* If it is a DBC 1st byte */
|
||||||
BYTE c = p[si++]; /* Get 2nd byte */
|
b = p[si++]; /* Get 2nd byte */
|
||||||
if (!IsDBCS2(c)) /* Reject invalid code for DBC */
|
if (!IsDBCS2(b)) /* Reject invalid code for DBC */
|
||||||
return FR_INVALID_NAME;
|
return FR_INVALID_NAME;
|
||||||
w = (w << 8) + c;
|
w = (w << 8) + b;
|
||||||
}
|
}
|
||||||
w = ff_convert(w, 1); /* Convert OEM to Unicode */
|
w = ff_convert(w, 1); /* Convert OEM to Unicode */
|
||||||
if (!w) return FR_INVALID_NAME; /* Reject invalid code */
|
if (!w) return FR_INVALID_NAME; /* Reject invalid code */
|
||||||
#endif
|
#endif
|
||||||
if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject unallowable chars for LFN */
|
if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal chars for LFN */
|
||||||
return FR_INVALID_NAME;
|
return FR_INVALID_NAME;
|
||||||
lfn[di++] = w; /* Store the Unicode char */
|
lfn[di++] = w; /* Store the Unicode char */
|
||||||
}
|
}
|
||||||
*path = &p[si]; /* Rerurn pointer to the next segment */
|
*path = &p[si]; /* Rerurn pointer to the next segment */
|
||||||
cf = (w < L' ') ? NS_LAST : 0; /* Set last segment flag if end of path */
|
cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */
|
||||||
#if _FS_RPATH
|
#if _FS_RPATH
|
||||||
if ((di == 1 && lfn[di - 1] == L'.') || /* Is this a dot entry? */
|
if ((di == 1 && lfn[di - 1] == '.') || /* Is this a dot entry? */
|
||||||
(di == 2 && lfn[di - 1] == L'.' && lfn[di - 2] == L'.')) {
|
(di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) {
|
||||||
lfn[di] = 0;
|
lfn[di] = 0;
|
||||||
for (i = 0; i < 11; i++)
|
for (i = 0; i < 11; i++)
|
||||||
dj->fn[i] = (i < di) ? '.' : ' ';
|
dj->fn[i] = (i < di) ? '.' : ' ';
|
||||||
@ -1127,7 +1147,7 @@ FRESULT create_name (
|
|||||||
#endif
|
#endif
|
||||||
while (di) { /* Strip trailing spaces and dots */
|
while (di) { /* Strip trailing spaces and dots */
|
||||||
w = lfn[di - 1];
|
w = lfn[di - 1];
|
||||||
if (w != L' ' && w != L'.') break;
|
if (w != ' ' && w != '.') break;
|
||||||
di--;
|
di--;
|
||||||
}
|
}
|
||||||
if (!di) return FR_INVALID_NAME; /* Reject null string */
|
if (!di) return FR_INVALID_NAME; /* Reject null string */
|
||||||
@ -1136,15 +1156,15 @@ FRESULT create_name (
|
|||||||
|
|
||||||
/* Create SFN in directory form */
|
/* Create SFN in directory form */
|
||||||
mem_set(dj->fn, ' ', 11);
|
mem_set(dj->fn, ' ', 11);
|
||||||
for (si = 0; lfn[si] == L' ' || lfn[si] == L'.'; si++) ; /* Strip leading spaces and dots */
|
for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */
|
||||||
if (si) cf |= NS_LOSS | NS_LFN;
|
if (si) cf |= NS_LOSS | NS_LFN;
|
||||||
while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */
|
while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */
|
||||||
|
|
||||||
b = i = 0; ni = 8;
|
b = i = 0; ni = 8;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
w = lfn[si++]; /* Get an LFN char */
|
w = lfn[si++]; /* Get an LFN char */
|
||||||
if (!w) break; /* Break when enf of the LFN */
|
if (!w) break; /* Break on enf of the LFN */
|
||||||
if (w == L' ' || (w == L'.' && si != di)) { /* Remove spaces and dots */
|
if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */
|
||||||
cf |= NS_LOSS | NS_LFN; continue;
|
cf |= NS_LOSS | NS_LFN; continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1152,7 +1172,7 @@ FRESULT create_name (
|
|||||||
if (ni == 11) { /* Long extension */
|
if (ni == 11) { /* Long extension */
|
||||||
cf |= NS_LOSS | NS_LFN; break;
|
cf |= NS_LOSS | NS_LFN; break;
|
||||||
}
|
}
|
||||||
if (si != di) cf |= NS_LOSS | NS_LFN; /* File name is longer than 8 bytes */
|
if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */
|
||||||
if (si > di) break; /* No extension */
|
if (si > di) break; /* No extension */
|
||||||
si = di; i = 8; ni = 11; /* Enter extension section */
|
si = di; i = 8; ni = 11; /* Enter extension section */
|
||||||
b <<= 2; continue;
|
b <<= 2; continue;
|
||||||
@ -1161,11 +1181,11 @@ FRESULT create_name (
|
|||||||
if (w >= 0x80) { /* Non ASCII char */
|
if (w >= 0x80) { /* Non ASCII char */
|
||||||
#ifdef _EXCVT
|
#ifdef _EXCVT
|
||||||
w = ff_convert(w, 0); /* Unicode -> OEM code */
|
w = ff_convert(w, 0); /* Unicode -> OEM code */
|
||||||
if (w) w = cvt[w - 0x80]; /* Convert extend char (SBCS) */
|
if (w) w = cvt[w - 0x80]; /* Convert extended char to upper (SBCS) */
|
||||||
#else
|
#else
|
||||||
w = ff_convert(ff_wtoupper(w), 0); /* Unicode (Caps) -> OEM code */
|
w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */
|
||||||
#endif
|
#endif
|
||||||
cf |= NS_LFN; /* Force create an LFN */
|
cf |= NS_LFN; /* Force create LFN entry */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_DF1S && w >= 0x100) { /* Double byte char */
|
if (_DF1S && w >= 0x100) { /* Double byte char */
|
||||||
@ -1174,13 +1194,13 @@ FRESULT create_name (
|
|||||||
}
|
}
|
||||||
dj->fn[i++] = (BYTE)(w >> 8);
|
dj->fn[i++] = (BYTE)(w >> 8);
|
||||||
} else { /* Single byte char */
|
} else { /* Single byte char */
|
||||||
if (!w || chk_chr("+,;[=]", w)) { /* Replace unallowable chars for SFN */
|
if (!w || chk_chr("+,;[=]", w)) { /* Replace illegal chars for SFN */
|
||||||
w = '_'; cf |= NS_LOSS | NS_LFN; /* Lossy conversion */
|
w = '_'; cf |= NS_LOSS | NS_LFN; /* Lossy conversion */
|
||||||
} else {
|
} else {
|
||||||
if (IsUpper(w)) { /* Large capital */
|
if (IsUpper(w)) { /* ASCII large capital */
|
||||||
b |= 2;
|
b |= 2;
|
||||||
} else {
|
} else {
|
||||||
if (IsLower(w)) { /* Small capital */
|
if (IsLower(w)) { /* ASCII small capital */
|
||||||
b |= 1; w -= 0x20;
|
b |= 1; w -= 0x20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1189,7 +1209,7 @@ FRESULT create_name (
|
|||||||
dj->fn[i++] = (BYTE)w;
|
dj->fn[i++] = (BYTE)w;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dj->fn[0] == 0xE5) dj->fn[0] = 0x05; /* If the first char collides with 0xE5, replace it with 0x05 */
|
if (dj->fn[0] == 0xE5) dj->fn[0] = 0x05; /* If the first char collides with deleted mark, replace it with 0x05 */
|
||||||
|
|
||||||
if (ni == 8) b <<= 2;
|
if (ni == 8) b <<= 2;
|
||||||
if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */
|
if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */
|
||||||
@ -1199,7 +1219,9 @@ FRESULT create_name (
|
|||||||
if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */
|
if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */
|
||||||
}
|
}
|
||||||
|
|
||||||
dj->fn[11] = cf; /* SFN is created */
|
dj->fn[NS] = cf; /* SFN is created */
|
||||||
|
|
||||||
|
return FR_OK;
|
||||||
|
|
||||||
|
|
||||||
#else /* Non-LFN configuration */
|
#else /* Non-LFN configuration */
|
||||||
@ -1219,15 +1241,15 @@ FRESULT create_name (
|
|||||||
if (c != '.' || si >= 3) break;
|
if (c != '.' || si >= 3) break;
|
||||||
sfn[i++] = c;
|
sfn[i++] = c;
|
||||||
}
|
}
|
||||||
if (c != '/' && c != '\\' && c >= ' ') return FR_INVALID_NAME;
|
if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME;
|
||||||
*path = &p[si]; /* Rerurn pointer to the next segment */
|
*path = &p[si]; /* Rerurn pointer to the next segment */
|
||||||
sfn[11] = (c < ' ') ? NS_LAST|NS_DOT : NS_DOT; /* Set last segment flag if end of path */
|
sfn[NS] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of path */
|
||||||
return FR_OK;
|
return FR_OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = p[si++];
|
c = p[si++];
|
||||||
if (c < ' ' || c == '/' || c == '\\') break; /* Break on end of segment */
|
if (c <= ' ' || c == '/' || c == '\\') break; /* Break on end of segment */
|
||||||
if (c == '.' || i >= ni) {
|
if (c == '.' || i >= ni) {
|
||||||
if (ni != 8 || c != '.') return FR_INVALID_NAME;
|
if (ni != 8 || c != '.') return FR_INVALID_NAME;
|
||||||
i = 8; ni = 11;
|
i = 8; ni = 11;
|
||||||
@ -1243,19 +1265,19 @@ FRESULT create_name (
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (IsDBCS1(c)) { /* If it is DBC 1st byte */
|
if (IsDBCS1(c)) { /* DBC 1st byte? */
|
||||||
d = p[si++]; /* Get 2nd byte */
|
d = p[si++]; /* Get 2nd byte */
|
||||||
if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */
|
if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */
|
||||||
return FR_INVALID_NAME;
|
return FR_INVALID_NAME;
|
||||||
sfn[i++] = c;
|
sfn[i++] = c;
|
||||||
sfn[i++] = d;
|
sfn[i++] = d;
|
||||||
} else {
|
} else { /* Single byte code */
|
||||||
if (chk_chr(" \"*+,[=]|\x7F", c)) /* Reject unallowable chrs for SFN */
|
if (chk_chr(" \"*+,[=]|\x7F", c)) /* Reject illegal chrs for SFN */
|
||||||
return FR_INVALID_NAME;
|
return FR_INVALID_NAME;
|
||||||
if (IsUpper(c)) {
|
if (IsUpper(c)) { /* ASCII large capital? */
|
||||||
b |= 2;
|
b |= 2;
|
||||||
} else {
|
} else {
|
||||||
if (IsLower(c)) {
|
if (IsLower(c)) { /* ASCII small capital? */
|
||||||
b |= 1; c -= 0x20;
|
b |= 1; c -= 0x20;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1263,7 +1285,7 @@ FRESULT create_name (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*path = &p[si]; /* Rerurn pointer to the next segment */
|
*path = &p[si]; /* Rerurn pointer to the next segment */
|
||||||
c = (c < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */
|
c = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */
|
||||||
|
|
||||||
if (!i) return FR_INVALID_NAME; /* Reject null string */
|
if (!i) return FR_INVALID_NAME; /* Reject null string */
|
||||||
if (sfn[0] == 0xE5) sfn[0] = 0x05; /* When first char collides with 0xE5, replace it with 0x05 */
|
if (sfn[0] == 0xE5) sfn[0] = 0x05; /* When first char collides with 0xE5, replace it with 0x05 */
|
||||||
@ -1272,10 +1294,10 @@ FRESULT create_name (
|
|||||||
if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Extension has only small capital) */
|
if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Extension has only small capital) */
|
||||||
if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Filename has only small capital) */
|
if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Filename has only small capital) */
|
||||||
|
|
||||||
sfn[11] = c; /* Store NT flag, File name is created */
|
sfn[NS] = c; /* Store NT flag, File name is created */
|
||||||
#endif
|
|
||||||
|
|
||||||
return FR_OK;
|
return FR_OK;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1288,15 +1310,12 @@ FRESULT create_name (
|
|||||||
static
|
static
|
||||||
void get_fileinfo ( /* No return code */
|
void get_fileinfo ( /* No return code */
|
||||||
DIR *dj, /* Pointer to the directory object */
|
DIR *dj, /* Pointer to the directory object */
|
||||||
FILINFO *fno /* Pointer to store the file information */
|
FILINFO *fno /* Pointer to the file information to be filled */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
BYTE c, nt, *dir;
|
BYTE c, nt, *dir;
|
||||||
char *p;
|
char *p;
|
||||||
#if _USE_LFN
|
|
||||||
XCHAR *tp;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
p = fno->fname;
|
p = fno->fname;
|
||||||
@ -1307,7 +1326,7 @@ void get_fileinfo ( /* No return code */
|
|||||||
c = dir[i];
|
c = dir[i];
|
||||||
if (c == ' ') break;
|
if (c == ' ') break;
|
||||||
if (c == 0x05) c = 0xE5;
|
if (c == 0x05) c = 0xE5;
|
||||||
if ((nt & 0x08) && IsUpper(c)) c += 0x20;
|
if (_USE_LFN && (nt & NS_BODY) && IsUpper(c)) c += 0x20;
|
||||||
*p++ = c;
|
*p++ = c;
|
||||||
}
|
}
|
||||||
if (dir[8] != ' ') { /* Copy name extension */
|
if (dir[8] != ' ') { /* Copy name extension */
|
||||||
@ -1315,7 +1334,7 @@ void get_fileinfo ( /* No return code */
|
|||||||
for (i = 8; i < 11; i++) {
|
for (i = 8; i < 11; i++) {
|
||||||
c = dir[i];
|
c = dir[i];
|
||||||
if (c == ' ') break;
|
if (c == ' ') break;
|
||||||
if ((nt & 0x10) && IsUpper(c)) c += 0x20;
|
if (_USE_LFN && (nt & NS_EXT) && IsUpper(c)) c += 0x20;
|
||||||
*p++ = c;
|
*p++ = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1327,8 +1346,8 @@ void get_fileinfo ( /* No return code */
|
|||||||
*p = 0;
|
*p = 0;
|
||||||
|
|
||||||
#if _USE_LFN
|
#if _USE_LFN
|
||||||
tp = fno->lfname;
|
if (fno->lfname) {
|
||||||
if (tp) {
|
XCHAR *tp = fno->lfname;
|
||||||
WCHAR w, *lfn;
|
WCHAR w, *lfn;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -1340,8 +1359,8 @@ void get_fileinfo ( /* No return code */
|
|||||||
if (!w) { i = 0; break; } /* Could not convert, no LFN */
|
if (!w) { i = 0; break; } /* Could not convert, no LFN */
|
||||||
if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC */
|
if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC */
|
||||||
tp[i++] = (XCHAR)(w >> 8);
|
tp[i++] = (XCHAR)(w >> 8);
|
||||||
if (i >= fno->lfsize - 1) { i = 0; break; } /* Buffer overrun, no LFN */
|
|
||||||
#endif
|
#endif
|
||||||
|
if (i >= fno->lfsize - 1) { i = 0; break; } /* Buffer overrun, no LFN */
|
||||||
tp[i++] = (XCHAR)w;
|
tp[i++] = (XCHAR)w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1368,6 +1387,7 @@ FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */
|
|||||||
BYTE *dir, last;
|
BYTE *dir, last;
|
||||||
|
|
||||||
|
|
||||||
|
while (!_USE_LFN && *path == ' ') path++; /* Skip leading spaces */
|
||||||
#if _FS_RPATH
|
#if _FS_RPATH
|
||||||
if (*path == '/' || *path == '\\') { /* There is a heading separator */
|
if (*path == '/' || *path == '\\') { /* There is a heading separator */
|
||||||
path++; dj->sclust = 0; /* Strip it and start from the root dir */
|
path++; dj->sclust = 0; /* Strip it and start from the root dir */
|
||||||
@ -1389,7 +1409,7 @@ FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */
|
|||||||
res = create_name(dj, &path); /* Get a segment */
|
res = create_name(dj, &path); /* Get a segment */
|
||||||
if (res != FR_OK) break;
|
if (res != FR_OK) break;
|
||||||
res = dir_find(dj); /* Find it */
|
res = dir_find(dj); /* Find it */
|
||||||
last = *(dj->fn+11) & NS_LAST;
|
last = *(dj->fn+NS) & NS_LAST;
|
||||||
if (res != FR_OK) { /* Could not find the object */
|
if (res != FR_OK) { /* Could not find the object */
|
||||||
if (res == FR_NO_FILE && !last)
|
if (res == FR_NO_FILE && !last)
|
||||||
res = FR_NO_PATH;
|
res = FR_NO_PATH;
|
||||||
@ -1420,17 +1440,14 @@ BYTE check_fs ( /* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2:
|
|||||||
DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */
|
DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
static const char fatstr[] = "FAT";
|
|
||||||
|
|
||||||
|
|
||||||
if (disk_read(fs->drive, fs->win, sect, 1) != RES_OK) /* Load boot record */
|
if (disk_read(fs->drive, fs->win, sect, 1) != RES_OK) /* Load boot record */
|
||||||
return 3;
|
return 3;
|
||||||
if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check record signature (always placed at offset 510 even if the sector size is >512) */
|
if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check record signature (always placed at offset 510 even if the sector size is >512) */
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
if (!mem_cmp(&fs->win[BS_FilSysType], fatstr, 3)) /* Check FAT signature */
|
if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */
|
||||||
return 0;
|
return 0;
|
||||||
if (!mem_cmp(&fs->win[BS_FilSysType32], fatstr, 3) && !(fs->win[BPB_ExtFlags] & 0x80))
|
if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -1443,14 +1460,13 @@ BYTE check_fs ( /* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2:
|
|||||||
/* Make sure that the file system is valid */
|
/* Make sure that the file system is valid */
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
|
||||||
static
|
|
||||||
FRESULT auto_mount ( /* FR_OK(0): successful, !=0: any error occured */
|
FRESULT chk_mounted ( /* FR_OK(0): successful, !=0: any error occured */
|
||||||
const XCHAR **path, /* Pointer to pointer to the path name (drive number) */
|
const XCHAR **path, /* Pointer to pointer to the path name (drive number) */
|
||||||
FATFS **rfs, /* Pointer to pointer to the found file system object */
|
FATFS **rfs, /* Pointer to pointer to the found file system object */
|
||||||
BYTE chk_wp /* !=0: Check media write protection for write access */
|
BYTE chk_wp /* !=0: Check media write protection for write access */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
FRESULT res;
|
|
||||||
BYTE fmt, *tbl;
|
BYTE fmt, *tbl;
|
||||||
UINT vol;
|
UINT vol;
|
||||||
DSTATUS stat;
|
DSTATUS stat;
|
||||||
@ -1458,7 +1474,6 @@ FRESULT auto_mount ( /* FR_OK(0): successful, !=0: any error occured */
|
|||||||
const XCHAR *p = *path;
|
const XCHAR *p = *path;
|
||||||
FATFS *fs;
|
FATFS *fs;
|
||||||
|
|
||||||
|
|
||||||
/* Get logical drive number from the path name */
|
/* Get logical drive number from the path name */
|
||||||
vol = p[0] - '0'; /* Is there a drive number? */
|
vol = p[0] - '0'; /* Is there a drive number? */
|
||||||
if (vol <= 9 && p[1] == ':') { /* Found a drive number, get and strip it */
|
if (vol <= 9 && p[1] == ':') { /* Found a drive number, get and strip it */
|
||||||
@ -1475,7 +1490,7 @@ FRESULT auto_mount ( /* FR_OK(0): successful, !=0: any error occured */
|
|||||||
if (vol >= _DRIVES) /* Is the drive number valid? */
|
if (vol >= _DRIVES) /* Is the drive number valid? */
|
||||||
return FR_INVALID_DRIVE;
|
return FR_INVALID_DRIVE;
|
||||||
*rfs = fs = FatFs[vol]; /* Returen pointer to the corresponding file system object */
|
*rfs = fs = FatFs[vol]; /* Returen pointer to the corresponding file system object */
|
||||||
if (!fs) return FR_NOT_ENABLED; /* Is the file system object registered? */
|
if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */
|
||||||
|
|
||||||
ENTER_FF(fs); /* Lock file system */
|
ENTER_FF(fs); /* Lock file system */
|
||||||
|
|
||||||
@ -1528,9 +1543,9 @@ FRESULT auto_mount ( /* FR_OK(0): successful, !=0: any error occured */
|
|||||||
fs->fatbase = bsect + LD_WORD(fs->win+BPB_RsvdSecCnt); /* FAT start sector (lba) */
|
fs->fatbase = bsect + LD_WORD(fs->win+BPB_RsvdSecCnt); /* FAT start sector (lba) */
|
||||||
fs->csize = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */
|
fs->csize = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */
|
||||||
fs->n_rootdir = LD_WORD(fs->win+BPB_RootEntCnt); /* Nmuber of root directory entries */
|
fs->n_rootdir = LD_WORD(fs->win+BPB_RootEntCnt); /* Nmuber of root directory entries */
|
||||||
tsect = LD_WORD(fs->win+BPB_TotSec16); /* Number of sectors on the file system */
|
tsect = LD_WORD(fs->win+BPB_TotSec16); /* Number of sectors on the volume */
|
||||||
if (!tsect) tsect = LD_DWORD(fs->win+BPB_TotSec32);
|
if (!tsect) tsect = LD_DWORD(fs->win+BPB_TotSec32);
|
||||||
fs->max_clust = mclst = (tsect /* Last cluster# + 1 */
|
fs->max_clust = mclst = (tsect /* Last cluster# + 1 (Number of clusters + 2) */
|
||||||
- LD_WORD(fs->win+BPB_RsvdSecCnt) - fsize - fs->n_rootdir / (SS(fs)/32)
|
- LD_WORD(fs->win+BPB_RsvdSecCnt) - fsize - fs->n_rootdir / (SS(fs)/32)
|
||||||
) / fs->csize + 2;
|
) / fs->csize + 2;
|
||||||
|
|
||||||
@ -1567,9 +1582,8 @@ FRESULT auto_mount ( /* FR_OK(0): successful, !=0: any error occured */
|
|||||||
fs->cdir = 0; /* Current directory (root dir) */
|
fs->cdir = 0; /* Current directory (root dir) */
|
||||||
#endif
|
#endif
|
||||||
fs->id = ++Fsid; /* File system mount ID */
|
fs->id = ++Fsid; /* File system mount ID */
|
||||||
res = FR_OK;
|
|
||||||
|
|
||||||
return res;
|
return FR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1663,10 +1677,10 @@ FRESULT f_open (
|
|||||||
fp->fs = NULL; /* Clear file object */
|
fp->fs = NULL; /* Clear file object */
|
||||||
#if !_FS_READONLY
|
#if !_FS_READONLY
|
||||||
mode &= (FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW);
|
mode &= (FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW);
|
||||||
res = auto_mount(&path, &dj.fs, (BYTE)(mode & (FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)));
|
res = chk_mounted(&path, &dj.fs, (BYTE)(mode & (FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)));
|
||||||
#else
|
#else
|
||||||
mode &= FA_READ;
|
mode &= FA_READ;
|
||||||
res = auto_mount(&path, &dj.fs, 0);
|
res = chk_mounted(&path, &dj.fs, 0);
|
||||||
#endif
|
#endif
|
||||||
if (res != FR_OK) LEAVE_FF(dj.fs, res);
|
if (res != FR_OK) LEAVE_FF(dj.fs, res);
|
||||||
INITBUF(dj, sfn, lfn);
|
INITBUF(dj, sfn, lfn);
|
||||||
@ -1759,7 +1773,7 @@ FRESULT f_read (
|
|||||||
BYTE *rbuff = buff;
|
BYTE *rbuff = buff;
|
||||||
|
|
||||||
|
|
||||||
*br = 0;
|
*br = 0; /* Initialize bytes read */
|
||||||
|
|
||||||
res = validate(fp->fs, fp->id); /* Check validity of the object */
|
res = validate(fp->fs, fp->id); /* Check validity of the object */
|
||||||
if (res != FR_OK) LEAVE_FF(fp->fs, res);
|
if (res != FR_OK) LEAVE_FF(fp->fs, res);
|
||||||
@ -1854,7 +1868,7 @@ FRESULT f_write (
|
|||||||
const BYTE *wbuff = buff;
|
const BYTE *wbuff = buff;
|
||||||
|
|
||||||
|
|
||||||
*bw = 0;
|
*bw = 0; /* Initialize bytes written */
|
||||||
|
|
||||||
res = validate(fp->fs, fp->id); /* Check validity of the object */
|
res = validate(fp->fs, fp->id); /* Check validity of the object */
|
||||||
if (res != FR_OK) LEAVE_FF(fp->fs, res);
|
if (res != FR_OK) LEAVE_FF(fp->fs, res);
|
||||||
@ -2055,7 +2069,7 @@ FRESULT f_chdir (
|
|||||||
BYTE *dir;
|
BYTE *dir;
|
||||||
|
|
||||||
|
|
||||||
res = auto_mount(&path, &dj.fs, 0);
|
res = chk_mounted(&path, &dj.fs, 0);
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
INITBUF(dj, sfn, lfn);
|
INITBUF(dj, sfn, lfn);
|
||||||
res = follow_path(&dj, path); /* Follow the file path */
|
res = follow_path(&dj, path); /* Follow the file path */
|
||||||
@ -2194,7 +2208,7 @@ FRESULT f_opendir (
|
|||||||
BYTE *dir;
|
BYTE *dir;
|
||||||
|
|
||||||
|
|
||||||
res = auto_mount(&path, &dj->fs, 0);
|
res = chk_mounted(&path, &dj->fs, 0);
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
INITBUF((*dj), sfn, lfn);
|
INITBUF((*dj), sfn, lfn);
|
||||||
res = follow_path(dj, path); /* Follow the path to the directory */
|
res = follow_path(dj, path); /* Follow the path to the directory */
|
||||||
@ -2276,7 +2290,7 @@ FRESULT f_stat (
|
|||||||
NAMEBUF(sfn, lfn);
|
NAMEBUF(sfn, lfn);
|
||||||
|
|
||||||
|
|
||||||
res = auto_mount(&path, &dj.fs, 0);
|
res = chk_mounted(&path, &dj.fs, 0);
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
INITBUF(dj, sfn, lfn);
|
INITBUF(dj, sfn, lfn);
|
||||||
res = follow_path(&dj, path); /* Follow the file path */
|
res = follow_path(&dj, path); /* Follow the file path */
|
||||||
@ -2311,7 +2325,7 @@ FRESULT f_getfree (
|
|||||||
|
|
||||||
|
|
||||||
/* Get drive number */
|
/* Get drive number */
|
||||||
res = auto_mount(&path, fatfs, 0);
|
res = chk_mounted(&path, fatfs, 0);
|
||||||
if (res != FR_OK) LEAVE_FF(*fatfs, res);
|
if (res != FR_OK) LEAVE_FF(*fatfs, res);
|
||||||
|
|
||||||
/* If number of free cluster is valid, return it without cluster scan. */
|
/* If number of free cluster is valid, return it without cluster scan. */
|
||||||
@ -2347,7 +2361,7 @@ FRESULT f_getfree (
|
|||||||
if (LD_WORD(p) == 0) n++;
|
if (LD_WORD(p) == 0) n++;
|
||||||
p += 2; i -= 2;
|
p += 2; i -= 2;
|
||||||
} else {
|
} else {
|
||||||
if (LD_DWORD(p) == 0) n++;
|
if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++;
|
||||||
p += 4; i -= 4;
|
p += 4; i -= 4;
|
||||||
}
|
}
|
||||||
} while (--clst);
|
} while (--clst);
|
||||||
@ -2421,12 +2435,12 @@ FRESULT f_unlink (
|
|||||||
DWORD dclst;
|
DWORD dclst;
|
||||||
|
|
||||||
|
|
||||||
res = auto_mount(&path, &dj.fs, 1);
|
res = chk_mounted(&path, &dj.fs, 1);
|
||||||
if (res != FR_OK) LEAVE_FF(dj.fs, res);
|
if (res != FR_OK) LEAVE_FF(dj.fs, res);
|
||||||
|
|
||||||
INITBUF(dj, sfn, lfn);
|
INITBUF(dj, sfn, lfn);
|
||||||
res = follow_path(&dj, path); /* Follow the file path */
|
res = follow_path(&dj, path); /* Follow the file path */
|
||||||
if (_FS_RPATH && res == FR_OK && (dj.fn[11] & NS_DOT))
|
if (_FS_RPATH && res == FR_OK && (dj.fn[NS] & NS_DOT))
|
||||||
res = FR_INVALID_NAME;
|
res = FR_INVALID_NAME;
|
||||||
if (res != FR_OK) LEAVE_FF(dj.fs, res); /* Follow failed */
|
if (res != FR_OK) LEAVE_FF(dj.fs, res); /* Follow failed */
|
||||||
|
|
||||||
@ -2441,7 +2455,7 @@ FRESULT f_unlink (
|
|||||||
if (dclst < 2) LEAVE_FF(dj.fs, FR_INT_ERR);
|
if (dclst < 2) LEAVE_FF(dj.fs, FR_INT_ERR);
|
||||||
mem_cpy(&sdj, &dj, sizeof(DIR)); /* Check if the sub-dir is empty or not */
|
mem_cpy(&sdj, &dj, sizeof(DIR)); /* Check if the sub-dir is empty or not */
|
||||||
sdj.sclust = dclst;
|
sdj.sclust = dclst;
|
||||||
res = dir_seek(&sdj, 0);
|
res = dir_seek(&sdj, 2);
|
||||||
if (res != FR_OK) LEAVE_FF(dj.fs, res);
|
if (res != FR_OK) LEAVE_FF(dj.fs, res);
|
||||||
res = dir_read(&sdj);
|
res = dir_read(&sdj);
|
||||||
if (res == FR_OK) res = FR_DENIED; /* Not empty sub-dir */
|
if (res == FR_OK) res = FR_DENIED; /* Not empty sub-dir */
|
||||||
@ -2476,13 +2490,13 @@ FRESULT f_mkdir (
|
|||||||
DWORD dsect, dclst, pclst, tim;
|
DWORD dsect, dclst, pclst, tim;
|
||||||
|
|
||||||
|
|
||||||
res = auto_mount(&path, &dj.fs, 1);
|
res = chk_mounted(&path, &dj.fs, 1);
|
||||||
if (res != FR_OK) LEAVE_FF(dj.fs, res);
|
if (res != FR_OK) LEAVE_FF(dj.fs, res);
|
||||||
|
|
||||||
INITBUF(dj, sfn, lfn);
|
INITBUF(dj, sfn, lfn);
|
||||||
res = follow_path(&dj, path); /* Follow the file path */
|
res = follow_path(&dj, path); /* Follow the file path */
|
||||||
if (res == FR_OK) res = FR_EXIST; /* Any file or directory is already existing */
|
if (res == FR_OK) res = FR_EXIST; /* Any file or directory is already existing */
|
||||||
if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[11] & NS_DOT))
|
if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NS] & NS_DOT))
|
||||||
res = FR_INVALID_NAME;
|
res = FR_INVALID_NAME;
|
||||||
if (res != FR_NO_FILE) /* Any error occured */
|
if (res != FR_NO_FILE) /* Any error occured */
|
||||||
LEAVE_FF(dj.fs, res);
|
LEAVE_FF(dj.fs, res);
|
||||||
@ -2556,11 +2570,11 @@ FRESULT f_chmod (
|
|||||||
BYTE *dir;
|
BYTE *dir;
|
||||||
|
|
||||||
|
|
||||||
res = auto_mount(&path, &dj.fs, 1);
|
res = chk_mounted(&path, &dj.fs, 1);
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
INITBUF(dj, sfn, lfn);
|
INITBUF(dj, sfn, lfn);
|
||||||
res = follow_path(&dj, path); /* Follow the file path */
|
res = follow_path(&dj, path); /* Follow the file path */
|
||||||
if (_FS_RPATH && res == FR_OK && (dj.fn[11] & NS_DOT))
|
if (_FS_RPATH && res == FR_OK && (dj.fn[NS] & NS_DOT))
|
||||||
res = FR_INVALID_NAME;
|
res = FR_INVALID_NAME;
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
dir = dj.dir;
|
dir = dj.dir;
|
||||||
@ -2596,11 +2610,11 @@ FRESULT f_utime (
|
|||||||
BYTE *dir;
|
BYTE *dir;
|
||||||
|
|
||||||
|
|
||||||
res = auto_mount(&path, &dj.fs, 1);
|
res = chk_mounted(&path, &dj.fs, 1);
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
INITBUF(dj, sfn, lfn);
|
INITBUF(dj, sfn, lfn);
|
||||||
res = follow_path(&dj, path); /* Follow the file path */
|
res = follow_path(&dj, path); /* Follow the file path */
|
||||||
if (_FS_RPATH && res == FR_OK && (dj.fn[11] & NS_DOT))
|
if (_FS_RPATH && res == FR_OK && (dj.fn[NS] & NS_DOT))
|
||||||
res = FR_INVALID_NAME;
|
res = FR_INVALID_NAME;
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
dir = dj.dir;
|
dir = dj.dir;
|
||||||
@ -2638,11 +2652,11 @@ FRESULT f_rename (
|
|||||||
|
|
||||||
|
|
||||||
INITBUF(dj_old, sfn, lfn);
|
INITBUF(dj_old, sfn, lfn);
|
||||||
res = auto_mount(&path_old, &dj_old.fs, 1);
|
res = chk_mounted(&path_old, &dj_old.fs, 1);
|
||||||
if (res == FR_OK) {
|
if (res == FR_OK) {
|
||||||
dj_new.fs = dj_old.fs;
|
dj_new.fs = dj_old.fs;
|
||||||
res = follow_path(&dj_old, path_old); /* Check old object */
|
res = follow_path(&dj_old, path_old); /* Check old object */
|
||||||
if (_FS_RPATH && res == FR_OK && (dj_old.fn[11] & NS_DOT))
|
if (_FS_RPATH && res == FR_OK && (dj_old.fn[NS] & NS_DOT))
|
||||||
res = FR_INVALID_NAME;
|
res = FR_INVALID_NAME;
|
||||||
}
|
}
|
||||||
if (res != FR_OK) LEAVE_FF(dj_old.fs, res); /* The old object is not found */
|
if (res != FR_OK) LEAVE_FF(dj_old.fs, res); /* The old object is not found */
|
||||||
|
|||||||
160
src/ff.h
160
src/ff.h
@ -1,9 +1,9 @@
|
|||||||
/*---------------------------------------------------------------------------/
|
/*---------------------------------------------------------------------------/
|
||||||
/ FatFs - FAT file system module include file R0.07c (C)ChaN, 2009
|
/ FatFs - FAT file system module include file R0.07e (C)ChaN, 2009
|
||||||
/----------------------------------------------------------------------------/
|
/----------------------------------------------------------------------------/
|
||||||
/ FatFs module is an open source software to implement FAT file system to
|
/ FatFs module is a generic FAT file system module for small embedded systems.
|
||||||
/ small embedded systems. This is a free software and is opened for education,
|
/ This is a free software that opened for education, research and commercial
|
||||||
/ research and commercial developments under license policy of following trems.
|
/ developments under license policy of following trems.
|
||||||
/
|
/
|
||||||
/ Copyright (C) 2009, ChaN, all right reserved.
|
/ Copyright (C) 2009, ChaN, all right reserved.
|
||||||
/
|
/
|
||||||
@ -13,144 +13,15 @@
|
|||||||
/ * Redistributions of source code must retain the above copyright notice.
|
/ * Redistributions of source code must retain the above copyright notice.
|
||||||
/----------------------------------------------------------------------------*/
|
/----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "integer.h"
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------/
|
|
||||||
/ FatFs Configuration Options
|
|
||||||
/
|
|
||||||
/ CAUTION! Do not forget to make clean the project after any changes to
|
|
||||||
/ the configuration options.
|
|
||||||
/
|
|
||||||
/----------------------------------------------------------------------------*/
|
|
||||||
#ifndef _FATFS
|
#ifndef _FATFS
|
||||||
#define _FATFS 0x007C
|
#define _FATFS 0x007E
|
||||||
|
|
||||||
#define _WORD_ACCESS 0
|
#include "integer.h" /* Basic integer types */
|
||||||
/* The _WORD_ACCESS option defines which access method is used to the word
|
#include "ffconf.h" /* FatFs configuration options */
|
||||||
/ data in the FAT structure.
|
|
||||||
/
|
|
||||||
/ 0: Byte-by-byte access. Always compatible with all platforms.
|
|
||||||
/ 1: Word access. Do not choose this unless following condition is met.
|
|
||||||
/
|
|
||||||
/ When the byte order on the memory is big-endian or address miss-aligned
|
|
||||||
/ word access results incorrect behavior, the _WORD_ACCESS must be set to 0.
|
|
||||||
/ If it is not the case, the value can also be set to 1 to improve the
|
|
||||||
/ performance and code efficiency. */
|
|
||||||
|
|
||||||
|
|
||||||
#define _FS_READONLY 0
|
|
||||||
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
|
|
||||||
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
|
|
||||||
/ f_truncate and useless f_getfree. */
|
|
||||||
|
|
||||||
|
|
||||||
#define _FS_MINIMIZE 0
|
|
||||||
/* The _FS_MINIMIZE option defines minimization level to remove some functions.
|
|
||||||
/
|
|
||||||
/ 0: Full function.
|
|
||||||
/ 1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_truncate and f_rename
|
|
||||||
/ are removed.
|
|
||||||
/ 2: f_opendir and f_readdir are removed in addition to level 1.
|
|
||||||
/ 3: f_lseek is removed in addition to level 2. */
|
|
||||||
|
|
||||||
|
|
||||||
#define _FS_TINY 0
|
|
||||||
/* When _FS_TINY is set to 1, FatFs uses the sector buffer in the file system
|
|
||||||
/ object instead of the sector buffer in the individual file object for file
|
|
||||||
/ data transfer. This reduces memory consumption 512 bytes each file object. */
|
|
||||||
|
|
||||||
|
|
||||||
#define _USE_STRFUNC 0
|
|
||||||
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
|
|
||||||
|
|
||||||
|
|
||||||
#define _USE_MKFS 0
|
|
||||||
/* To enable f_mkfs function, set _USE_MKFS to 1 and set _FS_READONLY to 0 */
|
|
||||||
|
|
||||||
|
|
||||||
#define _USE_FORWARD 0
|
|
||||||
/* To enable f_forward function, set _USE_FORWARD to 1 and set _FS_TINY to 1. */
|
|
||||||
|
|
||||||
|
|
||||||
#define _CODE_PAGE 932
|
|
||||||
/* The _CODE_PAGE specifies the OEM code page to be used on the target system.
|
|
||||||
/
|
|
||||||
/ 932 - Japanese Shift-JIS (DBCS, OEM, Windows)
|
|
||||||
/ 936 - Simplified Chinese GBK (DBCS, OEM, Windows)
|
|
||||||
/ 949 - Korean (DBCS, OEM, Windows)
|
|
||||||
/ 950 - Traditional Chinese Big5 (DBCS, OEM, Windows)
|
|
||||||
/ 1250 - Central Europe (Windows)
|
|
||||||
/ 1251 - Cyrillic (Windows)
|
|
||||||
/ 1252 - Latin 1 (Windows)
|
|
||||||
/ 1253 - Greek (Windows)
|
|
||||||
/ 1254 - Turkish (Windows)
|
|
||||||
/ 1255 - Hebrew (Windows)
|
|
||||||
/ 1256 - Arabic (Windows)
|
|
||||||
/ 1257 - Baltic (Windows)
|
|
||||||
/ 1258 - Vietnam (OEM, Windows)
|
|
||||||
/ 437 - U.S. (OEM)
|
|
||||||
/ 720 - Arabic (OEM)
|
|
||||||
/ 737 - Greek (OEM)
|
|
||||||
/ 775 - Baltic (OEM)
|
|
||||||
/ 850 - Multilingual Latin 1 (OEM)
|
|
||||||
/ 858 - Multilingual Latin 1 + Euro (OEM)
|
|
||||||
/ 852 - Latin 2 (OEM)
|
|
||||||
/ 855 - Cyrillic (OEM)
|
|
||||||
/ 866 - Russian (OEM)
|
|
||||||
/ 857 - Turkish (OEM)
|
|
||||||
/ 862 - Hebrew (OEM)
|
|
||||||
/ 874 - Thai (OEM, Windows)
|
|
||||||
/ 1 - ASCII (Valid for only non LFN cfg.)
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#define _USE_LFN 0
|
|
||||||
#define _MAX_LFN 255 /* Maximum LFN length to handle (max:255) */
|
|
||||||
/* The _USE_LFN option switches the LFN support.
|
|
||||||
/
|
|
||||||
/ 0: Disable LFN.
|
|
||||||
/ 1: Enable LFN with static working buffer on the bss. NOT REENTRANT.
|
|
||||||
/ 2: Enable LFN with dynamic working buffer on the caller's STACK.
|
|
||||||
/
|
|
||||||
/ The working buffer occupies (_MAX_LFN + 1) * 2 bytes. When enable LFN,
|
|
||||||
/ a Unicode handling functions ff_convert() and ff_wtoupper() must be added
|
|
||||||
/ to the project. */
|
|
||||||
|
|
||||||
|
|
||||||
#define _FS_RPATH 0
|
|
||||||
/* When _FS_RPATH is set to 1, relative path feature is enabled and f_chdir,
|
|
||||||
/ f_chdrive function are available.
|
|
||||||
/ Note that output of the f_readdir fnction is affected by this option. */
|
|
||||||
|
|
||||||
|
|
||||||
#define _FS_REENTRANT 0
|
|
||||||
#define _TIMEOUT 1000 /* Timeout period in unit of time ticks of the OS */
|
|
||||||
#define _SYNC_t HANDLE /* Type of sync object used on the OS. e.g. HANDLE, OS_EVENT*, ID and etc.. */
|
|
||||||
/* To make the FatFs module re-entrant, set _FS_REENTRANT to 1 and add user
|
|
||||||
/ provided synchronization handlers, ff_req_grant, ff_rel_grant, ff_del_syncobj
|
|
||||||
/ and ff_cre_syncobj function to the project. */
|
|
||||||
|
|
||||||
|
|
||||||
#define _DRIVES 1
|
|
||||||
/* Number of volumes (logical drives) to be used. */
|
|
||||||
|
|
||||||
|
|
||||||
#define _MAX_SS 512
|
|
||||||
/* Maximum sector size to be handled. (512/1024/2048/4096) */
|
|
||||||
/* Usually set 512 for memory card and hard disk but 1024 for floppy disk, 2048 for MO disk */
|
|
||||||
/* When _MAX_SS > 512, GET_SECTOR_SIZE must be implememted to disk_ioctl() */
|
|
||||||
|
|
||||||
|
|
||||||
#define _MULTI_PARTITION 0
|
|
||||||
/* When _MULTI_PARTITION is set to 0, each volume is bound to the same physical
|
|
||||||
/ drive number and can mount only first primaly partition. When it is set to 1,
|
|
||||||
/ each volume is tied to the partitions listed in Drives[]. */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of configuration options. Do not change followings without care. */
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
|
#if _FATFS != _FFCONFIG
|
||||||
|
#error Wrong configuration file (ffconf.h).
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* DBCS code ranges and SBCS extend char conversion table */
|
/* DBCS code ranges and SBCS extend char conversion table */
|
||||||
@ -352,17 +223,16 @@
|
|||||||
|
|
||||||
#define IsUpper(c) (((c)>='A')&&((c)<='Z'))
|
#define IsUpper(c) (((c)>='A')&&((c)<='Z'))
|
||||||
#define IsLower(c) (((c)>='a')&&((c)<='z'))
|
#define IsLower(c) (((c)>='a')&&((c)<='z'))
|
||||||
#define IsDigit(c) (((c)>='0')&&((c)<='9'))
|
|
||||||
|
|
||||||
#if _DF1S /* DBCS configuration */
|
#if _DF1S /* DBCS configuration */
|
||||||
|
|
||||||
#if _DF2S /* Two 1st byte areas */
|
#ifdef _DF2S /* Two 1st byte areas */
|
||||||
#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E))
|
#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E))
|
||||||
#else /* One 1st byte area */
|
#else /* One 1st byte area */
|
||||||
#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E)
|
#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if _DS3S /* Three 2nd byte areas */
|
#ifdef _DS3S /* Three 2nd byte areas */
|
||||||
#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E))
|
#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E))
|
||||||
#else /* Two 2nd byte areas */
|
#else /* Two 2nd byte areas */
|
||||||
#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E))
|
#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E))
|
||||||
@ -402,10 +272,10 @@ const PARTITION Drives[]; /* Logical drive# to physical location conversion ta
|
|||||||
|
|
||||||
/* Definitions corresponds to multiple sector size */
|
/* Definitions corresponds to multiple sector size */
|
||||||
|
|
||||||
#if _MAX_SS == 512
|
#if _MAX_SS == 512 /* Single sector size */
|
||||||
#define SS(fs) 512U
|
#define SS(fs) 512U
|
||||||
|
|
||||||
#elif _MAX_SS == 1024 || _MAX_SS == 2048 || _MAX_SS == 4096
|
#elif _MAX_SS == 1024 || _MAX_SS == 2048 || _MAX_SS == 4096 /* Multiple sector size */
|
||||||
#define SS(fs) ((fs)->s_size)
|
#define SS(fs) ((fs)->s_size)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -433,6 +303,7 @@ typedef struct _FATFS_ {
|
|||||||
BYTE csize; /* Number of sectors per cluster */
|
BYTE csize; /* Number of sectors per cluster */
|
||||||
BYTE n_fats; /* Number of FAT copies */
|
BYTE n_fats; /* Number of FAT copies */
|
||||||
BYTE wflag; /* win[] dirty flag (1:must be written back) */
|
BYTE wflag; /* win[] dirty flag (1:must be written back) */
|
||||||
|
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
|
||||||
WORD id; /* File system mount ID */
|
WORD id; /* File system mount ID */
|
||||||
WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */
|
WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */
|
||||||
#if _FS_REENTRANT
|
#if _FS_REENTRANT
|
||||||
@ -442,7 +313,6 @@ typedef struct _FATFS_ {
|
|||||||
WORD s_size; /* Sector size */
|
WORD s_size; /* Sector size */
|
||||||
#endif
|
#endif
|
||||||
#if !_FS_READONLY
|
#if !_FS_READONLY
|
||||||
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
|
|
||||||
DWORD last_clust; /* Last allocated cluster */
|
DWORD last_clust; /* Last allocated cluster */
|
||||||
DWORD free_clust; /* Number of free clusters */
|
DWORD free_clust; /* Number of free clusters */
|
||||||
DWORD fsi_sector; /* fsinfo sector */
|
DWORD fsi_sector; /* fsinfo sector */
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Sample code of OS dependent synchronization object controls */
|
/* Sample code of OS dependent synchronization object controls */
|
||||||
/* for FatFs R0.07a (C)ChaN, 2009 */
|
/* for FatFs R0.07c (C)ChaN, 2009 */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include <windows.h> // Win32
|
#include <windows.h> /* Win32 */
|
||||||
//#include <ucos_ii.h> // uC/OS-II
|
//#include <ucos_ii.h> /* uC/OS-II */
|
||||||
|
//#include <semphr.h> /* FreeRTOS */
|
||||||
|
|
||||||
|
|
||||||
#include "../ff.h"
|
#include "../ff.h"
|
||||||
|
|
||||||
@ -25,14 +27,17 @@ BOOL ff_cre_syncobj ( /* TRUE:Function succeeded, FALSE:Could not create due to
|
|||||||
{
|
{
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
*sobj = CreateMutex(NULL, FALSE, NULL); // Win32
|
*sobj = CreateMutex(NULL, FALSE, NULL); /* Win32 */
|
||||||
ret = (*sobj != INVALID_HANDLE_VALUE) ? TRUE : FALSE; //
|
ret = (*sobj != INVALID_HANDLE_VALUE) ? TRUE : FALSE;
|
||||||
|
|
||||||
// *sobj = VolumeSemId[vol]; // uITRON (give a static created sync object)
|
// *sobj = VolumeSemId[vol]; /* uITRON (give a static created sync object) */
|
||||||
// ret = TRUE; // The initial value of the semaphore must be 1.
|
// ret = TRUE; /* The initial value of the semaphore must be 1. */
|
||||||
|
|
||||||
// *sobj = OSMutexCreate(0, &err); // uC/OS-II
|
// *sobj = OSMutexCreate(0, &err); /* uC/OS-II */
|
||||||
// ret = (err == OS_NO_ERR) ? TRUE : FALSE; //
|
// ret = (err == OS_NO_ERR) ? TRUE : FALSE;
|
||||||
|
|
||||||
|
// *sobj = xSemaphoreCreateMutex(); /* FreeRTOS */
|
||||||
|
// ret = (*sobj != NULL) ? TRUE : FALSE;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -53,12 +58,14 @@ BOOL ff_del_syncobj ( /* TRUE:Function succeeded, FALSE:Could not delete due to
|
|||||||
{
|
{
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
ret = CloseHandle(sobj); // Win32
|
ret = CloseHandle(sobj); /* Win32 *
|
||||||
|
|
||||||
// ret = TRUE; // uITRON (nothing to do)
|
// ret = TRUE; /* uITRON (nothing to do) *
|
||||||
|
|
||||||
// OSMutexDel(sobj, OS_DEL_ALWAYS, &err); // uC/OS-II
|
// OSMutexDel(sobj, OS_DEL_ALWAYS, &err); /* uC/OS-II */
|
||||||
// ret = (err == OS_NO_ERR) ? TRUE : FALSE; //
|
// ret = (err == OS_NO_ERR) ? TRUE : FALSE;
|
||||||
|
|
||||||
|
// ret = TRUE; /* FreeRTOS (nothing to do) */
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -78,12 +85,14 @@ BOOL ff_req_grant ( /* TRUE:Got a grant to access the volume, FALSE:Could not ge
|
|||||||
{
|
{
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
|
|
||||||
ret = (WaitForSingleObject(sobj, _TIMEOUT) == WAIT_OBJECT_0) ? TRUE : FALSE; // Win32
|
ret = (WaitForSingleObject(sobj, _TIMEOUT) == WAIT_OBJECT_0) ? TRUE : FALSE; /* Win32 */
|
||||||
|
|
||||||
// ret = (wai_sem(sobj) == E_OK) ? TRUE : FALSE; // uITRON
|
// ret = (wai_sem(sobj) == E_OK) ? TRUE : FALSE; /* uITRON */
|
||||||
|
|
||||||
// OSMutexPend(sobj, _TIMEOUT, &err)); // uC/OS-II
|
// OSMutexPend(sobj, _TIMEOUT, &err)); /* uC/OS-II */
|
||||||
// ret = (err == OS_NO_ERR) ? TRUE : FALSE; //
|
// ret = (err == OS_NO_ERR) ? TRUE : FALSE;
|
||||||
|
|
||||||
|
// ret = (xSemaphoreTake(sobj, _TIMEOUT) == pdTRUE) ? TRUE : FALSE; /* FreeRTOS */
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -100,11 +109,14 @@ void ff_rel_grant (
|
|||||||
_SYNC_t sobj /* Sync object to be signaled */
|
_SYNC_t sobj /* Sync object to be signaled */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ReleaseMutex(sobj); // Win32
|
ReleaseMutex(sobj); /* Win32 */
|
||||||
|
|
||||||
// sig_sem(sobj); // uITRON
|
// sig_sem(sobj); /* uITRON */
|
||||||
|
|
||||||
|
// OSMutexPost(sobj); /* uC/OS-II */
|
||||||
|
|
||||||
|
// xSemaphoreGive(sobj); /* FreeRTOS */
|
||||||
|
|
||||||
// OSMutexPost(sobj); // uC/OS-II
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user