fatfs v0.08 May 15, 2010:

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

View File

@ -4,6 +4,8 @@
<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">
<meta name="description" content="Open souece FAT file system module for embedded projects"> <meta name="description" content="Open souece FAT file system module for embedded projects">
<link rel="start" title="Site Top" href="../../">
<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>
@ -15,7 +17,7 @@
<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 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> <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, 68k 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>
@ -25,8 +27,8 @@
<li>Various configuration options: <li>Various configuration options:
<ul> <ul>
<li>Multiple volumes (physical drives and partitions).</li> <li>Multiple volumes (physical drives and partitions).</li>
<li>Multiple OEM code pages including DBCS.</li> <li>Multiple ANSI/OEM code pages including DBCS.</li>
<li>Long file name (LFN) support in OEM code or Unicode.</li> <li>Long file name support in SBCS/DBCS or Unicode.</li>
<li>RTOS support.</li> <li>RTOS support.</li>
<li>Multiple sector size support.</li> <li>Multiple sector size support.</li>
<li>Read-only, minimized API, I/O buffer and etc...</li> <li>Read-only, minimized API, I/O buffer and etc...</li>
@ -38,7 +40,7 @@
<div class="para"> <div class="para">
<h3>Application Interface</h3> <h3>Application Interface</h3>
<p>FatFs module provides following functions to access the FAT volumes.</p> <p>FatFs module provides following functions to the applications. In other words, this list describes what FatFs can do 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 +73,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 so that 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 at least to access the physical media. When O/S related feature is enabled, it will require process/memory functions in addition. However 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 +87,10 @@
<div class="para"> <div class="para">
<h3>Resources</h3> <h3>Resources</h3>
<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> <p>The FatFs module is a free software opened for education, research and development. You can use, modify and/or redistribute it for personal projects 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">Jan 28, 2010</span></li> <li>Read first: <a href="en/appnote.html">FatFs module application note</a> <span class="mfd">May 15, 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,5 +100,6 @@
</div> </div>
<hr>
</body> </body>
</html> </html>

View File

@ -4,6 +4,8 @@
<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">
<meta name="description" content="組み込みシステム向けFATファイル・システム"> <meta name="description" content="組み込みシステム向けFATファイル・システム">
<link rel="start" title="Site Top" href="../../index_j.html">
<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>
@ -15,20 +17,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>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> <p>FatFsは小規模な組み込みシステム向けの汎用FATファイルシステム・モジュールです。ANSI C準拠でハードウェア・アーキテクチャには依存しないので、必要なワーク・エリアが確保できれば、8051, PIC, AVR, SH, Z80, 68k, 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>Windows互換 FATファイル・システム</li> <li>Windows互換 FATファイル・システム</li>
<li>プラットフォーム非依存</li> <li>プラットフォーム非依存</li>
<li>コンパクトなコード・サイズとRAM使用量</li> <li>コンパクトなコードとRAM使用量</li>
<li>多くの構成オプション: <li>多くの構成オプション:
<ul> <ul>
<li>複数のボリューム(物理ドライブ・区画)</li> <li>複数のボリューム(物理ドライブ・区画)</li>
<li>DBCSを含む複数のOEMコード・ページ</li> <li>DBCSを含む複数のANSI/OEMコード・ページ</li>
<li>長いファイル名(LFN)対応 (Unicode APIも選択可)</li> <li>長いファイル名(LFN) (Unicode APIも選択可)</li>
<li>マルチタスク対応</li> <li>マルチタスク関連</li>
<li>マルチ・セクタ・サイズ対応</li> <li>マルチ・セクタ・サイズ</li>
<li>リード・オンリー、一部APIの削除、バッファ構成、その他…</li> <li>リード・オンリー構成、一部APIの削除、バッファ構成、その他…</li>
</ul> </ul>
</li> </li>
</ul> </ul>
@ -36,8 +38,8 @@
<div class="para"> <div class="para">
<h3>上位レイヤI/F</h3> <h3>上位レイヤ・インターフェース</h3>
<p>FatFsモジュールは、次のファイル操作関数を提供しています。</p> <p>FatFsモジュールは、次のファイル操作関数(API)を提供します。つまり、このリストはFatFsにできることをシンプルに示しています。</p>
<ul> <ul>
<li><a href="ja/mount.html">f_mount</a> - ワークエリアの登録・削除</li> <li><a href="ja/mount.html">f_mount</a> - ワークエリアの登録・削除</li>
<li><a href="ja/open.html">f_open</a> - ファイルのオープン・作成</li> <li><a href="ja/open.html">f_open</a> - ファイルのオープン・作成</li>
@ -69,8 +71,8 @@
<div class="para"> <div class="para">
<h3>下位レイヤI/F</h3> <h3>下位レイヤ・インターフェース</h3>
<p>FatFsモジュールは、物理ドライブ等へのアクセスのため、下位レイヤに次のインターフェースを要求します。それぞれの記録メディアに対応したディスクI/Oモジュールは、ユーザによって用意される必要があります。資料にドライバを含むサンプル・プロジェクトあり。</p> <p>FatFsモジュールは、物理ドライブ等へのアクセスのため、下位レイヤに少なくとも次のインターフェースを要求します。使用する記録メディアに対応したディスクI/Oモジュールは、ユーザによって用意される必要があります。OS関連機能を有効にしたときは、加えてプロセス・メモリ関連関数も必要になります。資料にドライバを含むサンプル・プロジェクトあり。</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,18 +86,20 @@
<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">2010. 1. 28</span></li> <li>最初に読め: <a href="ja/appnote.html">FatFsモジュール・アプリケーション・ート</a> <span class="mfd">2010. 5. 15</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>
<li><a href="http://elm-chan.org/docs/mmc/mmc.html">MMCの使いかた</a></li> <li><a href="http://elm-chan.org/docs/mmc/mmc.html">MMCの使いかた</a></li>
<li><a href="img/rwtest.png">パフォーマンス・テスト1</a> (ATmega64/9.2MHz with MMC via SPI, HDD/CFC via GPIO)</li> <li><a href="img/rwtest.png">パフォーマンス・テスト1</a> (ATmega64/9.2MHz with MMC via SPI, HDD/CFC via GPIO)</li>
<li><a href="img/rwtest2.png">パフォーマンス・テスト2</a> (LPC2368/72MHz with MMC via MCI)</li> <li><a href="img/rwtest2.png">パフォーマンス・テスト2</a> (LPC2368/72MHz with MMC via MCI)</li>
</ul> </ul>
</div> </div>
<hr>
</body> </body>
</html> </html>

View File

@ -10,7 +10,8 @@ p {margin: 0 0 0.3em 1em;}
em {font-style: normal; font-weight: bold; margin: 0 0.1em;} em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
pre em {font-style: italic; font-weight: normal;} 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 {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; background-color: white;}
pre span {color: green;}
tt {margin: 0 0.2em;} tt {margin: 0 0.2em;}
ol {margin: 0 2.5em;} ol {margin: 0 2.5em;}
ul {margin: 0 2em;} ul {margin: 0 2em;}
@ -37,7 +38,7 @@ h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0
p.hdd {float: right; text-align: right; margin-top: 0.5em;} p.hdd {float: right; text-align: right; margin-top: 0.5em;}
hr.hds {clear: both; margin-bottom: 1em;} hr.hds {clear: both; margin-bottom: 1em;}
h2 {font-size: 1.5em; font-family: sans-serif; margin: 0 0 0.5em;} h2 {font-size: 1.5em; color: blueviolet; font-family: sans-serif; margin: 0 0 0.5em;}
h3 {font-size: 1.5em; font-family: sans-serif; margin: 1.5em 0 0.5em;} h3 {font-size: 1.5em; font-family: sans-serif; margin: 1.5em 0 0.5em;}
h4 {font-size: 1.2em; font-family: sans-serif; margin: 1em 0 0.2em;} h4 {font-size: 1.2em; font-family: sans-serif; margin: 1em 0 0.2em;}
h5 {font-size: 1em; font-family: sans-serif; margin: 0.5em 0 0em;} h5 {font-size: 1em; font-family: sans-serif; margin: 0.5em 0 0em;}

View File

@ -13,7 +13,8 @@ p {text-indent: 1em; margin: 0 0 0.3em 0.5em;}
em {font-style: normal; font-weight: bold; margin: 0 0.1em;} em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
pre em {font-style: italic; font-weight: normal;} 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 {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; letter-spacing: 0; background-color: white;}
pre span {color: green;}
tt {margin: 0 0.2em; letter-spacing: 0;} tt {margin: 0 0.2em; letter-spacing: 0;}
ol {margin: 0 2.5em;} ol {margin: 0 2.5em;}
ul {margin: 0 2em;} ul {margin: 0 2em;}
@ -40,7 +41,7 @@ h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0
p.hdd {float: right; text-align: right; margin-top: 0.5em;} p.hdd {float: right; text-align: right; margin-top: 0.5em;}
hr.hds {clear: both; margin-bottom: 1em;} hr.hds {clear: both; margin-bottom: 1em;}
h2 {font-size: 1.5em; font-family: " Pゴシック",sans-serif; margin: 0 0 0.5em;} h2 {font-size: 1.5em; color: blueviolet; font-family: " Pゴシック",sans-serif; margin: 0 0 0.5em;}
h3 {font-size: 1.5em; font-family: " Pゴシック",sans-serif; margin: 1.5em 0 0.5em;} h3 {font-size: 1.5em; font-family: " Pゴシック",sans-serif; margin: 1.5em 0 0.5em;}
h4 {font-size: 1.2em; font-family: " Pゴシック",sans-serif; margin: 1em 0 0.2em;} h4 {font-size: 1.2em; font-family: " Pゴシック",sans-serif; margin: 1em 0 0.2em;}
h5 {font-size: 1em; font-family: " Pゴシック",sans-serif; margin: 0.5em 0 0em;} h5 {font-size: 1em; font-family: " Pゴシック",sans-serif; margin: 0.5em 0 0em;}

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/appnote.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs Module Application Note</title> <title>FatFs Module Application Note</title>
</head> </head>
@ -13,22 +14,22 @@
<hr> <hr>
<div class="para"> <div class="para">
<h3>Basic considerations on porting</h3> <h3>How to port</h3>
<p>The FatFs module is assuming following terms on portability.</p>
<h4>Basic considerations</h4>
<p>The FatFs module is assuming following conditions 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 which is written in ANSI C. There is no platform dependence, so long as the compiler is in compliance with ANSI C.</li>
<li>Size of integer types<br> <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 class="para"> <h4>Which function is required?</h4>
<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> <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>Function</th><th>Required when:</th></tr> <tr><th>Function</th><th>Required when:</th><th>Note</th></tr>
<tr><td>disk_initialize</td><td>Always</td></tr> <tr><td>disk_initialize</td><td>Always</td><td rowspan="9">Samples available in ffsample.zip.<br>There are many implementations on the web.</td></tr>
<tr><td>disk_status</td><td>Always</td></tr> <tr><td>disk_status</td><td>Always</td></tr>
<tr><td>disk_read</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_write</td><td>_FS_READONLY == 0</td></tr>
@ -37,6 +38,14 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
<tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS &gt;= 1024</td></tr> <tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS &gt;= 1024</td></tr>
<tr><td>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr> <tr><td>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr>
<tr><td>get_fattime</td><td>_FS_READONLY == 0</td></tr> <tr><td>get_fattime</td><td>_FS_READONLY == 0</td></tr>
<tr><td>ff_convert</td><td>_USE_LFN &gt;= 1</td><td rowspan="2">Available in option/cc*.c.</td></tr>
<tr><td>ff_wtoupper</td><td>_USE_LFN &gt;= 1</td></tr>
<tr><td>ff_cre_syncobj</td><td>_FS_REENTRANT == 1</td><td rowspan="6">Samples available in option/syscall.c.</td></tr>
<tr><td>ff_del_syncobj</td><td>_FS_REENTRANT == 1</td></tr>
<tr><td>ff_req_grant</td><td>_FS_REENTRANT == 1</td></tr>
<tr><td>ff_rel_grant</td><td>_FS_REENTRANT == 1</td></tr>
<tr><td>ff_mem_alloc</td><td>_USE_LFN == 3</td></tr>
<tr><td>ff_mem_free</td><td>_USE_LFN == 3</td></tr>
</table> </table>
</div> </div>
@ -44,28 +53,28 @@ The FatFs module assumes that size of char/short/long are 8/16/32 bit and int is
<h3>Limits</h3> <h3>Limits</h3>
<ul> <ul>
<li>FAT sub-types: FAT12, FAT16 and FAT32.</li> <li>FAT sub-types: FAT12, FAT16 and FAT32.</li>
<li>Number of open files: Unlimited. Depends on available memory.</li> <li>Number of open files: Unlimited, depends on available memory.</li>
<li>Number of volumes: Upto 10.</li> <li>Number of volumes: Upto 10.</li>
<li>File size: Depends on FAT specs (4G-1 bytes). </li> <li>File size: Depends on FAT specs. (upto 4G-1 bytes)</li>
<li>Volume size: Depends on FAT specs (upto 2T,4T or 8T bytes). </li> <li>Volume size: Depends on FAT specs. (upto 2T bytes on 512 bytes/sector)</li>
<li>Cluster size: Upto 64K bytes. Upto 32K bytes for f_mkfs().</li> <li>Cluster size: Depends on FAT specs. (upto 64K bytes on 512 bytes/sector)</li>
<li>Sector size: Depends on FAT specs (upto 4K bytes).</li> <li>Sector size: Depends on FAT specs. (upto 4K bytes)</li>
</ul> </ul>
</div> </div>
<div class="para"> <div class="para">
<h3>Memory Usage (R0.07e)</h3> <h3>Memory Usage (R0.08)</h3>
<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>x86</th></tr> <tr><th></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>V850ES</th><th>SH-2A</th><th>ARM7</th><th>x86</th></tr>
<tr><td>Compiler</td><td>WinAVR(gcc)</td><td>CH38</td><td>C30(gcc)</td><td>CC870C</td><td>CA850</td><td>SHC</td><td>WinARM(gcc)</td><td>VC6</td></tr> <tr><td>Compiler</td><td>WinAVR(gcc)</td><td>CH38</td><td>C30(gcc)</td><td>CA850</td><td>SHC</td><td>WinARM(gcc)</td><td>VC6</td></tr>
<tr><td>_WORD_ACCESS</td><td>1</td><td>0</td><td>0</td><td>1</td><td>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>0</td><td>0</td><td>1</td></tr>
<tr class="lst3"><td>text (Full, R/W)</td><td>12194</td><td>10559</td><td>10924</td><td>15229</td><td>7686</td><td>8727</td><td>10564</td><td>7342</td></tr> <tr class="lst3"><td>text (Full, R/W)</td><td>12700</td><td>10686</td><td>11376</td><td>7730</td><td>8592</td><td>10520</td><td>7545</td></tr>
<tr> <td>text (Min, R/W)</td><td>7988</td><td>6903</td><td>7108</td><td>9960</td><td>4884</td><td>5651</td><td>6544</td><td>4764</td></tr> <tr> <td>text (Min, R/W)</td><td>8386</td><td>6980</td><td>7395</td><td>4930</td><td>5600</td><td>6636</td><td>4923</td></tr>
<tr><td>text (Full, R/O)</td><td>5532</td><td>4753</td><td>5020</td><td>6760</td><td>3462</td><td>3777</td><td>4624</td><td>3316</td></tr> <tr><td>text (Full, R/O)</td><td>6012</td><td>4874</td><td>5250</td><td>3556</td><td>3848</td><td>4656</td><td>3450</td></tr>
<tr> <td>text (Min, R/O)</td><td>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>text (Min, R/O)</td><td>4384</td><td>3774</td><td>3939</td><td>2684</td><td>2996</td><td>3416</td><td>2664</td></tr>
<tr><td>bss</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*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*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
<tr><td>Work area<br>(_FS_TINY == 0)</td><td>D*560 +<br>F*544</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*544</td><td></td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td></tr> <tr><td>Work area<br>(_FS_TINY == 0)</td><td>D*560 +<br>F*544</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*544</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td></tr>
<tr><td>Work area<br>(_FS_TINY == 1)</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*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*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>
@ -74,12 +83,14 @@ _FS_MINIMIZE 0 (Full function), 3 (Minimized function)
_USE_STRFUNC 0 (Disable string functions) _USE_STRFUNC 0 (Disable string functions)
_USE_MKFS 0 (Disable f_mkfs function) _USE_MKFS 0 (Disable f_mkfs function)
_USE_FORWARD 0 (Disable f_forward function) _USE_FORWARD 0 (Disable f_forward function)
_USE_FASTSEEK 0 (Disable fast seek feature)
_CODE_PAGE 932 (Japanese Shift-JIS) _CODE_PAGE 932 (Japanese Shift-JIS)
_USE_LFN 0 (Disable LFN) _USE_LFN 0 (Disable LFN)
_MAX_SS 512 (Single sector size) _MAX_SS 512 (Fixed sector size)
_FS_RPATH 0 (Disable relative path) _FS_RPATH 0 (Disable relative path)
_MULTI_PARTITION 0 (Single partition per drive) _MULTI_PARTITION 0 (Single partition per drive)
_FS_REENTRANT 0 (Disable reentrancy) _FS_REENTRANT 0 (Disable reentrancy)
_FS_SHARE 0 (Disable shareing control)
</pre> </pre>
</div> </div>
@ -119,7 +130,7 @@ _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. If the size of working buffer is insufficient for the given file name, the file function fails with <tt>FR_INVALID_NAME</tt>. When enable the LFN feature with re-entrant feature, <tt>_USE_LFN</tt> must be set to 2. In this case, the file function allocates the working buffer on the stack. The working buffer occupies <tt>(_MAX_LFN + 1) * 2</tt> bytes so that the caller's stack must be a sufficient size considering the working buffer.</p> <p>The FatFs module has started to support long file name (LFN) at revision 0.07. The two different file names, SFN and LFN, of a file is transparent in the file functions except for f_readdir function. To enable LFN feature, set <tt>_USE_LFN</tt> to 1, 2 or 3, and add a Unicode code conversion function <tt>ff_convert()</tt> and <tt>ff_wtoupper()</tt> to the project. The LFN feature requiers a certain working buffer in addition. The buffer size can be configured by <tt>_MAX_LFN</tt> corresponding to the available memory size. The size of long file name will reach up to 255 characters so that the <tt>_MAX_LFN</tt> should be set to 255 for full featured LFN operation. If the size of working buffer is insufficient for the given file name, the file function fails with <tt>FR_INVALID_NAME</tt>. When enable the LFN feature with re-entrant feature, <tt>_USE_LFN</tt> must be set to 2 or 3. In this case, the file function allocates the working buffer on the stack or heap. The working buffer occupies <tt>(_MAX_LFN + 1) * 2</tt> bytes.</p>
<table class="lst2 rset"> <table class="lst2 rset">
<caption>LFN cfg on ARM7</caption> <caption>LFN cfg on ARM7</caption>
<tr><th>Code page</th><th>Program size</th></tr> <tr><th>Code page</th><th>Program size</th></tr>
@ -129,13 +140,18 @@ _FS_REENTRANT 0 (Disable reentrancy)
<tr><td>949(Korean)</td><td>+139K</td></tr> <tr><td>949(Korean)</td><td>+139K</td></tr>
<tr><td>950(Big5)</td><td>+111K</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 how many bytes increased when LFN feature is enabled with some code pages. We are the Japanese, Chinese and Korean have tens of thousands of characters. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased that shown in the table. As the result, the FatFs with LFN will not able to be implemented to most 8-bit microcontrollers including AVR. <small>This is the reason why I had not been interested in implementing the LFN feature for a long time :-)</small></p> <p>When the LFN feature is enabled, the module size will be increased depends on the selected code page. Right table shows how many bytes increased when LFN feature is enabled with some code pages. We are the Japanese, Chinese and Korean have tens of thousands of characters. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased that shown in the table. As the result, the FatFs with LFN feature with DBCS will not able to be implemented to most 8-bit microcontrollers. <small>This is the reason why I had not been interested in implementing the LFN feature for a long time :-)</small></p>
<p>Note that the LFN feature on the FAT file system is a patent of Microsoft Corporation. When enable it on the commercial products, a license from Microsoft may be required depends on the final destination.</p> <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>
<div class="para">
<h3>Unicode API</h3>
<p>FatFs supports ANSI/OEM code set on the API in default but FatFs can also switch the code set to Unicode. For more information, refer to the description in the <a href="filename.html">file name</a>.</p>
</div>
<div class="para"> <div class="para">
<h3>Re-entrancy</h3> <h3>Re-entrancy</h3>
<p>The file operations to the different volume can always work simultaneously regardless of re-entrancy setting. The re-entrancy to the same volume can be enabled with <tt>_FS_REENTRANT</tt> option. In this case, also the OS dependent synchronization object control functions, ff_cre_syncobj, ff_del_syncobj, ff_req_grant and ff_rel_grant must be added to the project. The sample code with documentation is available in <tt>syncobj.c</tt>.</p> <p>The file operations to the different volume can always work simultaneously regardless of re-entrancy setting. The re-entrancy to the same volume can be enabled with <tt>_FS_REENTRANT</tt> option. In this case, also the OS dependent synchronization object control functions, ff_cre_syncobj, ff_del_syncobj, ff_req_grant and ff_rel_grant must be added to the project.</p>
<p>When a file function is called while the volume is in use by any other task, the access is blocked until the task leaves file function. If wait time exceeded a period defined by <tt>_TIMEOUT</tt>, the file function will abort with <tt>FR_TIMEOUT</tt>. The timeout feature might not be supported on some RTOS.</p> <p>When a file function is called while the volume is in use by any other task, the access is blocked until the task leaves file function. If wait time exceeded a period defined by <tt>_TIMEOUT</tt>, the file function will abort with <tt>FR_TIMEOUT</tt>. The timeout feature might not be supported on some RTOS.</p>
<p>There is an exception on f_mount and f_mkfs function. These functions are not re-entrant to the same volume. When use these functions, all other task must close the corresponding file on the volume and avoid to access the volume.</p> <p>There is an exception on f_mount and f_mkfs function. These functions are not re-entrant to the same volume. When use these functions, all other task must close the corresponding file on the volume and avoid to access the volume.</p>
<p>Note that this section describes on the re-entrancy of the FatFs module itself. There is no assumtion on the re-entrancy of low level disk I/O module.</p> <p>Note that this section describes on the re-entrancy of the FatFs module itself. There is no assumtion on the re-entrancy of low level disk I/O module.</p>
@ -143,7 +159,8 @@ _FS_REENTRANT 0 (Disable reentrancy)
<div class="para"> <div class="para">
<h3>Duplicated file access</h3> <h3>Duplicated file access</h3>
<p>FatFs module does not support the shareing controls of duplicated file access. It is permitted when open method to the file is only read mode. The duplicated open in write mode to a file is always prohibited and open file must not be renamed, deleted, otherwise the FAT structure on the volume can be collapted.</p> <p>FatFs module does not support the shareing controls of duplicated file access in default. It is permitted when open method to a file is only read mode. The duplicated open in write mode to a file is always prohibited and open file must not be renamed, deleted, otherwise the FAT structure on the volume can be collapted. Also current directory must not be deleted.</p>
<p>The file shareing control can also be available when <tt>_FS_SHARE</tt> is set to 1 or grater. In this case, if any open, rename or remove that violating the file shareing rule that described above is attempted, the file function will fail with <tt>FR_LOCKED</tt>.</p>
</div> </div>
<div class="para"> <div class="para">
@ -160,12 +177,12 @@ _FS_REENTRANT 0 (Disable reentrancy)
</p> </p>
<p>The file I/O buffer means a sector buffer to read/write a partial data on the sector. The sector buffer is either file private sector buffer on each file object or shared sector buffer on the file system object. The buffer configuration option <tt>_FS_TINY</tt> determins which sector buffer is used for the file data transfer. When tiny buffer (1) is selected, data memory consumption is reduced 512 bytes each file object. In this case, FatFs module uses only a sector buffer on the file system object for file data transfer and FAT/directory access. The disadvantage of the tiny buffer configuration is: the FAT data cached in the sector buffer will be lost by file data transfer and it must be reloaded at every cluster boundary. However it will be suitable for most application from view point of the decent performance and low memory comsumption.</p> <p>The file I/O buffer means a sector buffer to read/write a partial data on the sector. The sector buffer is either file private sector buffer on each file object or shared sector buffer on the file system object. The buffer configuration option <tt>_FS_TINY</tt> determins which sector buffer is used for the file data transfer. When tiny buffer (1) is selected, data memory consumption is reduced 512 bytes each file object. In this case, FatFs module uses only a sector buffer on the file system object for file data transfer and FAT/directory access. The disadvantage of the tiny buffer configuration is: the FAT data cached in the sector buffer will be lost by file data transfer and it must be reloaded at every cluster boundary. However it will be suitable for most application from view point of the decent performance and low memory comsumption.</p>
<p>Figure 1 shows that partial sector data is transferred via the file I/O buffer. On long data transfer shown in Figure 2, middle of transfer data that covers one or more sector is transferred to application buffer directly. Figure 3 shows that the case of entier transfer data is aligned to the sector boundary. In this case, file I/O buffer is not used. On the direct transfer, the maximum extent of sectors are read with disk_read function at a time but the multi sector transfer never across the cluster boundary even if it is contiguous.</p> <p>Figure 1 shows that partial sector data is transferred via the file I/O buffer. On long data transfer shown in Figure 2, middle of transfer data that covers one or more sector is transferred to application buffer directly. Figure 3 shows that the case of entier transfer data is aligned to the sector boundary. In this case, file I/O buffer is not used. On the direct transfer, the maximum extent of sectors are read with disk_read function at a time but the multi sector transfer never across the cluster boundary even if it is contiguous.</p>
<p>Therefore taking effort to sector aligned read/write accesss avoids buffered data transfer and the read/write performance will be improved. Besides the effect, cached FAT data will not be flushed by file data transfer on the tiny configuration so that it can achieve same performance as non tiny configuration with small memory footprint.</p> <p>Therefore taking effort to sector aligned read/write accesss avoids buffered data transfer and the read/write performance will be improved. Besides the effect, cached FAT data will not be flushed by file data transfer on the tiny configuration so that it can achieve same performance as non-tiny configuration with small memory footprint.</p>
</div> </div>
<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 application.</p> <p>If a write operation to the FAT file system is interrupted due to any accidental failure, such as sudden blackout, incorrect disk removal and unrecoverable disk error, the FAT structure can be collapted. Following images shows the critical section on the FatFs application.</p>
<div class="lset"> <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">
@ -175,34 +192,28 @@ Figure 5. Minimized critical section<br>
<img src="../img/f5.png" width="320" height="436" alt="fig.5"> <img src="../img/f5.png" width="320" height="436" alt="fig.5">
</div> </div>
<br class="clr"> <br class="clr">
<p>An interruption in the red section can cause a cross link; as a result, the file/directory being changed may be lost. There is one or more possibility listed below when an interruption in the yellow section is occured.</p> <p>An interruption in the red section can cause a cross link; as a result, the object being changed may be lost. There is one or more possibility listed below when an interruption in the yellow section is occured.</p>
<ul> <ul>
<li>File data being rewrited is collapted.</li> <li>File data being rewrited is collapted.</li>
<li>A file being appended returns initial state.</li> <li>A file being appended returns initial state.</li>
<li>A file created as new is gone.</li> <li>A file created as new is gone.</li>
<li>A file created as new or in overwritten remains with length of zero.</li> <li>A file created as new or in overwritten remains with no content.</li>
<li>Efficiency of disk use gets worse due to lost chain.</li> <li>Efficiency of disk use gets worse due to lost chain.</li>
</ul> </ul>
<p>Each case does not affect the files that not in write mode open. To minimize risk of data loss, the critical section can be minimized like shown in Figure 5 by minimizing the time that file is opened in write mode or using f_sync function properly.</p> <p>Each case does not affect the files that not in write mode open. To minimize risk of data loss, the critical section can be minimized like shown in Figure 5 by minimizing the time that file is opened in write mode or using f_sync function properly.</p>
</div> </div>
<div class="para">
<h3>Unicode API</h3>
<p>FatFs supports OEM code set on the API in default but FatFs can also switch the code set to Unicode. For more information, refer to the description in the <a href="filename.html">file name</a>.</p>
</div>
<div class="para"> <div class="para">
<h3>About FatFs License</h3> <h3>About FatFs License</h3>
<p>This is a copy of the FatFs license document that included in the source codes.</p> <p>This is a copy of the FatFs license document that included in the source codes.</p>
<pre>/*----------------------------------------------------------------------------/ <pre>/*----------------------------------------------------------------------------/
/ FatFs - FAT file system module R0.07e (C)ChaN, 2009 / FatFs - FAT file system module R0.08 (C)ChaN, 2010
/-----------------------------------------------------------------------------/ /-----------------------------------------------------------------------------/
/ FatFs module is a generic FAT file system module for small embedded systems. / 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 / This is a free software that opened for education, 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) 2010, ChaN, all right reserved.
/ /
/ * The FatFs module is a free software and there is NO WARRANTY. / * The FatFs module is a free software and there is NO WARRANTY.
/ * No restriction on use. You can use, modify and redistribute it for / * No restriction on use. You can use, modify and redistribute it for
@ -210,7 +221,7 @@ Figure 5. Minimized critical section<br>
/ * Redistributions of source code must retain the above copyright notice. / * Redistributions of source code must retain the above copyright notice.
/ /
/-----------------------------------------------------------------------------/</pre> /-----------------------------------------------------------------------------/</pre>
<p>Therefore FatFs license is one of the BSD-style license but there is a big difference. Because FatFs is for embedded projects, the conditions for redistributions in binary form, such as embedded code, hex file and binary library, are not specified to increase its usability. The documentation of the distributions need not include about FatFs and its license document, and it may also. Of course FatFs is compatible with the projects under GNU GPL. When redistribute it with any modification, the license can also be changed to GNU GPL or BSD license.</p> <p>Therefore FatFs license is one of the BSD-style license but there is a big difference. Because FatFs is for embedded projects, the conditions for redistributions in binary form, such as embedded code, hex file and binary library, are not specified to increase its usability. The documentation of the distributions need not include about FatFs and its license document, and it may also. Of course FatFs is compatible with the projects under GNU GPL. When redistribute it with any modification, the license can also be changed to GNU GPL or BSD-style license.</p>
</div> </div>
<p class="foot"><a href="../00index_e.html">Return</a></p> <p class="foot"><a href="../00index_e.html">Return</a></p>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/chdir.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_chdir</title> <title>FatFs - f_chdir</title>
</head> </head>
@ -15,7 +16,7 @@
<p>The f_chdir function changes the current directory of a drive.</p> <p>The f_chdir function changes the current directory of a drive.</p>
<pre> <pre>
FRESULT f_chdir ( FRESULT f_chdir (
const XCHAR* <em>Path</em> /* Pointer to the path name */ const TCHAR* <em>Path</em> <span>/* Pointer to the path name */</span>
); );
</pre> </pre>
</div> </div>
@ -49,7 +50,7 @@ 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 volume on the disk.</dd> <dd>There is no valid FAT volume on the drive.</dd>
</dl> </dl>
</div> </div>
@ -69,10 +70,10 @@ FRESULT f_chdir (
<div class="para"> <div class="para">
<h4>Example</h4> <h4>Example</h4>
<pre> <pre>
// Change current direcoty of the current drive (dir1 under root dir) <span>/* Change current direcoty of the current drive (dir1 under root dir) */</span>
f_chdir("/dir1"); f_chdir("/dir1");
// Change current direcoty of drive 2 (parent dir) <span>/* Change current direcoty of drive 2 (parent dir) */</span>
f_chdir("2:.."); f_chdir("2:..");
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/chdrive.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_chdrive</title> <title>FatFs - f_chdrive</title>
</head> </head>
@ -15,7 +16,7 @@
<p>The f_chdrive function changes the current drive.</p> <p>The f_chdrive function changes the current drive.</p>
<pre> <pre>
FRESULT f_chdrive ( FRESULT f_chdrive (
BYTE <em>Drive</em> /* Logical drive number */ BYTE <em>Drive</em> <span>/* Logical drive number */</span>
); );
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/chmod.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_chmod</title> <title>FatFs - f_chmod</title>
</head> </head>
@ -15,9 +16,9 @@
<p>The f_chmod function changes the attribute of a file or directory.</p> <p>The f_chmod function changes the attribute of a file or directory.</p>
<pre> <pre>
FRESULT f_chmod ( FRESULT f_chmod (
const XCHAR* <em>FileName</em>, /* Pointer to the file or directory */ const TCHAR* <em>FileName</em>, <span>/* Pointer to the file or directory */</span>
BYTE <em>Attribute</em>, /* Attribute flags */ BYTE <em>Attribute</em>, <span>/* Attribute flags */</span>
BYTE <em>AttributeMask</em> /* Attribute masks */ BYTE <em>AttributeMask</em> <span>/* Attribute masks */</span>
); );
</pre> </pre>
</div> </div>
@ -67,7 +68,7 @@ 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 volume on the disk.</dd> <dd>There is no valid FAT volume on the drive.</dd>
</dl> </dl>
</div> </div>
@ -87,7 +88,7 @@ FRESULT f_chmod (
<div class="para"> <div class="para">
<h4>Example</h4> <h4>Example</h4>
<pre> <pre>
// Set read-only flag, clear archive flag and others are retained. <span>/* Set read-only flag, clear archive flag and others are retained. */</span>
f_chmod("file.txt", AR_RDO, AR_RDO | AR_ARC); f_chmod("file.txt", AR_RDO, AR_RDO | AR_ARC);
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/close.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_close</title> <title>FatFs - f_close</title>
</head> </head>
@ -15,7 +16,7 @@
<p>The f_close function closes an open file.</p> <p>The f_close function closes an open file.</p>
<pre> <pre>
FRESULT f_close ( FRESULT f_close (
FIL* <em>FileObject</em> /* Pointer to the file object structure */ FIL* <em>FileObject</em> <span>/* Pointer to the file object structure */</span>
); );
</pre> </pre>
</div> </div>
@ -48,7 +49,7 @@ FRESULT f_close (
<div class="para"> <div class="para">
<h4>Description</h4> <h4>Description</h4>
<p>The f_close function closes an open file object. If any data has been written to the file, the cached information of the file is written back to the disk. After the function succeeded, the file object is no longer valid and it can be discarded. If the file object has been opened in read-only mode, it may be discarded without closing process by this function.</p> <p>The f_close function closes an open file object. If any data has been written to the file, the cached information of the file is written back to the disk. After the function succeeded, the file object is no longer valid and it can be discarded. If the file object has been opened in read-only mode, it may be discarded without closing process by this function but not recommended.</p>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dinit.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_initialize</title> <title>FatFs - disk_initialize</title>
</head> </head>
@ -15,7 +16,7 @@
<p>The disk_initialize function initializes the disk drive.</p> <p>The disk_initialize function initializes the disk drive.</p>
<pre> <pre>
DSTATUS disk_initialize ( DSTATUS disk_initialize (
BYTE <em>Drive</em> /* Physical drive number */ BYTE <em>Drive</em> <span>/* Physical drive number */</span>
); );
</pre> </pre>
</div> </div>
@ -37,7 +38,7 @@ DSTATUS disk_initialize (
<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> <p>This function is called on volume mount process in the FatFs module to manage the media change. <em>Application program should not call this function, or FAT structure on the volume can be collapted. To re-initialize the file system, use f_mount function.</em></p>
</div> </div>
<p class="foot"><a href="../00index_e.html">Return</a></p> <p class="foot"><a href="../00index_e.html">Return</a></p>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dioctl.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_ioctl</title> <title>FatFs - disk_ioctl</title>
</head> </head>
@ -15,9 +16,9 @@
<p>The disk_ioctl function cntrols device specified features and miscellaneous functions other than disk read/write.</p> <p>The disk_ioctl function cntrols device specified features and miscellaneous functions other than disk read/write.</p>
<pre> <pre>
DRESULT disk_ioctl ( DRESULT disk_ioctl (
BYTE <em>Drive</em>, /* Drive number */ BYTE <em>Drive</em>, <span>/* Drive number */</span>
BYTE <em>Command</em>, /* Control command code */ BYTE <em>Command</em>, <span>/* Control command code */</span>
void* <em>Buffer</em> /* Data transfer buffer */ void* <em>Buffer</em> <span>/* Parameter and data buffer */</span>
); );
</pre> </pre>
</div> </div>
@ -56,9 +57,9 @@ DRESULT disk_ioctl (
<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 command is not required in read-only configuration.</td></tr> <tr><td>CTRL_SYNC</td><td>Make sure that the disk drive has finished pending write process. When the disk I/O module has a write back cache, flush the dirty sector immediately. This command is not required in read-only configuration.</td></tr>
<tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the drive into the WORD variable pointed by Buffer. This command is not required in single sector size configuration, _MAX_SS is 512.</td></tr> <tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the drive into the WORD variable pointed by <tt>Buffer</tt>. This command is not required in single sector size configuration, _MAX_SS is 512.</td></tr>
<tr><td>GET_SECTOR_COUNT</td><td>Returns total sectors on the drive into the DWORD variable pointed by 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 <tt>Buffer</tt>. This command is used by only f_mkfs function to determine the volume size to be created.</td></tr>
<tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the 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 flash memory in unit of sector into the DWORD variable pointed by <tt>Buffer</tt>. This command is used by only f_mkfs function and it attempts to align data area to the erase block boundary. The allowable value is 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or disk devices.</td></tr>
</table> </table>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dread.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_read</title> <title>FatFs - disk_read</title>
</head> </head>
@ -15,10 +16,10 @@
<p>The disk_read function reads sector(s) from the disk drive.</p> <p>The disk_read function reads sector(s) from the disk drive.</p>
<pre> <pre>
DRESULT disk_read ( DRESULT disk_read (
BYTE <em>Drive</em>, /* Physical drive number */ BYTE <em>Drive</em>, <span>/* Physical drive number */</span>
BYTE* <em>Buffer</em>, /* Pointer to the read data buffer */ BYTE* <em>Buffer</em>, <span>/* Pointer to the read data buffer */</span>
DWORD <em>SectorNumber</em>, /* Start sector number */ DWORD <em>SectorNumber</em>, <span>/* Start sector number */</span>
BYTE <em>SectorCount</em> /* Number of sectros to read */ BYTE <em>SectorCount</em> <span>/* Number of sectros to read */</span>
); );
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dstat.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_status</title> <title>FatFs - disk_status</title>
</head> </head>
@ -15,7 +16,7 @@
<p>The disk_status function returns the current disk status.</p> <p>The disk_status function returns the current disk status.</p>
<pre> <pre>
DSTATUS disk_status ( DSTATUS disk_status (
BYTE <em>Drive</em> /* Physical drive number */ BYTE <em>Drive</em> <span>/* Physical drive number */</span>
); );
</pre> </pre>
</div> </div>
@ -31,7 +32,7 @@ DSTATUS disk_status (
<div class="para"> <div class="para">
<h4>Return Values</h4> <h4>Return Values</h4>
<p>The disk status is returned in combination of following flags.</p> <p>The disk status is returned in combination of following flags. FatFs refers only <tt>STA_NOINIT</tt> and <tt>STA_PROTECTED</tt>.</p>
<dl class="ret"> <dl class="ret">
<dt>STA_NOINIT</dt> <dt>STA_NOINIT</dt>
<dd>Indicates that the disk drive has not been initialized. This flag is set on: system reset, disk removal and disk_initialize function failed, and cleared on: disk_initialize function succeeded.</dd> <dd>Indicates that the disk drive has not been initialized. This flag is set on: system reset, disk removal and disk_initialize function failed, and cleared on: disk_initialize function succeeded.</dd>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/dwrite.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - disk_write</title> <title>FatFs - disk_write</title>
</head> </head>
@ -15,10 +16,10 @@
<p>The disk_write writes sector(s) to the disk.</p> <p>The disk_write writes sector(s) to the disk.</p>
<pre> <pre>
DRESULT disk_write ( DRESULT disk_write (
BYTE <em>Drive</em>, /* Physical drive number */ BYTE <em>Drive</em>, <span>/* Physical drive number */</span>
const BYTE* <em>Buffer</em>, /* Pointer to the write data (may be non aligned) */ const BYTE* <em>Buffer</em>, <span>/* Pointer to the write data (may be non aligned) */</span>
DWORD <em>SectorNumber</em>, /* Sector number to write */ DWORD <em>SectorNumber</em>, <span>/* Sector number to write */</span>
BYTE <em>SectorCount</em> /* Number of sectors to write */ BYTE <em>SectorCount</em> <span>/* Number of sectors to write */</span>
); );
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/fattime.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - get_fattime</title> <title>FatFs - get_fattime</title>
</head> </head>

View File

@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/filename.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - Path Names</title> <title>FatFs - Path Names</title>
</head> </head>
@ -13,10 +14,9 @@
<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 the filename specs of DOS/Windos 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> <p><tt>"[drive#:][/]directory/file"</tt></p>
"[<em>drive#</em>:][/]<em>directory</em>/<em>file</em>" <p>The FatFs module supports long file name (LFN) and 8.3 format file name (SFN). The LFN can be used when LFN feature is enabled <tt>(_USE_LFN &gt; 0)</tt>. The differences between FatFs and DOS/Windows are directory separator and logical drive number. The sub directories are separated with a / or \. The logical drive is specified in a numeral with a colon. When the drive number is omitted, it is assumed as default drive (0 or current drive).</p>
</pre> <p>Nul character and control characters (\0 to \x1F) are recognized as end of the path name. Leading/embedded spaces in the path name are valid as a part of the name on LFN configuration but they are recognized as end of the path name on non-LFN configuration.</p>
<p>The FatFs module supports long file name (LFN) and 8.3 format file name (SFN). The LFN can be used when LFN feature is enabled <tt>(_USE_LFN &gt; 0)</tt>. The differences between DOS/Windows are directory separator and logical drive number. The sub directories are separated with a / or \. The logical drive is specified in a numeral with a colon. When the drive number is omitted, it is assumed as default drive (0 or current drive). Leading/embedded spaces in the given path name are valid as a part of the name on LFN configuration but they are recognized as end of the path name on non-LFN configuration.</p>
<p>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>In default configuration <tt>(_FS_RPATH == 0)</tt>, it does not have a concept of current directory like OS oriented file system. All objects on the volume are always specified in full path name that follows from the root directory. Dot directory names are not allowed. Heading separator is ignored and it can be exist or omitted. The default drive number is fixed to 0.</p>
<p>When relative path feature is enabled <tt>(_FS_RPATH == 1)</tt>, specified path is followed from the root directory if a heading separator is exist. If not, the path is followed from the current directory set with <a href="chdir.html">f_chdir</a> function. Dot names are also allowed for the directory name. The default drive number is the current drive number set with <a href="chdrive.html">f_chdrive</a> function.</p> <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">
@ -31,14 +31,19 @@
<tr><td>.</td><td>Invalid name</td><td>This directory</td></tr> <tr><td>.</td><td>Invalid name</td><td>This directory</td></tr>
<tr><td>..</td><td>Invalid name</td><td>Parent directory of the current directory</td></tr> <tr><td>..</td><td>Invalid name</td><td>Parent directory of the current directory</td></tr>
<tr><td>dir1/..</td><td>Invalid name</td><td>The current directory</td></tr> <tr><td>dir1/..</td><td>Invalid name</td><td>The current directory</td></tr>
<tr><td>/..</td><td>Invalid name</td><td>Invalid name (Cannot use dot names at the root directory)</td></tr> <tr><td>/..</td><td>Invalid name</td><td>The root directory (sticks the top level)</td></tr>
</table> </table>
</div> </div>
<p><br></p> <p><br></p>
<div class="para"> <div class="para">
<h2>Unicode API</h2> <h2>Unicode API</h2>
<p>The path names are input/output in either OEM code (SBCS/DBCS) or Unicode depends on the configuration options. The type of arguments that specifies the file names are defined as <tt>XCHAR</tt> which is an alias of <tt>char</tt> in default. The code set of the file name string is the OEM code set specifid by <tt>_CODE_PAGE</tt>. When <tt>_LFN_UNICODE</tt> is set to 1 under LFN configuration, the type of the <tt>XCHAR</tt> is switched to <tt>unsigned short</tt> (wide character) to support Unicode. In this case, the LFN feature is fully supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name.</p> <p>The path names are input/output in either ANSI/OEM code (SBCS/DBCS) or Unicode depends on the configuration options. The type of arguments that specifies the file names are defined as <tt>TCHAR</tt> which is an alias of <tt>char</tt> in default. The code set of the file name string is the ANSI/OEM code set specifid by <tt>_CODE_PAGE</tt>. When <tt>_LFN_UNICODE</tt> is set to 1 under LFN configuration, the type of the <tt>TCHAR</tt> is switched to <tt>unsigned short</tt> (UCS-2 character) to support Unicode. In this case, the LFN feature is fully supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name. It also affects data types and encoding of the string I/O functions. To define literal strings, <tt>_T(s)</tt> and <tt>_TEXT(s)</tt> macro are available to select either ANSI/OEM or Unicode automatically. The code shown below is an example to define the literal strings.</p>
<pre>
f_open(fp, "filename.txt", FA_READ); <span>/* ANSI/OEM only */</span>
f_open(fp, L"filename.txt", FA_READ); <span>/* Unicode only */</span>
f_open(fp, _T("filename.txt"), FA_READ); <span>/* Changed automatically */</span>
</pre>
</div> </div>
<p><br></p> <p><br></p>
@ -50,10 +55,10 @@ Example: Logical drive 0-2 are assigned to three pri-partitions on the physical
Logical drive 3 is assigned to physical drive 1 (removable disk) Logical drive 3 is assigned to physical drive 1 (removable disk)
const PARTITION Drives[] = { const PARTITION Drives[] = {
{0, 0}, /* Logical drive 0 ==> Physical drive 0, 1st partition */ {0, 0}, <span>/* Logical drive 0 ==> Physical drive 0, 1st partition */</span>
{0, 1}, /* Logical drive 1 ==> Physical drive 0, 2nd partition */ {0, 1}, <span>/* Logical drive 1 ==> Physical drive 0, 2nd partition */</span>
{0, 2}, /* Logical drive 2 ==> Physical drive 0, 3rd partition */ {0, 2}, <span>/* Logical drive 2 ==> Physical drive 0, 3rd partition */</span>
{1, 0} /* Logical drive 3 ==> Physical drive 1 */ {1, 0} <span>/* Logical drive 3 ==> Physical drive 1 */</span>
}; };
</pre> </pre>
<p>There are some considerations when use <tt>_MULTI_PARTITION</tt> configuration.</p> <p>There are some considerations when use <tt>_MULTI_PARTITION</tt> configuration.</p>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/forward.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_forward</title> <title>FatFs - f_forward</title>
</head> </head>
@ -15,10 +16,10 @@
<p>The f_forward function reads the file data and forward it to the data streaming device.</p> <p>The f_forward function reads the file data and forward it to the data streaming device.</p>
<pre> <pre>
FRESULT f_forward ( FRESULT f_forward (
FIL* <em>FileObject</em>, /* File object */ FIL* <em>FileObject</em>, <span>/* File object */</span>
UINT (*<em>Func</em>)(const BYTE*,UINT), /* Data streaming function */ UINT (*<em>Func</em>)(const BYTE*,UINT), <span>/* Data streaming function */</span>
UINT <em>ByteToFwd</em>, /* Number of bytes to forward */ UINT <em>ByteToFwd</em>, <span>/* Number of bytes to forward */</span>
UINT* <em>ByteFwd</em> /* Number of bytes forwarded */ UINT* <em>ByteFwd</em> <span>/* Number of bytes forwarded */</span>
); );
</pre> </pre>
</div> </div>
@ -72,26 +73,26 @@ FRESULT f_forward (
<div class="para"> <div class="para">
<h4>Example (Audio playback)</h4> <h4>Example (Audio playback)</h4>
<pre> <pre>
/*-----------------------------------------------------------------------*/ <span>/*------------------------------------------------------------------------*/</span>
/* Sample code of data transfer function to be called from f_forward */ <span>/* Sample code of data transfer function to be called back from f_forward */</span>
/*-----------------------------------------------------------------------*/ <span>/*------------------------------------------------------------------------*/</span>
UINT out_stream ( /* Returns number of bytes sent or stream status */ UINT out_stream ( <span>/* Returns number of bytes sent or stream status */</span>
const BYTE *p, /* Pointer to the data block to be sent */ const BYTE *p, <span>/* Pointer to the data block to be sent */</span>
UINT btf /* &gt;0: Transfer call (Number of bytes to be sent). 0: Sense call */ UINT btf <span>/* &gt;0: Transfer call (Number of bytes to be sent). 0: Sense call */</span>
) )
{ {
UINT cnt = 0; UINT cnt = 0;
if (btf == 0) { /* Sense call */ if (btf == 0) { <span>/* Sense call */</span>
/* Return stream status (0: Busy, 1: Ready) */ <span>/* Return stream status (0: Busy, 1: Ready) */</span>
/* When once it returned ready to sense call, it must accept a byte at least */ <span>/* When once it returned ready to sense call, it must accept a byte at least */</span>
/* at subsequent transfer call, or f_forward will fail with FR_INT_ERROR. */ <span>/* at subsequent transfer call, or f_forward will fail with FR_INT_ERROR. */</span>
if (FIFO_READY) cnt = 1; if (FIFO_READY) cnt = 1;
} }
else { /* Transfer call */ else { <span>/* Transfer call */</span>
do { /* Repeat while there is any data to be sent and the stream is ready */ do { <span>/* Repeat while there is any data to be sent and the stream is ready */</span>
FIFO_PORT = *p++; FIFO_PORT = *p++;
cnt++; cnt++;
} while (cnt &lt; btf &amp;&amp; FIFO_READY); } while (cnt &lt; btf &amp;&amp; FIFO_READY);
@ -101,31 +102,33 @@ UINT out_stream ( /* Returns number of bytes sent or stream status */
} }
/*-----------------------------------------------------------------------*/ <span>/*------------------------------------------------------------------------*/</span>
/* Sample code using f_forward function */ <span>/* Sample code using f_forward function */</span>
/*-----------------------------------------------------------------------*/ <span>/*------------------------------------------------------------------------*/</span>
FRESULT play_file ( FRESULT play_file (
char *fn /* Pointer to the audio file name to be played */ char *fn <span>/* Pointer to the audio file name to be played */</span>
) )
{ {
FRESULT rc; FRESULT rc;
FIL fil; FIL fil;
UINT dmy; UINT dmy;
/* Open the audio file in read only mode */ <span>/* Open the audio file in read only mode */</span>
rc = f_open(&amp;fil, fn, FA_READ); rc = f_open(&amp;fil, fn, FA_READ);
if (rc) return rc;
/* Repeat until the file pointer reaches end of the file */ <span>/* Repeat until the file pointer reaches end of the file */</span>
while (rc == FR_OK &amp;&amp; fil.fptr &lt; fil.fsize) { while (rc == FR_OK &amp;&amp; fil.fptr &lt; fil.fsize) {
/* any other processes... */ <span>/* any other processes... */</span>
/* Fill output stream periodicaly or on-demand */ <span>/* Fill output stream periodicaly or on-demand */</span>
rc = f_forward(&amp;fil, out_stream, 1000, &amp;dmy); rc = f_forward(&amp;fil, out_stream, 1000, &amp;dmy);
} }
/* The read-only file object may be discarded without close */ <span>/* Close the file and return */</span>
f_close(&amp;fil);
return rc; return rc;
} }
</pre> </pre>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/getfree.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_getfree</title> <title>FatFs - f_getfree</title>
</head> </head>
@ -15,9 +16,9 @@
<p>The f_getfree function gets number of the free clusters.</p> <p>The f_getfree function gets number of the free clusters.</p>
<pre> <pre>
FRESULT f_getfree ( FRESULT f_getfree (
const XCHAR* <em>Path</em>, /* Root directory of the drive */ const TCHAR* <em>Path</em>, <span>/* Logical drive number */</span>
DWORD* <em>Clusters</em>, /* Pointer to the variable to store number of free clusters */ DWORD* <em>Clusters</em>, <span>/* Pointer to the variable to store number of free clusters */</span>
FATFS** <em>FileSystemObject</em> /* Pointer to pointer to file system object */ FATFS** <em>FileSystemObject</em> <span>/* Pointer to pointer to file system object */</span>
); );
</pre> </pre>
</div> </div>
@ -26,7 +27,7 @@ FRESULT f_getfree (
<h4>Parameters</h4> <h4>Parameters</h4>
<dl class="par"> <dl class="par">
<dt>Path</dt> <dt>Path</dt>
<dd>Pinter to the null-terminated string that specifies the <a href="filename.html">root directory</a> of the logical drive.</dd> <dd>Pinter to the null-terminated string that specifies the <a href="filename.html">logical drive</a>.</dd>
<dt>Clusters</dt> <dt>Clusters</dt>
<dd>Pointer to the DWORD variable to store number of free clusters.</dd> <dd>Pointer to the DWORD variable to store number of free clusters.</dd>
<dt>FileSystemObject</dt> <dt>FileSystemObject</dt>
@ -51,7 +52,7 @@ FRESULT f_getfree (
<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 partition on the drive.</dd>
</dl> </dl>
</div> </div>
@ -75,15 +76,15 @@ FRESULT f_getfree (
DWORD fre_clust, fre_sect, tot_sect; DWORD fre_clust, fre_sect, tot_sect;
/* Get drive information and free clusters */ <span>/* Get volume information and free clusters of drive 1 */</span>
res = f_getfree("/", &amp;fre_clust, &amp;fs); res = f_getfree("1:", &amp;fre_clust, &amp;fs);
if (res) die(res); if (res) die(res);
/* Get total sectors and free sectors */ <span>/* Get total sectors and free sectors */</span>
tot_sect = (fs->max_clust - 2) * fs->csize; 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) */ <span>/* Print free space in unit of KB (assuming 512 bytes/sector) */</span>
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);

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/gets.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_gets</title> <title>FatFs - f_gets</title>
</head> </head>
@ -14,10 +15,10 @@
<h2>f_gets</h2> <h2>f_gets</h2>
<p>The f_gets reads a string from the file.</p> <p>The f_gets reads a string from the file.</p>
<pre> <pre>
char* f_gets ( TCHAR* f_gets (
char* <em>Str</em>, /* Read buffer */ TCHAR* <em>Str</em>, <span>/* Read buffer */</span>
int <em>Size</em>, /* Size of the read buffer */ int <em>Size</em>, <span>/* Size of the read buffer */</span>
FIL* <em>FileObject</em> /* File object */ FIL* <em>FileObject</em> <span>/* File object */</span>
); );
</pre> </pre>
</div> </div>
@ -28,7 +29,7 @@ char* f_gets (
<dt>Str</dt> <dt>Str</dt>
<dd>Pointer to read buffer to store the read string.</dd> <dd>Pointer to read buffer to store the read string.</dd>
<dt>Size</dt> <dt>Size</dt>
<dd>Size of the read buffer.</dd> <dd>Size of the read buffer in unit of character.</dd>
<dt>FileObject</dt> <dt>FileObject</dt>
<dd>Pointer to the open file object structure.</dd> <dd>Pointer to the open file object structure.</dd>
</dl> </dl>
@ -43,7 +44,8 @@ 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 the file or the buffer is filled with <tt>Size - 1</tt> characters. The read string is terminated with a <tt>'\0'</tt>. When no character to read or any error occured during read operation, f_gets() returns a null pointer. The end of file and error status can be examined with <tt>f_eof()</tt> and <tt>f_error()</tt> macros.</p>
<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the file is read in UTF-8 encoding and stored it to the buffer in UCS-2. If not the case, the file will be read in one byte per character without any code conversion.</p>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/lseek.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_lseek</title> <title>FatFs - f_lseek</title>
</head> </head>
@ -16,8 +17,8 @@
<pre> <pre>
FRESULT f_lseek ( FRESULT f_lseek (
FIL* <em>FileObject</em>, /* Pointer to the file object structure */ FIL* <em>FileObject</em>, <span>/* Pointer to the file object structure */</span>
DWORD <em>Offset</em> /* File offset in unit of byte */ DWORD <em>Offset</em> <span>/* File offset in unit of byte */</span>
); );
</pre> </pre>
</div> </div>
@ -46,17 +47,20 @@ FRESULT f_lseek (
<dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd> <dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd>
<dt>FR_INVALID_OBJECT</dt> <dt>FR_INVALID_OBJECT</dt>
<dd>The file object is invalid.</dd> <dd>The file object is invalid.</dd>
<dt>FR_NOT_ENOUGH_CORE</dt>
<dd>Insufficient size of link map table for the file.</dd>
</dl> </dl>
</div> </div>
<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 increased and the data in the expanded area is undefined. This is suitable to create a large file quickly, for fast write operation. After the f_lseek function succeeded, member fptr in the file object should be checked in order to make sure the R/W pointer has been moved correctry. In case of fptr is not the expected value, either of followings has been occured.</p> <p>The f_lseek function moves the file read/write pointer of an open file. The offset can be specified in only origin from top of the file. When an offset above the file size is specified in write mode, the file size is increased and the data in the expanded area is undefined. This is suitable to create a large file quickly, for fast write operation. After the f_lseek function succeeded, member fptr in the file object should be checked in order to make sure the read/write pointer has been moved correctry. In case of fptr is not the expected value, either of followings has been occured.</p>
<ul> <ul>
<li>End of file. The specified Offset was clipped at the file size because the file has been opened in read-only mode.</li> <li>End of file. The specified Offset was clipped at the file size because the file has been opened in read-only mode.</li>
<li>Disk full. There is insufficient free space on the volume to expand the file size.</li> <li>Disk full. There is insufficient free space on the volume to expand the file size.</li>
</ul> </ul>
<p>When <tt>_USE_FASTSEEK</tt> is set to 1 and <tt>cltbl</tt> member in the file object is not NULL, the fast seek feature is enabled. This feature enables fast backward/long seek operations without FAT access by cluster link information stored on the user defined table. The cluster link information must be created prior to do the fast seek. The required size of the table is (number of fragments + 1) * 2 items. For example, when the file is fragmented in 5, 12 items will be required to store the cluster link information. The file size cannot be expanded when the fast seek feature is enabled.</p>
</div> </div>
@ -69,35 +73,49 @@ FRESULT f_lseek (
<div class="para"> <div class="para">
<h4>Example</h4> <h4>Example</h4>
<pre> <pre>
/* Move to offset of 5000 from top of the file */ <span>/* Move to offset of 5000 from top of the file */</span>
res = f_lseek(file, 5000); res = f_lseek(file, 5000);
/* Move to end of the file to append data */ <span>/* Move to end of the file to append data */</span>
res = f_lseek(file, file-&gt;fsize); res = f_lseek(file, file-&gt;fsize);
/* Forward 3000 bytes */ <span>/* Forward 3000 bytes */</span>
res = f_lseek(file, file-&gt;fptr + 3000); res = f_lseek(file, file-&gt;fptr + 3000);
/* Rewind 2000 bytes (take care on overflow) */ <span>/* Rewind 2000 bytes (take care on overflow) */</span>
res = f_lseek(file, file-&gt;fptr - 2000); res = f_lseek(file, file-&gt;fptr - 2000);
</pre> </pre>
<pre> <pre>
/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */ <span>/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */</span>
res = f_open(file, recfile, FA_CREATE_NEW | FA_WRITE); /* Create a file */ res = f_open(file, recfile, FA_CREATE_NEW | FA_WRITE); <span>/* Create a file */</span>
res = f_lseek(file, PRE_SIZE); /* Pre-allocate clusters */ res = f_lseek(file, PRE_SIZE); <span>/* Pre-allocate clusters */</span>
if (res || file-&gt;fptr != PRE_SIZE) ... /* Check if the file size has been increased correctly */ if (res || file-&gt;fptr != PRE_SIZE) ... <span>/* Check if the file size has been increased correctly */</span>
res = f_lseek(file, DATA_START); /* Record data stream without cluster allocation delay */ res = f_lseek(file, DATA_START); <span>/* Record data stream without cluster allocation delay */</span>
... ...
res = f_truncate(file); /* Truncate unused area */ res = f_truncate(file); <span>/* Truncate unused area */</span>
res = f_lseek(file, 0); /* Put file header */ res = f_lseek(file, 0); <span>/* Put file header */</span>
... ...
res = f_close(file); res = f_close(file);
</pre> </pre>
<pre>
<span>/* Using fast seek feature */</span>
DWORD lktbl[SZ_TBL]; <span>/* Link map table buffer */</span>
res = f_lseek(&amp;file, ofs1); <span>/* This is normal seek (file.cltbl == NULL on file open) */</span>
file.cltbl = lktbl; <span>/* Enable fast seek feature */</span>
lktbl[0] = SZ_TBL; <span>/* Set table size to the first item */</span>
res = f_lseek(&amp;file, CREATE_LINKMAP); <span>/* Create cluster link map table */</span>
...
res = f_lseek(&amp;file, ofs2); <span>/* This is fast seek (file.cltbl != NULL) */</span>
</pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/mkdir.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_mkdir</title> <title>FatFs - f_mkdir</title>
</head> </head>
@ -15,7 +16,7 @@
<p>The f_mkdir function creates a new directory.</p> <p>The f_mkdir function creates a new directory.</p>
<pre> <pre>
FRESULT f_mkdir ( FRESULT f_mkdir (
const XCHAR* <em>DirName</em> /* Pointer to the directory name */ const TCHAR* <em>DirName</em> <span>/* Pointer to the directory name */</span>
); );
</pre> </pre>
</div> </div>
@ -55,7 +56,7 @@ 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 volume on the disk.</dd> <dd>There is no valid FAT volume on the drive.</dd>
</dl> </dl>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/mkfs.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_mkfs</title> <title>FatFs - f_mkfs</title>
</head> </head>
@ -15,9 +16,9 @@
<p>The f_mkfs fucntion creates a file system on the drive.</p> <p>The f_mkfs fucntion creates a file system on the drive.</p>
<pre> <pre>
FRESULT f_mkfs ( FRESULT f_mkfs (
BYTE <em>Drive</em>, /* Logical drive number */ BYTE <em>Drive</em>, <span>/* Logical drive number */</span>
BYTE <em>PartitioningRule</em>, /* Partitioning rule */ BYTE <em>PartitioningRule</em>, <span>/* Partitioning rule */</span>
WORD <em>AllocSize</em> /* Size of the allocation unit */ UINT <em>AllocSize</em> <span>/* Size of the allocation unit */</span>
); );
</pre> </pre>
</div> </div>
@ -28,9 +29,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 the first sector on the drive and then the file system is created on the partition. This is called FDISK format and used for harddisk and memory card. When 1 is given, the file system starts from the first sector without partition table. This is often called super floppy disk (SFD) format and used for floppy disk and removable disk.</dd> <dd>When 0 is given, a partition table is created into the master boot record and a primary DOS partition is created and then an FAT volume is created on the partition. This is called FDISK format and used for harddisk and memory cards. When 1 is given, the FAT volume starts from the first sector on the drive without partition table. This is called <abbr title="Super Floppy Disk">SFD</abbr> format and used for floppy disk and most optical disk.</dd>
<dt>AllocSize</dt> <dt>AllocSize</dt>
<dd>Specifies allocation unit size in number of bytes per cluster. The value must be 0 or power of 2 in range of from 512 to 32768. When 0 is specified, the cluster size is determined depends on the volume size. FAT64 (64KB/cluster on FAT16) cannot be created by this function.</dd> <dd>Force the allocation unit (cluter) size in unit of byte. The value must be power of 2 and between the sector size and 128 times sector size. When invalid value is specified, the cluster size is determined depends on the volume size.</dd>
</dl> </dl>
</div> </div>
@ -62,8 +63,8 @@ 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 an FAT volume on the drive. There are two partitioning rules, FDISK and SFD, for removable media. The FDISK format is recommended for the most case. This function currently <em>does not support multiple partition</em>, so that existing partitions on the physical dirve will be deleted and re-created a new partition occupies entire disk space.</p>
<p>The FAT sub-type, FAT12/FAT16/FAT32, is determined by number of clusters on the drive and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the volume size and the specified cluster size. The cluster size affects performance of the file system and large cluster increases the performance.</p> <p>The FAT sub-type, FAT12/FAT16/FAT32, is determined by number of clusters on the volume and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the volume size and the specified cluster size. The cluster size affects performance of the file system and large cluster increases the performance.</p>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/mount.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_mount</title> <title>FatFs - f_mount</title>
</head> </head>
@ -15,8 +16,8 @@
<p>The f_mount fucntion registers/unregisters a work area to the FatFs module.</p> <p>The f_mount fucntion registers/unregisters a work area to the FatFs module.</p>
<pre> <pre>
FRESULT f_mount ( FRESULT f_mount (
BYTE <em>Drive</em>, /* Logical drive number */ BYTE <em>Drive</em>, <span>/* Logical drive number */</span>
FATFS* <em>FileSystemObject</em> /* Pointer to the work area */ FATFS* <em>FileSystemObject</em> <span>/* Pointer to the work area */</span>
); );
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/open.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_open</title> <title>FatFs - f_open</title>
</head> </head>
@ -15,9 +16,9 @@
<p>The f_open function creates a <em>file object</em> to be used to access the file.</p> <p>The f_open function creates a <em>file object</em> to be used to access the file.</p>
<pre> <pre>
FRESULT f_open ( FRESULT f_open (
FIL* <em>FileObject</em>, /* Pointer to the blank file object structure */ FIL* <em>FileObject</em>, <span>/* Pointer to the blank file object structure */</span>
const XCHAR* <em>FileName</em>, /* Pointer to the file neme */ const TCHAR* <em>FileName</em>, <span>/* Pointer to the file neme */</span>
BYTE <em>ModeFlags</em> /* Mode flags */ BYTE <em>ModeFlags</em> <span>/* Mode flags */</span>
); );
</pre> </pre>
</div> </div>
@ -36,7 +37,8 @@ FRESULT f_open (
<tr><td>FA_READ</td><td>Specifies read access to the object. Data can be read from the file.<br>Combine with FA_WRITE for read-write access.</td></tr> <tr><td>FA_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, a new file is created.</td></tr> <tr><td>FA_OPEN_ALWAYS</td><td>Opens the file if it is existing. If not, a new file is created.<br>
To append data to the file, use f_lseek function after file open in this method.</td></tr>
<tr><td>FA_CREATE_NEW</td><td>Creates a new file. The function fails if the file is already existing.</td></tr> <tr><td>FA_CREATE_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>
@ -62,9 +64,9 @@ FRESULT f_open (
<dd>The file is already existing.</dd> <dd>The file is already existing.</dd>
<dt>FR_DENIED</dt> <dt>FR_DENIED</dt>
<dd>The required access was denied due to one of the following reasons: <dd>The required access was denied due to one of the following reasons:
<ul><li>Write mode open of a read-only file.</li> <ul><li>Write mode open against a read-only file.</li>
<li>File cannot be created due to a read-only file or same name directory is existing.</li> <li>File cannot be created due to a read-only file or same directory name is existing.</li>
<li>File cannot be created due to the directory table or disk is full.</li></ul></dd> <li>File cannot be created due to the directory table or volume is full.</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>
@ -76,21 +78,23 @@ 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 volume on the disk.</dd> <dd>There is no valid FAT volume on the drive.</dd>
<dt>FR_LOCKED</dt>
<dd>The function was rejected due to file shareing policy.</dd>
</dl> </dl>
</div> </div>
<div class="para"> <div class="para">
<h4>Description</h4> <h4>Description</h4>
<p>A file object is created when the function succeeded. The file object is used for subsequent read/write functions to refer to the file. When close an open file object, use <a href="close.html">f_close</a> function. If the modified file is not closed, the file may be collapsed.</p> <p>A file object is created when the function succeeded. The file object is used for subsequent read/write functions to refer to the file. When close an open file object, use <a href="close.html">f_close</a> function. If the modified file is not closed, the file data can be collapsed.</p>
<p>Before using any file function, a work area (file system object) must be given to the logical drive with <a href="mount.html">f_mount</a> function. All file functions can work after this procedure.</p> <p>Before using any file function, a work area (file system object) must be given to the logical drive with <a href="mount.html">f_mount</a> function. All file functions can work after this procedure.</p>
</div> </div>
<div class="para"> <div class="para">
<h4>QuickInfo</h4> <h4>QuickInfo</h4>
<p>Always available. The mode flags, <tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>, are not available when <tt>_FS_READONLY == 1</tt>.</p> <p>Always available. The mode flags, <tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW and FA_OPEN_ALWAYS</tt>, are not available when <tt>_FS_READONLY == 1</tt>.</p>
</div> </div>
@ -99,38 +103,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]; <span>/* Work area (file system object) for logical drives */</span>
FIL fsrc, fdst; /* file objects */ FIL fsrc, fdst; <span>/* file objects */</span>
BYTE buffer[4096]; /* file copy buffer */ BYTE buffer[4096]; <span>/* file copy buffer */</span>
FRESULT res; /* FatFs function common result code */ FRESULT res; <span>/* FatFs function common result code */</span>
UINT br, bw; /* File R/W count */ UINT br, bw; <span>/* File read/write count */</span>
/* Register work area for logical drives */ <span>/* Register work area for logical drives */</span>
f_mount(0, &amp;fs[0]); f_mount(0, &amp;fs[0]);
f_mount(1, &amp;fs[1]); f_mount(1, &amp;fs[1]);
/* Open source file on the drive 1 */ <span>/* Open source file on the drive 1 */</span>
res = f_open(&amp;fsrc, "1:srcfile.dat", FA_OPEN_EXISTING | FA_READ); res = f_open(&amp;fsrc, "1:srcfile.dat", FA_OPEN_EXISTING | FA_READ);
if (res) die(res); if (res) die(res);
/* Create destination file on the drive 0 */ <span>/* Create destination file on the drive 0 */</span>
res = f_open(&amp;fdst, "0:dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE); res = f_open(&amp;fdst, "0:dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE);
if (res) die(res); if (res) die(res);
/* Copy source to destination */ <span>/* Copy source to destination */</span>
for (;;) { for (;;) {
res = f_read(&amp;fsrc, buffer, sizeof(buffer), &amp;br); res = f_read(&amp;fsrc, buffer, sizeof(buffer), &amp;br); <span>/* Read a chunk of src file */</span>
if (res || br == 0) break; /* error or eof */ if (res || br == 0) break; <span>/* error or eof */</span>
res = f_write(&amp;fdst, buffer, br, &amp;bw); res = f_write(&amp;fdst, buffer, br, &amp;bw); <span>/* Write it to the dst file */</span>
if (res || bw &lt; br) break; /* error or disk full */ if (res || bw &lt; br) break; <span>/* error or disk full */</span>
} }
/* Close open files */ <span>/* Close open files */</span>
f_close(&amp;fsrc); f_close(&amp;fsrc);
f_close(&amp;fdst); f_close(&amp;fdst);
/* Unregister work area prior to discard it */ <span>/* Unregister work area prior to discard it */</span>
f_mount(0, NULL); f_mount(0, NULL);
f_mount(1, NULL); f_mount(1, NULL);
} }

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/opendir.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_opendir</title> <title>FatFs - f_opendir</title>
</head> </head>
@ -15,8 +16,8 @@
<p>The f_opendir function opens a directory.</p> <p>The f_opendir function opens a directory.</p>
<pre> <pre>
FRESULT f_opendir ( FRESULT f_opendir (
DIR* <em>DirObject</em>, /* Pointer to the blank directory object structure */ DIR* <em>DirObject</em>, <span>/* Pointer to the blank directory object structure */</span>
const XCHAR* <em>DirName</em> /* Pointer to the directory name */ const TCHAR* <em>DirName</em> <span>/* Pointer to the directory name */</span>
); );
</pre> </pre>
</div> </div>
@ -52,7 +53,7 @@ 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 volume on the disk.</dd> <dd>There is no valid FAT volume on the drive.</dd>
</dl> </dl>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/printf.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_printf</title> <title>FatFs - f_printf</title>
</head> </head>
@ -15,8 +16,8 @@
<p>The f_printf function writes formatted string to the file.</p> <p>The f_printf function writes formatted string to the file.</p>
<pre> <pre>
int f_printf ( int f_printf (
FIL* <em>FileObject</em>, /* File object */ FIL* <em>FileObject</em>, <span>/* File object */</span>
const char* <em>Foramt</em>, /* Format stirng */ const TCHAR* <em>Foramt</em>, <span>/* Format stirng */</span>
... ...
); );
</pre> </pre>
@ -28,7 +29,7 @@ int f_printf (
<dt>FileObject</dt> <dt>FileObject</dt>
<dd>Pointer to the open file object structure.</dd> <dd>Pointer to the open file object structure.</dd>
<dt>Format</dt> <dt>Format</dt>
<dd>Pointer to the null-terminated format string.</dd> <dd>Pointer to the null terminated format string.</dd>
<dt>...</dt> <dt>...</dt>
<dd>Optional arguments.</dd> <dd>Optional arguments.</dd>
@ -38,7 +39,7 @@ int f_printf (
<div class="para"> <div class="para">
<h4>Return Values</h4> <h4>Return Values</h4>
<p>When the function succeeded, number of characters written is returned. When the function failed due to disk full or any error, an <tt>EOF</tt> will be returned.</p> <p>When the function succeeded, number of characters written is returned. When the function failed due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
</div> </div>
@ -46,8 +47,8 @@ int f_printf (
<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 shown as follos:</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>
<ul> <ul>
<li>Type: <tt>c s d u X</tt></li> <li>Type: <tt>c C s S d D u U x X b B</tt></li>
<li>Size: <tt>l</tt></li> <li>Size: <tt>l L</tt></li>
<li>Flag: <tt>0</tt></li> <li>Flag: <tt>0</tt></li>
</ul> </ul>
</div> </div>
@ -56,18 +57,20 @@ int f_printf (
<div class="para"> <div class="para">
<h4>QuickInfo</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 output are converted to <tt>"\r\n"</tt>.</p> <p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\n'</tt>s contained in the output are converted to <tt>"\r\n"</tt>.</p>
<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the generated UCS-2 characters are written to the file in UTF-8 encoding. If not the case, the byte characters will be written directly.</p>
</div> </div>
<div class="para"> <div class="para">
<h4>Example</h4> <h4>Example</h4>
<pre> <pre>
f_printf(&amp;fil, "%6d", -200); /* " -200" */ f_printf(&amp;fil, "%6d", -200); <span>/* " -200" */</span>
f_printf(&amp;fil, "%02u", 5); /* "05" */ f_printf(&amp;fil, "%02u", 5); <span>/* "05" */</span>
f_printf(&amp;fil, "%ld", 12345678L); /* "12345678" */ f_printf(&amp;fil, "%ld", 12345678L); <span>/* "12345678" */</span>
f_printf(&amp;fil, "%08lX", 1194684UL); /* "00123ABC" */ f_printf(&amp;fil, "%08lX", 1194684UL); <span>/* "00123ABC" */</span>
f_printf(&amp;fil, "%s", "String"); /* "String" */ f_printf(&amp;fil, "%08b", 0x55); <span>/* "01010101" */</span>
f_printf(&amp;fil, "%c", 'a'); /* "a" */ f_printf(&amp;fil, "%s", "String"); <span>/* "String" */</span>
f_printf(&amp;fil, "%c", 'a'); <span>/* "a" */</span>
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/putc.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_putc</title> <title>FatFs - f_putc</title>
</head> </head>
@ -15,8 +16,8 @@
<p>The f_putc funciton puts a character to the file.</p> <p>The f_putc funciton puts a character to the file.</p>
<pre> <pre>
int f_putc ( int f_putc (
int <em>Chr</em>, /* A character to put */ TCHAR <em>Chr</em>, <span>/* A character to put */</span>
FIL* <em>FileObject</em> /* File object */ FIL* <em>FileObject</em> <span>/* File object */</span>
); );
</pre> </pre>
</div> </div>
@ -34,7 +35,8 @@ int f_putc (
<div class="para"> <div class="para">
<h4>Return Values</h4> <h4>Return Values</h4>
<p>When the character was written successfuly, the function returns the character. When the function failed due to disk full or any error, an <tt>EOF</tt> will be returned.</p> <p>When the character was written successfuly, the function returns the character. When the function failed due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the UCS-2 character is written to the file in UTF-8 encoding. If not the case, the byte will be written directly.</p>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/puts.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_puts</title> <title>FatFs - f_puts</title>
</head> </head>
@ -15,8 +16,8 @@
<p>The f_puts function writes a string to the file.</p> <p>The f_puts function writes a string to the file.</p>
<pre> <pre>
int f_puts ( int f_puts (
const char* <em>Str</em>, /* String */ const TCHAR* <em>Str</em>, <span>/* String */</span>
FIL* <em>FileObject</em> /* File object */ FIL* <em>FileObject</em> <span>/* File object */</span>
); );
</pre> </pre>
</div> </div>
@ -34,7 +35,8 @@ 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 that is not minus value is returned. When the function failed due to disk full or any error, an <tt>EOF</tt> will be returned.</p> <p>When the function succeeded, number of characters written that is not minus value is returned. When the function failed due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
<p>When the FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), the UCS-2 string is written to the file in UTF-8 encoding. If not the case, the byte stream will be written directly.</p>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/read.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_read</title> <title>FatFs - f_read</title>
</head> </head>
@ -15,10 +16,10 @@
<p>The f_read function reads data from a file.</p> <p>The f_read function reads data from a file.</p>
<pre> <pre>
FRESULT f_read ( FRESULT f_read (
FIL* <em>FileObject</em>, /* Pointer to the file object structure */ FIL* <em>FileObject</em>, <span>/* Pointer to the file object structure */</span>
void* <em>Buffer</em>, /* Pointer to the buffer to store read data */ void* <em>Buffer</em>, <span>/* Pointer to the buffer to store read data */</span>
UINT <em>ByteToRead</em>, /* Number of bytes to read */ UINT <em>ByteToRead</em>, <span>/* Number of bytes to read */</span>
UINT* <em>ByteRead</em> /* Pointer to the variable to return number of bytes read */ UINT* <em>ByteRead</em> <span>/* Pointer to the variable to return number of bytes read */</span>
); );
</pre> </pre>
</div> </div>
@ -59,7 +60,7 @@ 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 the end of file. In case of <tt>*ByteRead &lt; ByteToRead</tt>, it means the R/W pointer reached end of the file during read operation.</p> <p>The file pointer of the file object increases in number of bytes read. After the function succeeded, <tt>*ByteRead</tt> should be checked to detect the end of file. In case of <tt>*ByteRead &lt; ByteToRead</tt>, it means the read/write pointer reached end of the file during read operation.</p>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/readdir.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_readdir</title> <title>FatFs - f_readdir</title>
</head> </head>
@ -15,8 +16,8 @@
<p>The f_readdir function reads directory entries.</p> <p>The f_readdir function reads directory entries.</p>
<pre> <pre>
FRESULT f_readdir ( FRESULT f_readdir (
DIR* <em>DirObject</em>, /* Pointer to the open directory object */ DIR* <em>DirObject</em>, <span>/* Pointer to the open directory object */</span>
FILINFO* <em>FileInfo</em> /* Pointer to the file information structure */ FILINFO* <em>FileInfo</em> <span>/* Pointer to the file information structure */</span>
); );
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/rename.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_rename</title> <title>FatFs - f_rename</title>
</head> </head>
@ -15,8 +16,8 @@
<p>Renames an object.</p> <p>Renames an object.</p>
<pre> <pre>
FRESULT f_rename ( FRESULT f_rename (
const XCHAR* <em>OldName</em>, /* Pointer to old object name */ const TCHAR* <em>OldName</em>, <span>/* Pointer to old object name */</span>
const XCHAR* <em>NewName</em> /* Pointer to new object name */ const TCHAR* <em>NewName</em> <span>/* Pointer to new object name */</span>
); );
</pre> </pre>
</div> </div>
@ -60,7 +61,9 @@ 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 volume on the disk.</dd> <dd>There is no valid FAT volume on the drive.</dd>
<dt>FR_LOCKED</dt>
<dd>The function was rejected due to file shareing policy.</dd>
</dl> </dl>
</div> </div>
@ -80,10 +83,10 @@ FRESULT f_rename (
<div class="para"> <div class="para">
<h4>Example</h4> <h4>Example</h4>
<pre> <pre>
/* Rename an object */ <span>/* Rename an object */</span>
f_rename("oldname.txt", "newname.txt"); f_rename("oldname.txt", "newname.txt");
/* Rename and move an object to other directory */ <span>/* Rename and move an object to other directory */</span>
f_rename("oldname.txt", "dir1/newname.txt"); f_rename("oldname.txt", "dir1/newname.txt");
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/sdir.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - DIR</title> <title>FatFs - DIR</title>
</head> </head>
@ -14,18 +15,18 @@
<h2>DIR</h2> <h2>DIR</h2>
<p>The <tt>DIR</tt> structure is used for the work area to read a directory by f_oepndir, f_readdir function. There is no member that can be changed by application.</p> <p>The <tt>DIR</tt> structure is used for the work area to read a directory by f_oepndir, f_readdir function. There is no member that can be changed by application.</p>
<pre> <pre>
typedef struct _DIR_ { typedef struct {
FATFS* fs; /* Pointer to the owner file system object */ FATFS* fs; <span>/* Pointer to the owner file system object */</span>
WORD id; /* Owner file system mount ID */ WORD id; <span>/* Owner file system mount ID */</span>
WORD index; /* Current read/write index number */ WORD index; <span>/* Directory index number to be read/write next */</span>
DWORD sclust; /* Table start cluster (0:Static table) */ DWORD sclust; <span>/* Table start cluster (0:Root dir) */</span>
DWORD clust; /* Current cluster */ DWORD clust; <span>/* Current cluster */</span>
DWORD sect; /* Current sector */ DWORD sect; <span>/* Current sector */</span>
BYTE* dir; /* Pointer to the current SFN entry in the win[] */ BYTE* dir; <span>/* Pointer to the current SFN entry in the win[] */</span>
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ BYTE* fn; <span>/* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */</span>
#if _USE_LFN #if _USE_LFN
WCHAR* lfn; /* Pointer to the LFN working buffer */ WCHAR* lfn; <span>/* Pointer to the LFN working buffer */</span>
WORD lfn_idx; /* Last matched LFN index (0xFFFF:No LFN) */ WORD lfn_idx; <span>/* Last matched LFN index (0xFFFF:No LFN) */</span>
#endif #endif
} DIR; } DIR;
</pre> </pre>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/sfatfs.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FATFS</title> <title>FatFs - FATFS</title>
</head> </head>
@ -14,36 +15,36 @@
<h2>FATFS</h2> <h2>FATFS</h2>
<p>The <tt>FATFS</tt> structure holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with f_mount function. Following members are in standard configuration. There is no member that can be changed from the application program.</p> <p>The <tt>FATFS</tt> structure holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with f_mount function. Following members are in standard configuration. There is no member that can be changed from the application program.</p>
<pre> <pre>
typedef struct _FATFS_ { typedef struct {
BYTE fs_type; /* FAT sub type */ BYTE fs_type; <span>/* FAT sub-type (0:Not mounted) */</span>
BYTE drive; /* Physical drive number */ BYTE drv; <span>/* Physical drive number */</span>
BYTE csize; /* Number of sectors per cluster */ BYTE csize; <span>/* Sectors per cluster (1,2,4...128) */</span>
BYTE n_fats; /* Number of FAT copies */ BYTE n_fats; <span>/* Number of FAT copies (1,2) */</span>
BYTE wflag; /* win[] dirty flag (1:must be written back) */ BYTE wflag; <span>/* win[] dirty flag */</span>
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */ BYTE fsi_flag; <span>/* fsinfo dirty flag */</span>
WORD id; /* File system mount ID */ WORD id; <span>/* File system mount ID */</span>
WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */ WORD n_rootdir; <span>/* Number of root directory entries (FAT12/16) */</span>
#if _FS_REENTRANT
_SYNC_t sobj; /* Identifier of sync object */
#endif
#if _MAX_SS != 512 #if _MAX_SS != 512
WORD s_size; /* Sector size */ WORD ssize; <span>/* Sector size (512,1024,2048,4096) */</span>
#endif
#if _FS_REENTRANT
_SYNC_t sobj; <span>/* Identifier of sync object */</span>
#endif #endif
#if !_FS_READONLY #if !_FS_READONLY
DWORD last_clust; /* Last allocated cluster */ DWORD last_clust; <span>/* Last allocated cluster */</span>
DWORD free_clust; /* Number of free clusters */ DWORD free_clust; <span>/* Number of free clusters */</span>
DWORD fsi_sector; /* fsinfo sector */ DWORD fsi_sector; <span>/* fsinfo sector (FAT32) */</span>
#endif #endif
#if _FS_RPATH #if _FS_RPATH
DWORD cdir; /* Current directory (0:root)*/ DWORD cdir; <span>/* Current directory cluster (0:root) */</span>
#endif #endif
DWORD sects_fat; /* Sectors per fat */ DWORD n_fatent; <span>/* Number of FAT entries (= number of clusters + 2) */</span>
DWORD max_clust; /* Maximum cluster# + 1. Number of clusters is max_clust - 2 */ DWORD fsize; <span>/* Sectors per FAT */</span>
DWORD fatbase; /* FAT start sector */ DWORD fatbase; <span>/* FAT area start sector */</span>
DWORD dirbase; /* Root directory start sector (Cluster# on FAT32) */ DWORD dirbase; <span>/* Root directory area start sector (FAT32: cluster#) */</span>
DWORD database; /* Data start sector */ DWORD database; <span>/* Data area start sector */</span>
DWORD winsect; /* Current sector appearing in the win[] */ DWORD winsect; <span>/* Current sector appearing in the win[] */</span>
BYTE win[_MAX_SS];/* Disk access window for Directory/FAT */ BYTE win[_MAX_SS]; <span>/* Disk access window for Directory, FAT (and Data on tiny cfg) */</span>
} FATFS; } FATFS;
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/sfile.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FIL</title> <title>FatFs - FIL</title>
</head> </head>
@ -12,25 +13,31 @@
<div class="para"> <div class="para">
<h2>FIL</h2> <h2>FIL</h2>
<p>The FIL structure (file object) holds state of an open file. It is initialzed by f_open function and discarded by f_close function. There is no member that can be changed by the application program.</p> <p>The FIL structure (file object) holds state of an open file. It is created by f_open function and discarded by f_close function. There is no member that can be changed by the application program except for <tt>cltbl</tt>. Note that a sector buffer is defined in this structure under non-tiny configuration so that the FIL structures should not be defined as auto variable.</p>
<pre> <pre>
typedef struct _FIL_ { typedef struct {
FATFS* fs; /* Pointer to the owner file system object */ FATFS* fs; <span>/* Pointer to the owner file system object */</span>
WORD id; /* Owner file system mount ID */ WORD id; <span>/* Owner file system mount ID */</span>
BYTE flag; /* File status flags */ BYTE flag; <span>/* File status flags */</span>
BYTE csect; /* Sector address in the cluster */ BYTE pad1;
DWORD fptr; /* File R/W pointer */ DWORD fptr; <span>/* File read/write pointer (Byte offset origin from top of the file) */</span>
DWORD fsize; /* File size */ DWORD fsize; <span>/* File size */</span>
DWORD org_clust; /* File start cluster */ DWORD org_clust; <span>/* File start cluster */</span>
DWORD curr_clust; /* Current cluster */ DWORD curr_clust; <span>/* Current cluster */</span>
DWORD dsect; /* Current data sector */ DWORD dsect; <span>/* Current data sector */</span>
#if !_FS_READONLY #if !_FS_READONLY
DWORD dir_sect; /* Sector containing the directory entry */ DWORD dir_sect; <span>/* Sector containing the directory entry */</span>
BYTE* dir_ptr; /* Ponter to the directory entry in the window */ BYTE* dir_ptr; <span>/* Ponter to the directory entry in the window */</span>
#endif
#if _USE_FASTSEEK
DWORD* cltbl; <span>/* Pointer to the cluster link map table */</span>
#endif
#if _FS_SHARE
UINT lockid; <span>/* File lock ID */</span>
#endif #endif
#if !_FS_TINY #if !_FS_TINY
BYTE buf[_MAX_SS];/* File R/W buffer */ BYTE buf[_MAX_SS]; <span>/* Data read/write buffer */</span>
#endif #endif
} FIL; } FIL;
</pre> </pre>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/sfileinfo.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - FILINFO</title> <title>FatFs - FILINFO</title>
</head> </head>
@ -14,15 +15,15 @@
<h2>FILINFO</h2> <h2>FILINFO</h2>
<p>The <tt>FILINFO</tt> structure holds a file information returned by f_stat and f_readdir function.</p> <p>The <tt>FILINFO</tt> structure holds a file information returned by f_stat and f_readdir function.</p>
<pre> <pre>
typedef struct _FILINFO_ { typedef struct {
DWORD fsize; /* File size */ DWORD fsize; <span>/* File size */</span>
WORD fdate; /* Last modified date */ WORD fdate; <span>/* Last modified date */</span>
WORD ftime; /* Last modified time */ WORD ftime; <span>/* Last modified time */</span>
BYTE fattrib; /* Attribute */ BYTE fattrib; <span>/* Attribute */</span>
char fname[13]; /* Short file name (8.3 format) */ TCHAR fname[13]; <span>/* Short file name (8.3 format) */</span>
#if _USE_LFN #if _USE_LFN
XCHAR* lfname; /* Pointer to the LFN buffer */ TCHAR* lfname; <span>/* Pointer to the LFN buffer */</span>
int lfsize; /* Size of LFN buffer [characters] */ int lfsize; <span>/* Size of LFN buffer [characters] */</span>
#endif #endif
} FILINFO; } FILINFO;
</pre> </pre>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/stat.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_stat</title> <title>FatFs - f_stat</title>
</head> </head>
@ -15,8 +16,8 @@
<p>The f_stat gets the file status.</p> <p>The f_stat gets the file status.</p>
<pre> <pre>
FRESULT f_stat ( FRESULT f_stat (
const XCHAR* <em>FileName</em>, /* Pointer to the file or directory name */ const TCHAR* <em>FileName</em>, <span>/* Pointer to the file or directory name */</span>
FILINFO* <em>FileInfo</em> /* Pointer to the FILINFO structure */ FILINFO* <em>FileInfo</em> <span>/* Pointer to the FILINFO structure */</span>
); );
</pre> </pre>
</div> </div>
@ -54,7 +55,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 volume on the disk.</dd> <dd>There is no valid FAT volume on the drive.</dd>
</dl> </dl>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/sync.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_sync</title> <title>FatFs - f_sync</title>
</head> </head>
@ -15,7 +16,7 @@
<p>The f_sync function flushes the cached information of a writing file.</p> <p>The f_sync function flushes the cached information of a writing file.</p>
<pre> <pre>
FRESULT f_sync ( FRESULT f_sync (
FIL* <em>FileObject</em> /* Pointer to the file object */ FIL* <em>FileObject</em> <span>/* Pointer to the file object */</span>
); );
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/truncate.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_truncate</title> <title>FatFs - f_truncate</title>
</head> </head>
@ -15,7 +16,7 @@
<p>The f_truncate function truncates the file size.</p> <p>The f_truncate function truncates the file size.</p>
<pre> <pre>
FRESULT f_truncate ( FRESULT f_truncate (
FIL* <em>FileObject</em> /* Pointer to the file object */ FIL* <em>FileObject</em> <span>/* Pointer to the file object */</span>
); );
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/unlink.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_unlink</title> <title>FatFs - f_unlink</title>
</head> </head>
@ -15,7 +16,7 @@
<p>The f_unlink removes an object.</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 object name */ const TCHAR* <em>FileName</em> <span>/* Pointer to the object name */</span>
); );
</pre> </pre>
</div> </div>
@ -56,7 +57,9 @@ 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 volume on the disk.</dd> <dd>There is no valid FAT volume on the drive.</dd>
<dt>FR_LOCKED</dt>
<dd>The function was rejected due to file shareing policy.</dd>
</dl> </dl>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/utime.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_utime</title> <title>FatFs - f_utime</title>
</head> </head>
@ -15,8 +16,8 @@
<p>The f_utime function changes the timestamp of a file or directory.</p> <p>The f_utime function changes the timestamp of a file or directory.</p>
<pre> <pre>
FRESULT f_utime ( FRESULT f_utime (
const XCHAR* <em>FileName</em>, /* Pointer to the file or directory path */ const TCHAR* <em>FileName</em>, <span>/* Pointer to the file or directory path */</span>
const FILINFO* <em>TimeDate</em> /* Time and data to be set */ const FILINFO* <em>TimeDate</em> <span>/* Time and data to be set */</span>
); );
</pre> </pre>
</div> </div>
@ -56,7 +57,7 @@ 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 volume on the disk.</dd> <dd>There is no valid FAT volume on the drive.</dd>
</dl> </dl>
</div> </div>
@ -67,6 +68,30 @@ FRESULT f_utime (
</div> </div>
<div class="para">
<h4>Example</h4>
<pre>
FRESULT set_timestamp (
char *obj, <span>/* Pointer to the file name */</span>
int year,
int month,
int mday,
int hour,
int min,
int sec
)
{
FILINFO fno;
fno.fdate = (WORD)(((year - 1980) * 512U) | month * 32U | mday);
fno.ftime = (WORD)(hour * 2048U | min * 32U | sec / 2U);
return f_utime(obj, &fno);
}
</pre>
</div>
<div class="para"> <div class="para">
<h4>QuickInfo</h4> <h4>QuickInfo</h4>
<p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p> <p>Available when <tt>_FS_READONLY == 0</tt> and <tt>_FS_MINIMIZE == 0</tt>.</p>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_e.html"> <link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/write.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_write</title> <title>FatFs - f_write</title>
</head> </head>
@ -15,10 +16,10 @@
<p>The f_write writes data to a file.</p> <p>The f_write writes data to a file.</p>
<pre> <pre>
FRESULT f_write ( FRESULT f_write (
FIL* <em>FileObject</em>, /* Pointer to the file object structure */ FIL* <em>FileObject</em>, <span>/* Pointer to the file object structure */</span>
const void* <em>Buffer</em>, /* Pointer to the data to be written */ const void* <em>Buffer</em>, <span>/* Pointer to the data to be written */</span>
UINT <em>ByteToWrite</em>, /* Number of bytes to write */ UINT <em>ByteToWrite</em>, <span>/* Number of bytes to write */</span>
UINT* <em>ByteWritten</em> /* Pointer to the variable to return number of bytes written */ UINT* <em>ByteWritten</em> <span>/* Pointer to the variable to return number of bytes written */</span>
); );
</pre> </pre>
</div> </div>
@ -59,7 +60,7 @@ FRESULT f_write (
<div class="para"> <div class="para">
<h4>Description</h4> <h4>Description</h4>
<p>The R/W pointer in the file object is increased in number of bytes written. After the function succeeded, <tt>*ByteWritten</tt> should be checked to detect the disk full. In case of <tt>*ByteWritten &lt; ByteToWrite</tt>, it means the volume got full during the write operation.</p> <p>The read/write pointer in the file object is increased in number of bytes written. After the function succeeded, <tt>*ByteWritten</tt> should be checked to detect the disk full. In case of <tt>*ByteWritten &lt; ByteToWrite</tt>, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.</p>
</div> </div>

View File

@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/appnote.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>FatFsモジュール アプリケーション・ノート</title> <title>FatFsモジュール アプリケーション・ノート</title>
</head> </head>
@ -27,8 +28,8 @@ FatFsモジュールはANSI C準拠で記述されているので、ANSI C準拠
<h3>ポーティングのしかた</h3> <h3>ポーティングのしかた</h3>
<p>必要なのは FatFsモジュールの要求するディスク関数を用意することだけで、それ以外にすることはありません。既に動作しているディスク関数があるならその APIを FatFsに合わせるだけで済みますが、無い場合はほかから移植するか、最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード・オンリー構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。</p> <p>必要なのは FatFsモジュールの要求するディスク関数を用意することだけで、それ以外にすることはありません。既に動作しているディスク関数があるならその APIを FatFsに合わせるだけで済みますが、無い場合はほかから移植するか、最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード・オンリー構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。</p>
<table class="lst2"> <table class="lst2">
<tr><th>ユーザ作成関数</th><th>必要となる条件</th></tr> <tr><th>ユーザ作成関数</th><th>必要となる条件</th><th>備考</th></tr>
<tr><td>disk_initialize</td><td>常時</td></tr> <tr><td>disk_initialize</td><td>常時</td><td rowspan="9">ffsample.zip (サンプル)<br>その他web上に多数</td></tr>
<tr><td>disk_status</td><td>常時</td></tr> <tr><td>disk_status</td><td>常時</td></tr>
<tr><td>disk_read</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_write</td><td>_FS_READONLY == 0</td></tr>
@ -37,6 +38,14 @@ FatFsモジュールはANSI C準拠で記述されているので、ANSI C準拠
<tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS &gt;= 1024</td></tr> <tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS &gt;= 1024</td></tr>
<tr><td>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr> <tr><td>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr>
<tr><td>get_fattime</td><td>_FS_READONLY == 0</td></tr> <tr><td>get_fattime</td><td>_FS_READONLY == 0</td></tr>
<tr><td>ff_convert</td><td>_USE_LFN &gt;= 1</td><td rowspan="2">option/cc*.c</td></tr>
<tr><td>ff_wtoupper</td><td>_USE_LFN &gt;= 1</td></tr>
<tr><td>ff_cre_syncobj</td><td>_FS_REENTRANT == 1</td><td rowspan="6">option/syscall.c (サンプル)</td></tr>
<tr><td>ff_del_syncobj</td><td>_FS_REENTRANT == 1</td></tr>
<tr><td>ff_req_grant</td><td>_FS_REENTRANT == 1</td></tr>
<tr><td>ff_rel_grant</td><td>_FS_REENTRANT == 1</td></tr>
<tr><td>ff_mem_alloc</td><td>_USE_LFN == 3</td></tr>
<tr><td>ff_mem_free</td><td>_USE_LFN == 3</td></tr>
</table> </table>
</div> </div>
@ -44,42 +53,44 @@ FatFsモジュールはANSI C準拠で記述されているので、ANSI C準拠
<h3>限界値</h3> <h3>限界値</h3>
<ul> <ul>
<li>FATタイプ: FAT12, FAT16, FAT32。</li> <li>FATタイプ: FAT12, FAT16, FAT32。</li>
<li>同時オープン・ファイル数: 無制限(利用可能メモリによる)</li> <li>同時オープン・ファイル数: 無制限(利用可能メモリによる)</li>
<li>ボリューム数: 最大 10。</li> <li>ボリューム数: 最大 10。</li>
<li>ファイル・サイズ: FAT規格に依存 (4G-1バイト)</li> <li>ファイル・サイズ: FAT規格に依存。(最大 4G-1バイト)</li>
<li>ボリューム・サイズ: FAT規格に依存 (最大 2T,4Tまたは8Tバイト)。</li> <li>ボリューム・サイズ: FAT規格に依存。(最大 2Tバイト(512バイト/セクタ時))</li>
<li>クラスタ・サイズ: 最大 64Kバイト。f_mkfs()では 32Kバイト。</li> <li>クラスタ・サイズ: FAT規格に依存。(最大 64Kバイト(512バイト/セクタ時))</li>
<li>セクタ・サイズ: FAT規格に依存 (最大 4Kバイト)。</li> <li>セクタ・サイズ: FAT規格に依存。(最大 4Kバイト)</li>
</ul> </ul>
</div> </div>
<div class="para"> <div class="para">
<h3>メモリ使用量 (R0.07e)</h3> <h3>メモリ使用量 (R0.08)</h3>
<p>次の表にいくつかのターゲットにおけるメモリ使用量の例を示します。テスト時の構成オプションはその下の通りです。数値の単位はバイトで、<em>D</em>は論理ボリューム数、<em>F</em>は同時オープン・ファイル数を示します。コンパイラの最適化オプションはコード・サイズとしています。</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>x86</th></tr> <tr><th></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>V850ES</th><th>SH-2A</th><th>ARM7</th><th>x86</th></tr>
<tr><td>Compiler</td><td>WinAVR(gcc)</td><td>CH38</td><td>C30(gcc)</td><td>CC870C</td><td>CA850</td><td>SHC</td><td>WinARM(gcc)</td><td>VC6</td></tr> <tr><td>Compiler</td><td>WinAVR(gcc)</td><td>CH38</td><td>C30(gcc)</td><td>CA850</td><td>SHC</td><td>WinARM(gcc)</td><td>VC6</td></tr>
<tr><td>_WORD_ACCESS</td><td>1</td><td>0</td><td>0</td><td>1</td><td>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>0</td><td>0</td><td>1</td></tr>
<tr class="lst3"><td>text (Full, R/W)</td><td>12194</td><td>10559</td><td>10924</td><td>15229</td><td>7686</td><td>8727</td><td>10564</td><td>7342</td></tr> <tr class="lst3"><td>text (Full, R/W)</td><td>12700</td><td>10686</td><td>11376</td><td>7730</td><td>8592</td><td>10520</td><td>7545</td></tr>
<tr> <td>text (Min, R/W)</td><td>7988</td><td>6903</td><td>7108</td><td>9960</td><td>4884</td><td>5651</td><td>6544</td><td>4764</td></tr> <tr> <td>text (Min, R/W)</td><td>8386</td><td>6980</td><td>7395</td><td>4930</td><td>5600</td><td>6636</td><td>4923</td></tr>
<tr><td>text (Full, R/O)</td><td>5532</td><td>4753</td><td>5020</td><td>6760</td><td>3462</td><td>3777</td><td>4624</td><td>3316</td></tr> <tr><td>text (Full, R/O)</td><td>6012</td><td>4874</td><td>5250</td><td>3556</td><td>3848</td><td>4656</td><td>3450</td></tr>
<tr> <td>text (Min, R/O)</td><td>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>text (Min, R/O)</td><td>4384</td><td>3774</td><td>3939</td><td>2684</td><td>2996</td><td>3416</td><td>2664</td></tr>
<tr><td>bss</td><td>D*2 + 2</td><td>D*4 + 2</td><td>D*2 + 2</td><td>D*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*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td><td>D*4 + 2</td></tr>
<tr><td>Work area<br>(_FS_TINY == 0)</td><td>D*560 +<br>F*544</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*544</td><td></td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td></tr> <tr><td>Work area<br>(_FS_TINY == 0)</td><td>D*560 +<br>F*544</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*544</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td><td>D*560 +<br>F*550</td></tr>
<tr><td>Work area<br>(_FS_TINY == 1)</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*36</td><td>D*560 +<br>F*32</td><td>D*560 +<br>F*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*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>
<pre> <pre>
_FS_READONLY 0 (R/W), 1 (R/O) _FS_READONLY 0 (R/W), 1 (R/O)
_FS_MINIMIZE 0 (Full function), 3 (Minimized function) _FS_MINIMIZE 0 (Full function), 3 (Minimized function)
_USE_STRFUNC 0 (Disable string functions) _USE_STRFUNC 0 (Disable string functions)
_USE_MKFS 0 (Disable f_mkfs function) _USE_MKFS 0 (Disable f_mkfs function)
_USE_FORWARD 0 (Disable f_forward function) _USE_FORWARD 0 (Disable f_forward function)
_USE_FASTSEEK 0 (Disable fast seek feature)
_CODE_PAGE 932 (Japanese Shift-JIS) _CODE_PAGE 932 (Japanese Shift-JIS)
_USE_LFN 0 (Disable LFN) _USE_LFN 0 (Disable LFN)
_MAX_SS 512 (Single sector size) _MAX_SS 512 (Fixed sector size)
_FS_RPATH 0 (Disable relative path) _FS_RPATH 0 (Disable relative path)
_MULTI_PARTITION 0 (Single partition per drive) _MULTI_PARTITION 0 (Single partition per drive)
_FS_REENTRANT 0 (Disable reentrancy) _FS_REENTRANT 0 (Disable reentrancy)
_FS_SHARE 0 (Disable shareing control)
</pre> </pre>
</div> </div>
@ -119,11 +130,11 @@ _FS_REENTRANT 0 (Disable reentrancy)
<div class="para"> <div class="para">
<h3>長いファイル名</h3> <h3>長いファイル名</h3>
<p>FatFsモジュールはR0.07から長いファイル名(LFN)をサポートしました。ファイルに付けられた2つの異なる名前(短いファル名と長いファイル名)は、f_readdir関数を除くファイル操作関数において透過です。LFN機能を有効にするには、<tt>_USE_LFN</tt>を1または2に設定し、Unicode変換関数 ff_convert, ff_wtoupper をプロジェクトに追加します。これらの関数は、<tt>cc*.c</tt>に含まれています。LFN機能は、加えてある程度のワーク・エリア(LFN操作バッファ)を必要とします。バッファ長は使用できるメモリに応じて<tt>_MAX_LFN</tt>オプションで構成されることができます。LFNの長さは最大255文字に達するので、LFN完全対応のためには<tt>_MAX_LFN</tt>は255に設定されるべきです。与えられたファイル名に対してバッファ長が不足した場合、ファイル関数は<tt>FR_INVALID_NAME</tt>で失敗します。</p> <p>FatFsモジュールはR0.07から長いファイル名(LFN)をサポートしました。ファイルに付けられた2つの異なる名前(短いファル名と長いファイル名)は、f_readdir関数を除くファイル操作関数において透過です。LFN機能を有効にするには、<tt>_USE_LFN</tt>を1,2または3に設定し、Unicode変換関数<tt>ff_convert(), ff_wtoupper()</tt>をプロジェクトに追加します。これらの関数は、<tt>option/cc*.c</tt>に含まれています。LFN機能は、加えてある程度のワーク・エリア(LFN操作バッファ)を必要とします。バッファ長は使用できるメモリに応じて<tt>_MAX_LFN</tt>オプションで構成されることができます。LFNの長さは最大255文字に達するので、LFN完全対応のためには<tt>_MAX_LFN</tt>は255に設定されるべきです。与えられたファイル名に対してバッファ長が不足した場合、ファイル関数は<tt>FR_INVALID_NAME</tt>で失敗します。</p>
<p>LFN機能をリエントラント構成で使用する場合は、<tt>_USE_LFN</tt>は2に設定されなければなりません。この場合、ファイル関数はバッファをスタックに確保します。バッファ・サイズは、<tt>(_MAX_LFN + 1) * 2</tt>バイトになるので、呼び出し側スタックのサイズはそれを考慮した十分なサイズでなければなりません。</p> <p>LFN機能をリエントラント構成で使用する場合は、<tt>_USE_LFN</tt>は2または3に設定されなければなりません。この場合、ファイル関数はバッファをスタックやヒープに確保します。バッファ・サイズは、<tt>(_MAX_LFN + 1) * 2</tt>バイトになるので、スタックのサイズはそれを考慮した十分なサイズでなければなりません。</p>
<table class="lst2 rset"> <table class="lst2 rset">
<caption>LFN cfg on ARM7</caption> <caption>LFN cfg on ARM7</caption>
<tr><th>コードページ</th><th>ROMサイズ[bytes]</th></tr> <tr><th>コードページ</th><th>コードサイズ[bytes]</th></tr>
<tr><td>SBCS</td><td>+3721</td></tr> <tr><td>SBCS</td><td>+3721</td></tr>
<tr><td>932(Shift-JIS)</td><td>+62609</td></tr> <tr><td>932(Shift-JIS)</td><td>+62609</td></tr>
<tr><td>936(GBK)</td><td>+177797</td></tr> <tr><td>936(GBK)</td><td>+177797</td></tr>
@ -134,17 +145,28 @@ _FS_REENTRANT 0 (Disable reentrancy)
<p>注: FATファイル・システム上のLFN機能はマイクロソフト社の特許です。商用製品でそれを有効にするときは、最終仕向地によってはライセンスが必要かも知れません。</p> <p>注: FATファイル・システム上のLFN機能はマイクロソフト社の特許です。商用製品でそれを有効にするときは、最終仕向地によってはライセンスが必要かも知れません。</p>
</div> </div>
<div class="para">
<h3>日本語ファイル名の大文字変換</h3>
<p>CP932(Shift_JIS)でかつ非LFN構成のときは、拡張文字の小文字(2バイト英字・キリル文字・ギリシャ文字)に対して大文字変換を行わず、小文字のままSFNエントリに記録・検索されます。これは日本語MSDOSと同じ仕様となります。このため、非LFN構成で全角小文字を含むファイルを作成すると、NT系Windowsでそのファイルを開けなくなります。LFN構成では大文字変換を行います(NT系Windows仕様)。</p>
</div>
<div class="para">
<h3>Unicode入出力への対応</h3>
<p>ファイル関数のファイル名入出力はデフォルトでは ANSI/OEMコードですが、これをUnicodeに切り替えることもできます。Unicodeファイル名に関する詳細は、<a href="filename.html">ファイル名</a>を参照してください。</p>
</div>
<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依存の同期オブジェクト操作関数<tt>ff_cre_syncobj, ff_del_syncobj, ff_req_grant</tt><tt>ff_rel_grant</tt>もまたプロジェクトに追加されなければなりません。サンプル・コードと解説は<tt>option/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>ひとつの例外が<tt>f_mount()</tt><tt>f_mkfs()</tt>にあります。これらの関数は同じボリュームに対してリエントラントではありません。これらの関数を使用するときは、アプリケーション・レベルで排他制御しなければなりません。</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>
<p><tt>_FS_SHARE</tt>に1以上の値をセットすることにより、ファイル単位の排他制御を自動で行うこともできます。この場合、上記のルールを破ったオープン・リネーム・削除を試みると、その関数は<tt>FR_LOCKED</tt>で失敗します。</p>
</div> </div>
<div class="para"> <div class="para">
@ -187,21 +209,11 @@ _FS_REENTRANT 0 (Disable reentrancy)
<p>いずれも書き込み中や操作対象でないファイルには影響はありません。これらのクリチカル・セクションは、ファイルを書き込みモードで開いている時間を最小限にするか、f_sync()を適宜使用することで図5のようにリスクを最小化することができます。</p> <p>いずれも書き込み中や操作対象でないファイルには影響はありません。これらのクリチカル・セクションは、ファイルを書き込みモードで開いている時間を最小限にするか、f_sync()を適宜使用することで図5のようにリスクを最小化することができます。</p>
</div> </div>
<div class="para">
<h3>日本語ファイル名の大文字変換</h3>
<p>CP932(Shift_JIS)でかつ非LFN構成のときは、拡張文字の小文字(2バイト英字・キリル文字・ギリシャ文字)に対して大文字変換を行わず、小文字のままSFNエントリに記録・検索されます。これは日本語MSDOSと同じ仕様となります。このため、全角小文字を含むファイルを作成すると、NT系Windowsでそのファイルを開けなくなります。LFN構成では大文字変換を行います(NT系Windows仕様)。</p>
</div>
<div class="para">
<h3>Unicode入出力への対応</h3>
<p>ファイル関数のファイル名入出力はデフォルトでは OEMコードですが、これをUnicodeに切り替えることもできます。詳細は、<a href="filename.html">ファイル名</a>を参照してください。</p>
</div>
<div class="para"> <div class="para">
<h3>FatFsのライセンスについて</h3> <h3>FatFsのライセンスについて</h3>
<p>ソース・ファイルのヘッダにライセンス条件が記述されているので、利用の際はそれに従うこと。英語を読めない方のために以下に日本語訳を示しておきます。</p> <p>ソース・ファイルのヘッダにライセンス条件が記述されているので、利用の際はそれに従うこと。英語を読めない方のために以下に日本語訳を示しておきます。</p>
<pre>/*----------------------------------------------------------------------------/ <pre>/*----------------------------------------------------------------------------/
/ FatFs - FAT file system module R0.07e (C)ChaN, 2009 / FatFs - FAT file system module R0.08 (C)ChaN, 2009
/-----------------------------------------------------------------------------/ /-----------------------------------------------------------------------------/
/ FatFsモジュールは、小規模な組み込みシステム向けの汎用FATファイルシステム・ / FatFsモジュールは、小規模な組み込みシステム向けの汎用FATファイルシステム・
/ モジュールです。これはフリー・ソフトウェアとして、教育・研究・開発のために / モジュールです。これはフリー・ソフトウェアとして、教育・研究・開発のために
@ -215,7 +227,7 @@ _FS_REENTRANT 0 (Disable reentrancy)
/ * ソース・コードを再配布するときは、上記の著作権表示を保持しなければなりません。 / * ソース・コードを再配布するときは、上記の著作権表示を保持しなければなりません。
/ /
/-----------------------------------------------------------------------------/</pre> /-----------------------------------------------------------------------------/</pre>
<p>要するにFatFsはタダで自由に使えるということです。ソース・コードを再配布するときは、このブロックをそのまま保持しておくこと。このようにFatFsはBSDライクなライセンスとしていますが、一つ大きな違いがあります。特に組み込み用途での利用価値を高めるため、バイナリ形式(ソース・コードを含まない形式全て)での再配布については、条件は設けていません。その場合は、FatFsおよびそのライセンス文書についてはドキュメントに明記してもしなくてもかまいません。もちろんGNU GPLプロジェクトとも共存可能です。何らかの変更を加えて再配布する際は、他のライセンス(GNU GPLかBSDライセンス)に変更することも可能です。</p> <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>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/chdir.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>FatFs - f_chdir</title> <title>FatFs - f_chdir</title>
</head> </head>
@ -15,7 +16,7 @@
<p>カレント・ディレクトリを変更します。</p> <p>カレント・ディレクトリを変更します。</p>
<pre> <pre>
FRESULT f_chdir ( FRESULT f_chdir (
const XCHAR* <em>Path</em> /* ディレクトリ名へのポインタ */ const XCHAR* <em>Path</em> <span>/* ディレクトリ名へのポインタ */</span>
); );
</pre> </pre>
</div> </div>
@ -53,7 +54,7 @@ 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>
@ -71,7 +72,7 @@ FRESULT f_chdir (
<div class="para"> <div class="para">
<h4>サンプル・コード</h4> <h4>使用例</h4>
<pre> <pre>
// カレント・ドライブのカレント・ディレクトリを変更 (ルート下のdir1へ) // カレント・ドライブのカレント・ディレクトリを変更 (ルート下のdir1へ)
f_chdir("/dir1"); f_chdir("/dir1");

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/chdrive.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>FatFs - f_chdrive</title> <title>FatFs - f_chdrive</title>
</head> </head>
@ -15,7 +16,7 @@
<p>カレント・ドライブを変更します。</p> <p>カレント・ドライブを変更します。</p>
<pre> <pre>
FRESULT f_chdrive ( FRESULT f_chdrive (
BYTE <em>Drive</em> /* 論理ドライブ番号 */ BYTE <em>Drive</em> <span>/* 論理ドライブ番号 */</span>
); );
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/chmod.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>FatFs - f_chmod</title> <title>FatFs - f_chmod</title>
</head> </head>
@ -15,9 +16,9 @@
<p>ファイルまたはディレクトリの属性を変更します。</p> <p>ファイルまたはディレクトリの属性を変更します。</p>
<pre> <pre>
FRESULT f_chmod ( FRESULT f_chmod (
const XCHAR* <em>FileName</em>, /* ファイルまたはディレクトリ名へのポインタ */ const TCHAR* <em>FileName</em>, <span>/* ファイルまたはディレクトリ名へのポインタ */</span>
BYTE <em>Attribute</em>, /* 設定値 */ BYTE <em>Attribute</em>, <span>/* 設定値 */</span>
BYTE <em>AttributeMask</em> /* 変更マスク */ BYTE <em>AttributeMask</em> <span>/* 変更マスク */</span>
); );
</pre> </pre>
</div> </div>
@ -67,7 +68,7 @@ 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>
@ -87,7 +88,7 @@ FRESULT f_chmod (
<div class="para"> <div class="para">
<h4>使用例</h4> <h4>使用例</h4>
<pre> <pre>
/* リードオンリーをセット、アーカイブをクリア、その他は変更しない */ <span>/* リードオンリーをセット、アーカイブをクリア、その他は変更しない */</span>
f_chmod("file.txt", AM_RDO, AM_RDO | AM_ARC); f_chmod("file.txt", AM_RDO, AM_RDO | AM_ARC);
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/close.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>FatFs - f_close</title> <title>FatFs - f_close</title>
</head> </head>
@ -15,7 +16,7 @@
<p>ファイルを閉じます。</p> <p>ファイルを閉じます。</p>
<pre> <pre>
FRESULT f_close ( FRESULT f_close (
FIL* <em>FileObject</em> /* ファイル・オブジェクトへのポインタ */ FIL* <em>FileObject</em> <span>/* ファイル・オブジェクトへのポインタ */</span>
); );
</pre> </pre>
</div> </div>
@ -48,7 +49,7 @@ FRESULT f_close (
<div class="para"> <div class="para">
<h4>解説</h4> <h4>解説</h4>
<p>ファイルを閉じます。書き込みの行われたファイルの場合、キャッシュされた状態R/Wバッファ上のデータ、変更されたFATやディレクトリ項目はディスクに書き戻されます。関数が正常終了すると、そのファイル・オブジェクトは無効になり、そのメモリも解放できます。読み込み専用モードで開かれたファイル・オブジェクトは、この関数によるクローズ処理を経ずに破棄することもできます。</p> <p>ファイルを閉じます。何らかの書き込みの行われたファイルの場合、キャッシュされた状態(リード/ライト・バッファ上のデータ、変更されたFATやディレクトリ項目)はディスクに書き戻されます。関数が正常終了すると、そのファイル・オブジェクトは無効になり、そのメモリも解放できます。読み込み専用モードで開かれたファイル・オブジェクトは、この関数によるクローズ処理を経ずに破棄することもできますが、推奨はされません</p>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/dinit.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>FatFs - disk_initialize</title> <title>FatFs - disk_initialize</title>
</head> </head>
@ -15,7 +16,7 @@
<p>ディスク・ドライブを初期化します。</p> <p>ディスク・ドライブを初期化します。</p>
<pre> <pre>
DSTATUS disk_initialize ( DSTATUS disk_initialize (
BYTE <em>Drive</em> /* 物理ドライブ番号 */ BYTE <em>Drive</em> <span>/* 物理ドライブ番号 */</span>
); );
</pre> </pre>
</div> </div>
@ -37,7 +38,7 @@ DSTATUS disk_initialize (
<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> <p>FatFsモジュールは、自動マウント動作により必要に応じてこの関数を呼び出します。<em>アプリケーションからこの関数を呼び出してはなりません。さもないと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>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/dioctl.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>FatFs - disk_ioctl</title> <title>FatFs - disk_ioctl</title>
</head> </head>
@ -15,9 +16,9 @@
<p>セクタの読み書き以外のディスク・ドライブ自体に対する様々な制御をします。</p> <p>セクタの読み書き以外のディスク・ドライブ自体に対する様々な制御をします。</p>
<pre> <pre>
DRESULT disk_ioctl ( DRESULT disk_ioctl (
BYTE <em>Drive</em>, /* 物理ドライブ番号 */ BYTE <em>Drive</em>, <span>/* 物理ドライブ番号 */</span>
BYTE <em>Command</em>, /* 制御コマンド */ BYTE <em>Command</em>, <span>/* 制御コマンド */</span>
void* <em>Buffer</em> /* データ受け渡しバッファ */ void* <em>Buffer</em> <span>/* データ受け渡しバッファ */</span>
); );
</pre> </pre>
</div> </div>
@ -54,10 +55,10 @@ DRESULT disk_ioctl (
<p>この関数はリード・オンリー構成では必要とされません。</p> <p>この関数はリード・オンリー構成では必要とされません。</p>
<table class="lst"> <table class="lst">
<tr><th>コマンド</th><th>解説</th></tr> <tr><th>コマンド</th><th>解説</th></tr>
<tr><td>CTRL_SYNC</td><td>ドライブがデータの書き込みを完了するのを待ちます。ライト・バック・キャッシュがある場合は、書き込まれていないデータを即時書き戻します。</td></tr> <tr><td>CTRL_SYNC</td><td>ドライブがデータの書き込み処理を完了するのを待ちます。また、ライト・バック・キャッシュが存在する場合は、書き込まれていないデータを即時書き戻します。</td></tr>
<tr><td>GET_SECTOR_SIZE</td><td>Bufferの指すWORD変数にドライブのセクタ・サイズを返します。_MAX_SSが1024以上のとき必要とされます</td></tr> <tr><td>GET_SECTOR_SIZE</td><td><tt>Buffer</tt>の指すWORD変数にドライブのセクタ・サイズを返します。セクタサイズが固定(_MAX_SSが512)のときはこのコマンドは必要ありません</td></tr>
<tr><td>GET_SECTOR_COUNT</td><td>Bufferの指すDWORD変数にドライブ上の総セクタ数を返します。f_mkfs内でのみ使用</td></tr> <tr><td>GET_SECTOR_COUNT</td><td><tt>Buffer</tt>の指すDWORD変数にドライブ上の総セクタ数を返します。f_mkfs関数内で作成するボリュームのサイズを決定するために使用されます</td></tr>
<tr><td>GET_BLOCK_SIZE</td><td>Bufferの指すDWORD変数にメモリ・アレーの消去ブロックサイズをセクタ単位で返します。不明な場合またはHDDでは1を返します。f_mkfs内でのみ使用</td></tr> <tr><td>GET_BLOCK_SIZE</td><td>フラッシュ・メモリ・アレーの消去ブロック・サイズが分かる場合は、<tt>Buffer</tt>の指すDWORD変数にそれをセクタ単位で返します。1から32768でかつ2の累乗の値でなければなりません。f_mkfs関数内でのみ使用され、データ領域はこの境界にアライメントされます。不明な場合またはディスク・ドライブでは1を返します</td></tr>
</table> </table>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/dread.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>FatFs - disk_read</title> <title>FatFs - disk_read</title>
</head> </head>
@ -15,10 +16,10 @@
<p>ディスクからセクタを読み出します。</p> <p>ディスクからセクタを読み出します。</p>
<pre> <pre>
DRESULT disk_read ( DRESULT disk_read (
BYTE <em>Drive</em>, /* 物理ドライブ番号 */ BYTE <em>Drive</em>, <span>/* 物理ドライブ番号 */</span>
BYTE* <em>Buffer</em>, /* 読み出しバッファへのポインタ */ BYTE* <em>Buffer</em>, <span>/* 読み出しバッファへのポインタ */</span>
DWORD <em>SectorNumber</em>, /* 読み出し開始セクタ番号 */ DWORD <em>SectorNumber</em>, <span>/* 読み出し開始セクタ番号 */</span>
BYTE <em>SectorCount</em> /* 読み出しセクタ数 */ BYTE <em>SectorCount</em> <span>/* 読み出しセクタ数 */</span>
); );
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/dstat.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>FatFs - disk_status</title> <title>FatFs - disk_status</title>
</head> </head>
@ -15,7 +16,7 @@
<p>ディスク・ドライブの状態を取得します。</p> <p>ディスク・ドライブの状態を取得します。</p>
<pre> <pre>
DSTATUS disk_status ( DSTATUS disk_status (
BYTE <em>Drive</em> /* 物理ドライブ番号 */ BYTE <em>Drive</em> <span>/* 物理ドライブ番号 */</span>
); );
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/dwrite.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>FatFs - disk_write</title> <title>FatFs - disk_write</title>
</head> </head>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/fattime.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>FatFs - get_fattime</title> <title>FatFs - get_fattime</title>
</head> </head>

View File

@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css"> <meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/filename.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>FatFs - ファイル・ディレクトリの指定方法</title> <title>FatFs - ファイル・ディレクトリの指定方法</title>
</head> </head>
@ -12,10 +13,9 @@
<div class="para"> <div class="para">
<h2>ファイル・ディレクトリの指定方法</h2> <h2>ファイル・ディレクトリの指定方法</h2>
<p>FatFsモジュールでのファイル、ディレクトリ、ドライブの指定方法はDOS/Windowsとほぼ同じです。パス名のフォーマットは次の通りです。</p> <p>FatFsモジュールでのファイル、ディレクトリ、ドライブの指定方法はDOS/Windowsとほぼ同じです。パス名のフォーマットは次の通りです。</p>
<pre> <p><tt>"[論理ドライブ番号:][/]ディレクトリ名/ファイル名"</tt></p>
"[<em>論理ドライブ番号</em>:][/]<em>ディレクトリ名</em>/<em>ファイル名</em>" <p>FatFsモジュールは長いファイル名(LFN)および8.3形式ファイル名(SFN)に対応しています。LFNは、<tt>(_USE_LFN &gt; 0)</tt>のとき使用可能になります。DOS/Windowsとの違いは、ディレクトリ・セパレータと論理ドライブ番号の指定です。ディレクトリ・セパレータには / または \ を使用します。論理ドライブ番号は、'0''9'の一文字の数字とコロンで指定し、省略した場合はデフォルト・ドライブ(0またはカレント・ドライブ)が選択されます。</p>
</pre> <p>Nul文字と制御文字(\0\x1F)は、パス名の終端として認識されます。パス名に先行あるいは中に含まれるスペースは、LFN構成では名前の一部として有効ですが、非LFN構成ではパス名の終端として認識されます。</p>
<p>FatFsモジュールは長いファイル名(LFN)および8.3形式ファイル名(SFN)に対応しています。LFNは、<tt>(_USE_LFN &gt; 0)</tt>のとき使用可能になります。DOS/Windowsとの違いは、ディレクトリ・セパレータと論理ドライブ番号の指定です。ディレクトリ・セパレータには / または \ を使用します。論理ドライブ番号は、'0''9'の一文字の数字とコロンで指定し、省略した場合はデフォルト・ドライブ(0またはカレント・ドライブ)が選択されます。パス名に先行あるいは中に含まれるスペースは、LFN構成では名前の一部として有効ですが、非LFN構成ではパス名の終端として認識されます。</p>
<p>標準構成<tt>(_FS_RPATH == 0)</tt>のときは、全てのオブジェクトがルート・ディレクトリから辿る絶対パスで指定されます。OS指向なカレント・ディレクトリという概念は無く、またドット・ディレクトリ(&quot;.&quot;&quot;..&quot;)は使用できません。パス名先頭のセパレータは無視されます。デフォルト・ドライブ番号は常に0になります。</p> <p>標準構成<tt>(_FS_RPATH == 0)</tt>のときは、全てのオブジェクトがルート・ディレクトリから辿る絶対パスで指定されます。OS指向なカレント・ディレクトリという概念は無く、またドット・ディレクトリ(&quot;.&quot;&quot;..&quot;)は使用できません。パス名先頭のセパレータは無視されます。デフォルト・ドライブ番号は常に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">
@ -30,29 +30,34 @@
<tr><td>.</td><td>無効</td><td>このディレクトリ</td></tr> <tr><td>.</td><td>無効</td><td>このディレクトリ</td></tr>
<tr><td>..</td><td>無効</td><td>カレント・ディレクトリの親ディレクトリ</td></tr> <tr><td>..</td><td>無効</td><td>カレント・ディレクトリの親ディレクトリ</td></tr>
<tr><td>dir1/..</td><td>無効</td><td>カレント・ディレクトリ</td></tr> <tr><td>dir1/..</td><td>無効</td><td>カレント・ディレクトリ</td></tr>
<tr><td>/..</td><td>無効</td><td>無効(ルート・ディレクトリではドット名は使用不可)</td></tr> <tr><td>/..</td><td>無効</td><td>ルート・ディレクトリ(その上は辿れない)</td></tr>
</table> </table>
</div> </div>
<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>のエリアスになっています。そして、<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> <p>ファイル関数の入出力のうちファイル名やパス名を指定する引数の型は、<tt>TCHAR</tt>で定義されていますが、これは<tt>char</tt>のエリアスになっています。そして、<tt>_CODE_PAGE</tt>で指定される ANSI/OEMコード(SBCSまたはDBCS)の文字列として扱われます。ファイル名入出力をUnicodeとする構成(LFN構成で、かつ<tt>_LFN_UNICODE</tt>を 1)にしたときは、<tt>TCHAR</tt>はワイド文字(<tt>unsigned short</tt>)に切り替わり、パス名にUnicodeを使用するようになります。これにより LFNフル対応となり、ANSI/OEMコードにない文字(たとえば ✝☪✡☸☭など)も使用できます。この設定は文字列入出力関数のデータ型とエンコーディングにも影響を与えます。リテラル文字列を定義するとき、次に示すように<tt>_T(s)</tt>および<tt>_TEXT(s)</tt>マクロを使ってANSI/OEMとUnicodeを自動切り替えすることができます。</p>
<pre>
f_open(fp, "filename.txt", FA_READ); <span>/* ANSI/OEM専用コード */</span>
f_open(fp, L"filename.txt", FA_READ); <span>/* Unicode専用コード */</span>
f_open(fp, _T("filename.txt"), FA_READ); <span>/* 両用コード */</span>
</pre>
</div> </div>
<p><br></p> <p><br></p>
<div class="para"> <div class="para">
<h2>論理ドライブ(ボリューム)と物理ドライブ(ディスク装置)の対応</h2> <h2>論理ドライブ(ボリューム)と物理ドライブ(ディスク装置)の対応</h2>
<p>デフォルトの構成では、それぞれの論理ドライブは同じ番号の物理ドライブに1:1で結びつけられていて、物理ドライブの先頭の区画がマウントされます。<tt>_MULTI_PARTITION</tt>に 1を指定すると、論理ドライブに対して個別に物理ドライブ番号・区画を指定できるようになります。この構成では、論理ドライブと区画の対応を解決するためのテーブルを次に示すように定義する必要があります。</p> <p>デフォルトの構成では、それぞれの論理ドライブは同じ番号の物理ドライブに1:1で結びつけられていて、物理ドライブの先頭の区画にあるボリュームがマウントされます。<tt>_MULTI_PARTITION</tt>に 1を指定すると、個々の論理ドライブに対して個別に物理ドライブ番号・区画を指定できるようになります。この構成では、論理ドライブと区画の対応を解決するためのテーブルを次に示すように定義する必要があります。</p>
<pre> <pre>
例:論理ドライブ02を物理ドライブ0(固定ディスク)の3つの基本区画に割り当て、 例:論理ドライブ02を物理ドライブ0(固定ディスク)の3つの基本区画に割り当て、
論理ドライブ3を物理ドライブ1(リムーバブル・ディスク)に割り当てる場合。 論理ドライブ3を物理ドライブ1(リムーバブル・ディスク)に割り当てる場合。
const PARTITION Drives[] = { const PARTITION Drives[] = {
{0, 0}, /* Logical drive 0 ==> Physical drive 0, 1st partition */ {0, 0}, <span>/* Logical drive 0 ==> Physical drive 0, 1st partition */</span>
{0, 1}, /* Logical drive 1 ==> Physical drive 0, 2nd partition */ {0, 1}, <span>/* Logical drive 1 ==> Physical drive 0, 2nd partition */</span>
{0, 2}, /* Logical drive 2 ==> Physical drive 0, 3rd partition */ {0, 2}, <span>/* Logical drive 2 ==> Physical drive 0, 3rd partition */</span>
{1, 0} /* Logical drive 3 ==> Physical drive 1 */ {1, 0} <span>/* Logical drive 3 ==> Physical drive 1 */</span>
}; };
</pre> </pre>
<p>複数区画指定を使用する場合、次の点に注意しなければなりません。 <p>複数区画指定を使用する場合、次の点に注意しなければなりません。

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/forward.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>FatFs - f_forward</title> <title>FatFs - f_forward</title>
</head> </head>
@ -15,10 +16,10 @@
<p>ファイルからデータを読み出し、送信ストリームに直接転送します。</p> <p>ファイルからデータを読み出し、送信ストリームに直接転送します。</p>
<pre> <pre>
FRESULT f_forward ( FRESULT f_forward (
FIL* <em>FileObject</em>, /* ファイル・オブジェクト構造体 */ FIL* <em>FileObject</em>, <span>/* ファイル・オブジェクト構造体 */</span>
UINT (*<em>Func</em>)(const BYTE*,UINT), /* データ転送関数 */ UINT (*<em>Func</em>)(const BYTE*,UINT), <span>/* データ転送関数 */</span>
UINT <em>ByteToFwd</em>, /* 転送するバイト数 */ UINT <em>ByteToFwd</em>, <span>/* 転送するバイト数 */</span>
UINT* <em>ByteFwd</em> /* 転送されたバイト数 */ UINT* <em>ByteFwd</em> <span>/* 転送されたバイト数 */</span>
); );
</pre> </pre>
</div> </div>
@ -72,26 +73,26 @@ FRESULT f_forward (
<div class="para"> <div class="para">
<h4>使用例(オーディオ再生)</h4> <h4>使用例(オーディオ再生)</h4>
<pre> <pre>
/*-----------------------------------------------------------------------*/ <span>/*-----------------------------------------------------------------------*/</span>
/* f_forward関数から呼ばれるデータ送信関数の例 */ <span>/* f_forward関数から呼ばれるデータ送信関数の例 */</span>
/*-----------------------------------------------------------------------*/ <span>/*-----------------------------------------------------------------------*/</span>
UINT out_stream ( /* 戻り値: 転送されたバイト数またはストリームの状態 */ UINT out_stream ( <span>/* 戻り値: 転送されたバイト数またはストリームの状態 */</span>
const BYTE *p, /* 転送するデータを指すポインタ */ const BYTE *p, <span>/* 転送するデータを指すポインタ */</span>
UINT btf /* &gt;0: 転送を行う(バイト数). 0: ストリームの状態を調べる */ UINT btf <span>/* &gt;0: 転送を行う(バイト数). 0: ストリームの状態を調べる */</span>
) )
{ {
UINT cnt = 0; UINT cnt = 0;
if (btf == 0) { /* センス要求 */ if (btf == 0) { <span>/* センス要求 */</span>
/* ストリームの状態を返す (0: ビジー, 1: レディ) */ <span>/* ストリームの状態を返す (0: ビジー, 1: レディ) */</span>
/* 一旦、レディを返したら、続く転送要求で少なくとも1バイトは */ <span>/* 一旦、レディを返したら、続く転送要求で少なくとも1バイトは */</span>
/* 転送されないと f_forward関数は FR_RW_ERROR となる。 */ <span>/* 転送されないと f_forward関数は FR_RW_ERROR となる。 */</span>
if (FIFO_READY) cnt = 1; if (FIFO_READY) cnt = 1;
} }
else { /* 転送要求 */ else { <span>/* 転送要求 */</span>
do { /* 全てのバイトを転送するか、ストリームがビジーになるまで繰り返す */ do { <span>/* 全てのバイトを転送するか、ストリームがビジーになるまで繰り返す */</span>
FIFO_PORT = *p++; FIFO_PORT = *p++;
cnt++; cnt++;
} while (cnt &lt; btf &amp;&amp; FIFO_READY); } while (cnt &lt; btf &amp;&amp; FIFO_READY);
@ -101,31 +102,34 @@ UINT out_stream ( /*
} }
/*-----------------------------------------------------------------------*/ <span>/*-----------------------------------------------------------------------*/</span>
/* f_forward関数の使用例 */ <span>/* f_forward関数の使用例 */</span>
/*-----------------------------------------------------------------------*/ <span>/*-----------------------------------------------------------------------*/</span>
FRESULT play_file ( FRESULT play_file (
char *fn /* 再生するオーディオ・ファイル名を指すポインタ */ char *fn <span>/* 再生するオーディオ・ファイル名を指すポインタ */</span>
) )
{ {
FRESULT rc; FRESULT rc;
FIL fil; FIL fil;
UINT dmy; UINT dmy;
/* ファイルを読み出しモードで開く */ <span>/* ファイルを読み出しモードで開く */</span>
rc = f_open(&amp;fil, fn, FA_READ); rc = f_open(&amp;fil, fn, FA_READ);
if (rc) return rc;
/* 全てのデータが転送されるかエラーが発生するまで続ける */ <span>/* 全てのデータが転送されるかエラーが発生するまで続ける */</span>
while (rc == FR_OK &amp;&amp; fil.fptr &lt; fil.fsize) { while (rc == FR_OK &amp;&amp; fil.fptr &lt; fil.fsize) {
/* ほかの処理... */ <span>/* ほかの処理... */</span>
/* 定期的または要求に応じてデータをストリームに送出する */ <span>/* 定期的または要求に応じてデータをストリームに送出する */</span>
rc = f_forward(&amp;fil, out_stream, 1000, &amp;dmy); rc = f_forward(&amp;fil, out_stream, 1000, &amp;dmy);
} }
return rc; /* FR_OK: 正常終了, ほか:異常終了 */ <span>/* ファイルを閉じて戻る */</span>
f_close(&amp;fil);
return rc; <span>
} }
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/getfree.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>FatFs - f_getfree</title> <title>FatFs - f_getfree</title>
</head> </head>
@ -15,9 +16,9 @@
<p>論理ドライブ上の未使用クラスタ数を得ます。</p> <p>論理ドライブ上の未使用クラスタ数を得ます。</p>
<pre> <pre>
FRESULT f_getfree ( FRESULT f_getfree (
const XCHAR* <em>Path</em>, /* 対象ドライブのルート・ディレクトリ */ const TCHAR* <em>Path</em>, <span>/* 対象ドライブを指定します */</span>
DWORD* <em>Clusters</em>, /* 空きクラスタ数を格納する変数へのポインタ */ DWORD* <em>Clusters</em>, <span>/* 空きクラスタ数を格納する変数へのポインタ */</span>
FATFS** <em>FileSystemObject</em> /* ファイル・システム・オブジェクトを指すポインタへのポインタ */ FATFS** <em>FileSystemObject</em> <span>/* ファイル・システム・オブジェクトを指すポインタへのポインタ */</span>
); );
</pre> </pre>
</div> </div>
@ -26,7 +27,7 @@ FRESULT f_getfree (
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>Path</dt> <dt>Path</dt>
<dd>対象の論理ドライブのルートディレクトリの<a href="filename.html">パス名</a>が入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd> <dd>調べる対象の論理ドライブを示す<a href="filename.html">パス名</a>が入った<tt>'\0'</tt>で終わる文字列へのポインタを指定します。</dd>
<dt>Clusters</dt> <dt>Clusters</dt>
<dd>空きクラスタ数を格納する<tt>DWORD</tt>変数へのポインタを指定します。</dd> <dd>空きクラスタ数を格納する<tt>DWORD</tt>変数へのポインタを指定します。</dd>
<dt>FileSystemObject</dt> <dt>FileSystemObject</dt>
@ -51,14 +52,14 @@ FRESULT f_getfree (
<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>csize</tt>メンバがクラスタあたりのセクタ数を示しているので、これを元に実際の空きサイズが計算できます。FAT32ボリュームにおいては、FSINFOの状態によっては不正確な値を返したり、処理に時間がかかったりする可能性があります。</p> <p>論理ドライブ上の空きクラスタ数を取得します。返されたファイル・システム・オブジェクトの<tt>csize</tt>メンバがクラスタあたりのセクタ数を示しているので、これを元に実際の空きサイズが計算できます。FAT32ボリュームにおいては、FSINFOセクタの状態によっては不正確な値を返したり、処理に時間がかかったりする可能性があります。</p>
</div> </div>
@ -75,15 +76,15 @@ FRESULT f_getfree (
DWORD fre_clust, fre_sect, tot_sect; DWORD fre_clust, fre_sect, tot_sect;
/* Get drive information and free clusters */ <span>/* ドライブ1のボリューム情報と空きクラスタ数を得る */</span>
res = f_getfree("/", &amp;fre_clust, &amp;fs); res = f_getfree("1:", &amp;fre_clust, &amp;fs);
if (res) die(res); if (res) die(res);
/* Get total sectors and free sectors */ <span>/* 全セクタ数と空きセクタ数を計算 */</span>
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) */ <span>/* ドライブサイズと空きサイズの表示 (512バイト/セクタと仮定) */</span>
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);

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/gets.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>FatFs - f_gets</title> <title>FatFs - f_gets</title>
</head> </head>
@ -14,10 +15,10 @@
<h2>f_gets</h2> <h2>f_gets</h2>
<p>ファイルから文字列を読み出します。</p> <p>ファイルから文字列を読み出します。</p>
<pre> <pre>
char* f_gets ( TCHAR* f_gets (
char* <em>Str</em>, /* バッファ */ TCHAR* <em>Str</em>, <span>/* バッファ */</span>
int <em>Size</em>, /* バッファのサイズ */ int <em>Size</em>, <span>/* バッファのサイズ */</span>
FIL* <em>FileObject</em> /* ファイル・オブジェクト */ FIL* <em>FileObject</em> <span>/* ファイル・オブジェクト */</span>
); );
</pre> </pre>
</div> </div>
@ -28,7 +29,7 @@ char* f_gets (
<dt>Str</dt> <dt>Str</dt>
<dd>文字列を読み出すバッファを指すポインタを指定します。</dd> <dd>文字列を読み出すバッファを指すポインタを指定します。</dd>
<dt>Size</dt> <dt>Size</dt>
<dd>バッファのサイズを指定します。</dd> <dd>バッファのサイズを要素数で指定します。</dd>
<dt>FileObject</dt> <dt>FileObject</dt>
<dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd> <dd>ファイル・オブジェクト構造体へのポインタを指定します。</dd>
</dl> </dl>
@ -43,7 +44,8 @@ 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>f_eof()</tt>,<tt>f_error()</tt>マクロで調べられます。</p>
<p>APIにUnicodeが選択されている(<tt>_LFN_UNICODE</tt>が1)ときは、UTF-8エンコードのテキスト・ファイルとしてUCS-2に変換してバッファに読み込みます。それ以外の時は無変換(1文字1バイト)で読み込みます。</p>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/lseek.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>FatFs - f_lseek</title> <title>FatFs - f_lseek</title>
</head> </head>
@ -12,11 +13,11 @@
<div class="para"> <div class="para">
<h2>f_lseek</h2> <h2>f_lseek</h2>
<p>ファイルのR/Wポインタを移動します。</p> <p>ファイルのリード/ライト・ポインタを移動します。</p>
<pre> <pre>
FRESULT f_lseek ( FRESULT f_lseek (
FIL* <em>FileObject</em>, /* ファイル・オブジェクト構造体へのポインタ */ FIL* <em>FileObject</em>, <span>/* ファイル・オブジェクト構造体へのポインタ */</span>
DWORD <em>Offset</em> /* 移動先オフセット */ DWORD <em>Offset</em> <span>/* 移動先オフセット */</span>
); );
</pre> </pre>
</div> </div>
@ -27,7 +28,7 @@ FRESULT f_lseek (
<dt>FileObject</dt> <dt>FileObject</dt>
<dd>対象となるファイル・オブジェクト構造体へのポインタを指定します。</dd> <dd>対象となるファイル・オブジェクト構造体へのポインタを指定します。</dd>
<dt>Offset</dt> <dt>Offset</dt>
<dd>移動先のオフセット(R/Wポインタ)値。ファイル先頭からのオフセットをバイト単位で指定します。</dd> <dd>移動先のオフセット(リード/ライト・ポインタ)値。ファイル先頭からのオフセットをバイト単位で指定します。</dd>
</dl> </dl>
</div> </div>
@ -45,17 +46,20 @@ FRESULT f_lseek (
<dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd> <dd>メディアがセットされていないなど、物理ドライブが動作不能状態。</dd>
<dt>FR_INVALID_OBJECT</dt> <dt>FR_INVALID_OBJECT</dt>
<dd>無効なファイル・オブジェクト。</dd> <dd>無効なファイル・オブジェクト。</dd>
<dt>FR_NOT_ENOUGH_CORE</dt>
<dd>リンク・マップ・テーブルのサイズが不足。</dd>
</dl> </dl>
</div> </div>
<div class="para"> <div class="para">
<h4>解説</h4> <h4>解説</h4>
<p>ファイルR/Wポインタ(ファイル・オブジェクト内のfptrメンバで、次に読み出し・書き込みされるバイトのオフセットを示す)を移動します。オフセットの原点はファイル先頭からです。書き込みモードでファイル・サイズより大きな値を指定すると、そこまでファイルが拡張され、拡張された部分のデータは未定義となります。データを遅延無く高速に書き込みたいときは、予めこの関数で必要なサイズまでファイル・サイズを拡張しておくと良いでしょう。f_lseek関数が正常終了したあとは、ファイルR/Wポインタが正しく移動したかfptrをチェックするべきです。ファイルR/Wポインタが指定より小さいときは、次の原因が考えられます。</p> <p>ファイルのリード/ライト・ポインタ(ファイル・オブジェクト内のfptrメンバで、次に読み出し・書き込みされるバイトのオフセットを示す)を移動します。オフセットの原点はファイル先頭です。書き込みモードでファイル・サイズより大きな値を指定すると、そこまでファイル・サイズが拡張され、拡張された部分のデータは未定義となります。データを遅延無く高速に書き込みたいときは、予めこの関数で必要なサイズまでファイル・サイズを拡張しておくと良いでしょう。f_lseek関数が正常終了したあとは、リード/ライト・ポインタが正しく移動したかfptrをチェックするべきです。リード/ライト・ポインタが指定より小さいときは、次の原因が考えられます。</p>
<ul> <ul>
<li>非書き込みモードのため、ファイル・サイズでクリップされた。</li> <li>非書き込みモードまたは高速シーク・モードのため、ファイル・サイズでクリップされた。</li>
<li>ファイル拡張中にディスクが満杯になった。</li> <li>ファイル拡張中にディスクが満杯になった。</li>
</ul> </ul>
<p><tt>_USE_FASTSEEK</tt>に1が指定されていて、且つファイル・オブジェクトの<tt>cltbl</tt>メンバがNULL以外のとき、高速シーク・モードになります。これはファイルのクラスタ情報をアプリケーションの指定した配列に保持しておくことにより、FATにアクセスすることなく後方シークやロング・シークを高速に行う機能です。高速シーク動作を行う前には、配列を初期化しておく必要があります。必要な配列サイズ(要素数)は、(ファイルの分割数 + 1) * 2 です。たとえば、ファイルが5つに分断されているときに必要な配列サイズは、12要素となります。高速シーク使用時はファイル・サイズの拡張はできません。</p>
</div> </div>
@ -68,35 +72,48 @@ FRESULT f_lseek (
<div class="para"> <div class="para">
<h4>使用例</h4> <h4>使用例</h4>
<pre> <pre>
/* オフセット5000へ移動 */ <span>/* ファイル・オフセット5000へ移動 */</span>
res = f_lseek(&amp;file, 5000); res = f_lseek(&amp;file, 5000, 0);
/* ファイル追記の準備 (ファイル終端へ移動) */ <span>/* ファイル追記の準備 (ファイル終端へ移動) */</span>
res = f_lseek(&amp;file, file.fsize); res = f_lseek(&amp;file, file.fsize, 0);
/* 3000バイト進める */ <span>/* 3000バイト進める */</span>
res = f_lseek(&amp;file, file.fptr + 3000); res = f_lseek(&amp;file, file.fptr + 3000, 0);
/* 2000バイト戻す (オーバーフローに注意) */ <span>/* 2000バイト戻す (オーバーフローに注意) */</span>
res = f_lseek(&amp;file, file.fptr - 2000); res = f_lseek(&amp;file, file.fptr - 2000, 0);
</pre> </pre>
<pre> <pre>
/* クラスタ先行割り当て (ストリーミング・ライト時のバッファ・オーバーラン防止) */ <span>/* クラスタ先行割り当て (ストリーミング・ライト時のバッファ・オーバーラン防止) */</span>
res = f_open(&amp;file, "record.wav", FA_CREATE_NEW | FA_WRITE); /* ファイル作成 */ res = f_open(&amp;file, "record.wav", FA_CREATE_NEW | FA_WRITE); <span>/* ファイル作成 */</span>
res = f_lseek(&amp;file, MAX_SIZE); /* 十分なクラスタの先行割り当て */ res = f_lseek(&amp;file, MAX_SIZE, 0); <span>/* 十分なクラスタの先行割り当て */</span>
if (res || file.fptr != PRE_SIZE) .... /* 正しくファイルが拡張されたかチェック */ if (res || file.fptr != PRE_SIZE) .... <span>/* 正しくファイルが拡張されたかチェック */</span>
res = f_lseek(&amp;file, DATA_START); /* データ・ストリームの記録(アロケーションディレイ無し) */ res = f_lseek(&amp;file, DATA_START, 0); <span>/* データ・ストリームの記録(アロケーションディレイ無し) */</span>
... ...
res = f_truncate(&amp;file); /* 不要領域の切り捨て */ res = f_truncate(&amp;file); <span>/* 不要領域の切り捨て */</span>
res = f_lseek(&amp;file, 0); /* ヘッダの記録 */ res = f_lseek(&amp;file, 0, 0); <span>/* ヘッダの記録 */</span>
... ...
res = f_close(&amp;file); res = f_close(&amp;file);
</pre> </pre>
<pre>
<span>/* 高速シーク機能を使う */</span>
DWORD lktbl[SZ_TBL]; <span>/* リンク・マップ・テーブル格納バッファ */</span>
res = f_lseek(&amp;file, ofs1); <span>/* 通常シーク (オープン時は file.cltbl == NULL) */</span>
file.cltbl = lktbl; <span>/* 高速シーク機能の有効化 */</span>
lktbl[0] = SZ_TBL; <span>/* 先頭要素に配列要素数をセット */</span>
res = f_lseek(&amp;file, CREATE_LINKMAP); <span>/* リンク・マップ・テーブルの作成 */</span>
res = f_lseek(&amp;file, ofs2); <span>/* 高速シーク (file.cltbl != NULL) */</span>
</pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/mkdir.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>FatFs - f_mkdir</title> <title>FatFs - f_mkdir</title>
</head> </head>
@ -15,7 +16,7 @@
<p>ディレクトリを作成します。</p> <p>ディレクトリを作成します。</p>
<pre> <pre>
FRESULT f_mkdir ( FRESULT f_mkdir (
const XCHAR* <em>DirName</em> /* 作成するディレクトリ名へのポインタ */ const TCHAR* <em>DirName</em> <span>/* 作成するディレクトリ名へのポインタ */</span>
); );
</pre> </pre>
</div> </div>
@ -55,7 +56,7 @@ 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>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/mkfs.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>FatFs - f_mkfs</title> <title>FatFs - f_mkfs</title>
</head> </head>
@ -15,9 +16,9 @@
<p>ドライブ上にFATファイル・システムを作成(フォーマット)します。</p> <p>ドライブ上にFATファイル・システムを作成(フォーマット)します。</p>
<pre> <pre>
FRESULT f_mkfs ( FRESULT f_mkfs (
BYTE <em>Drive</em>, /* 論理ドライブ番号 */ BYTE <em>Drive</em>, <span>/* 論理ドライブ番号 */</span>
BYTE <em>PartitioningRule</em>, /* 区画作成方法 */ BYTE <em>PartitioningRule</em>, <span>/* 区画作成方法 */</span>
WORD <em>AllocSize</em> /* クラス・タサイズ */ UINT <em>AllocSize</em> <span>/* クラス・タサイズ */</span>
); );
</pre> </pre>
</div> </div>
@ -28,9 +29,9 @@ FRESULT f_mkfs (
<dt>Drive</dt> <dt>Drive</dt>
<dd>フォーマットする論理ドライブ(0-9)。</dd> <dd>フォーマットする論理ドライブ(0-9)。</dd>
<dt>PartitioningRule</dt> <dt>PartitioningRule</dt>
<dd>0を指定すると、ドライブの全領域を占める基本DOS区画を作成したあとその区画にファイル・システムを作成します(FDISKフォーマット)。1を指定すると、区画テーブルを作成せずドライブの先頭セクタから直接ファイル・システムを作成します(super floppy (SFD) フォーマット)。</dd> <dd>0を指定すると、ドライブの全領域を占める基本DOS区画を作成したあとその区画にファイル・システムを作成します(FDISKフォーマット)。1を指定すると、区画テーブルを作成せず物理ドライブの先頭セクタから直接ファイル・システムを作成します(super floppy (SFD) フォーマット)。</dd>
<dt>AllocSize</dt> <dt>AllocSize</dt>
<dd>クラスタ・サイズをバイト単位で指定します。0または51232768の範囲でかつ2の累乗でなければなりません。0を指定するとドライブ・サイズに応じたデフォルトのクラスタ・サイズを選択します。FAT64(64KB/クラスタ)は選択できません</dd> <dd>クラスタ・サイズをバイト単位で指定します。2の累乗、且つセクタ・サイズ以上、且つセクタ・サイズの128倍以下でなければなりません。無効な値を指定した場合、ドライブ・サイズに応じたデフォルトのクラスタ・サイズが選択されます。特に指定しない場合は、0を指定して自動選択とします</dd>
</dl> </dl>
</div> </div>
@ -63,7 +64,7 @@ FRESULT f_mkfs (
<div class="para"> <div class="para">
<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>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/mount.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>FatFs - f_mount</title> <title>FatFs - f_mount</title>
</head> </head>
@ -12,11 +13,11 @@
<div class="para"> <div class="para">
<h2>f_mount</h2> <h2>f_mount</h2>
<p>論理ドライブ(ボリューム)のワーク・エリアを登録・抹消します。</p> <p>論理ドライブのワーク・エリアを登録・抹消します。</p>
<pre> <pre>
FRESULT f_mount ( FRESULT f_mount (
BYTE <em>Drive</em>, /* 論理ドライブ番号 */ BYTE <em>Drive</em>, <span>/* 論理ドライブ番号 */</span>
FATFS* <em>FileSystemObject</em> /* ワーク・エリアへのポインタ */ FATFS* <em>FileSystemObject</em> <span>/* ワーク・エリアへのポインタ */</span>
); );
</pre> </pre>
</div> </div>
@ -37,15 +38,15 @@ FRESULT f_mount (
<dt>FR_OK (0)</dt> <dt>FR_OK (0)</dt>
<dd><EFBFBD>³<EFBFBD>í<EFBFBD>I—¹<EFBFBD>B</dd> <dd><EFBFBD>³<EFBFBD>í<EFBFBD>I—¹<EFBFBD>B</dd>
<dt>FR_INVALID_DRIVE</dt> <dt>FR_INVALID_DRIVE</dt>
<dd>ドライブ番号が無効。</dd> <dd>論理ドライブ番号が無効。</dd>
</dl> </dl>
</div> </div>
<div class="para"> <div class="para">
<h4>‰ð<EFBFBD>à</h4> <h4>‰ð<EFBFBD>à</h4>
<p>FatFsモジュールではそれぞれの論理ドライブにファイル・システム・オブジェクトというワーク・エリアが必要です。この関数は論理ドライブにそのワーク・エリアを登録したり抹消したりします。何らかのファイル関数を使用する前にこの関数でその論理ドライブのワーク・エリアを与えておかなければなりません。<tt>FileSystemObject</tt>にヌル・ポインタを指定するとその論理ドライブのワーク・エリアの登録は抹消され、登録されていたワーク・エリアは破棄できます。</p> <p>FatFsモジュールではそれぞれの論理ドライブにファイル・システム・オブジェクトというワーク・エリアが必要です。この関数は論理ドライブにそのワーク・エリアを登録したり抹消したりします。何らかのファイル関数を使用する前にこの関数でその論理ドライブのワーク・エリアを与えておかなければなりません。<tt>FileSystemObject</tt>にヌル・ポインタを指定するとその論理ドライブのワーク・エリアの登録は抹消され、登録されていたワーク・エリアは破棄できます。操作対象のドライブに対して開かれているファイルやディレクトリがあった場合、それらは全て無効になります。</p>
<p>この関数内では物理ドライブへのアクセスは発生せず、ワーク・エリアを初期化して内部配列にそのアドレスを登録するだけです。実際のマウント動作は、f_mount()またはメディア交換後、最初のファイル・アクセスのときに行われます。</p> <p>この関数内では下位レイヤ(物理ドライブ)へのアクセスは発生せず、ワーク・エリアを初期化して内部配列にそのアドレスを登録するだけです。実際のマウント動作は、f_mount()またはメディア交換後、最初のファイル・アクセスのときに行われます。</p>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/open.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>FatFs - f_open</title> <title>FatFs - f_open</title>
</head> </head>
@ -15,9 +16,9 @@
<p>ファイルをオープンまたは作成します。</p> <p>ファイルをオープンまたは作成します。</p>
<pre> <pre>
FRESULT f_open ( FRESULT f_open (
FIL* <em>FileObject</em>, /* 空のファイル・オブジェクト構造体へのポインタ */ FIL* <em>FileObject</em>, <span>/* 空のファイル・オブジェクト構造体へのポインタ */</span>
const XCHAR* <em>FileName</em>, /* ファイルのフルパス名へのポインタ */ const TCHAR* <em>FileName</em>, <span>/* ファイルのフルパス名へのポインタ */</span>
BYTE <em>ModeFlags</em> /* モードフラグ */ BYTE <em>ModeFlags</em> <span>/* モードフラグ */</span>
); );
</pre> </pre>
</div> </div>
@ -36,7 +37,7 @@ FRESULT f_open (
<tr><td>FA_READ</td><td>読み出しモードで開きます。読み書きする場合は<tt>FA_WRITE</tt>と共に指定します。</td></tr> <tr><td>FA_READ</td><td>読み出しモードで開きます。読み書きする場合は<tt>FA_WRITE</tt>と共に指定します。</td></tr>
<tr><td>FA_WRITE</td><td>書き込みモードで開きます。読み書きする場合は<tt>FA_READ</tt>と共に指定します。</td></tr> <tr><td>FA_WRITE</td><td>書き込みモードで開きます。読み書きする場合は<tt>FA_READ</tt>と共に指定します。</td></tr>
<tr><td>FA_OPEN_EXISTING</td><td>既存のファイルを開きます。ファイルが無いときはエラーになります。(デフォルト)</td></tr> <tr><td>FA_OPEN_EXISTING</td><td>既存のファイルを開きます。ファイルが無いときはエラーになります。(デフォルト)</td></tr>
<tr><td>FA_OPEN_ALWAYS</td><td>既存のファイルを開きます。ファイルが無いときはファイルを作成します。</td></tr> <tr><td>FA_OPEN_ALWAYS</td><td>既存のファイルを開きます。ファイルが無いときはファイルを作成します。追記する場合は、この方法でオープンした後、<tt>f_lseek()</tt>でファイルの最後尾に移動してください。</td></tr>
<tr><td>FA_CREATE_NEW</td><td>ファイルを作成します。同名のファイルがある場合は、エラーになります。</td></tr> <tr><td>FA_CREATE_NEW</td><td>ファイルを作成します。同名のファイルがある場合は、エラーになります。</td></tr>
<tr><td>FA_CREATE_ALWAYS</td><td>ファイルを作成します。同名のファイルがある場合は、サイズを0にしてから開きます。</td></tr> <tr><td>FA_CREATE_ALWAYS</td><td>ファイルを作成します。同名のファイルがある場合は、サイズを0にしてから開きます。</td></tr>
</table> </table>
@ -73,7 +74,9 @@ 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>
<dt>FR_LOCKED</dt>
<dd>ファイル共有機能によるアクセス拒否。</dd>
</dl> </dl>
</div> </div>
@ -96,37 +99,37 @@ FRESULT f_open (
<pre> <pre>
void main (void) void main (void)
{ {
FATFS fs[2]; /* 論理ドライブのワーク・エリア(ファイル・システム・オブジェクト) */ FATFS fs[2]; <span>/* 論理ドライブのワーク・エリア(ファイル・システム・オブジェクト) */</span>
FIL fsrc, fdst; /* ファイル・オブジェクト */ FIL fsrc, fdst; <span>/* ファイル・オブジェクト */</span>
BYTE buffer[4096]; /* file copy buffer */ BYTE buffer[4096]; <span>/* file copy buffer */</span>
FRESULT res; /* FatFs function common result code */ FRESULT res; <span>/* FatFs function common result code */</span>
UINT br, bw; /* File R/W count */ UINT br, bw; <span>/* File R/W count */</span>
/* ドライブ0,1にワーク・エリアを与える */ <span>/* ドライブ0,1にワーク・エリアを与える */</span>
f_mount(0, &amp;fs[0]); f_mount(0, &amp;fs[0]);
f_mount(1, &amp;fs[1]); f_mount(1, &amp;fs[1]);
/* ドライブ1のソース・ファイルを開く */ <span>/* ドライブ1のソース・ファイルを開く */</span>
res = f_open(&amp;fsrc, "1:srcfile.dat", FA_OPEN_EXISTING | FA_READ); res = f_open(&amp;fsrc, "1:srcfile.dat", FA_OPEN_EXISTING | FA_READ);
if (res) die(res); if (res) die(res);
/* ドライブ0にデスティネーション・ファイルを作成する */ <span>/* ドライブ0にデスティネーション・ファイルを作成する */</span>
res = f_open(&amp;fdst, "0:dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE); res = f_open(&amp;fdst, "0:dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE);
if (res) die(res); if (res) die(res);
/* ソースからデスティネーションにコピーする */ <span>/* ソースからデスティネーションにコピーする */</span>
for (;;) { for (;;) {
res = f_read(&amp;fsrc, buffer, sizeof(buffer), &amp;br); res = f_read(&amp;fsrc, buffer, sizeof(buffer), &amp;br);
if (res || br == 0) break; /* エラーかファイル終端 */ if (res || br == 0) break; <span>/* エラーかファイル終端 */</span>
res = f_write(&amp;fdst, buffer, br, &amp;bw); res = f_write(&amp;fdst, buffer, br, &amp;bw);
if (res || bw &lt; br) break; /* エラーかディスク満杯 */ if (res || bw &lt; br) break; <span>/* エラーかディスク満杯 */</span>
} }
/* 全てのファイルを閉じる */ <span>/* 全てのファイルを閉じる */</span>
f_close(&amp;fsrc); f_close(&amp;fsrc);
f_close(&amp;fdst); f_close(&amp;fdst);
/* ワーク・エリアを開放する */ <span>/* ワーク・エリアを開放する */</span>
f_mount(0, NULL); f_mount(0, NULL);
f_mount(1, NULL); f_mount(1, NULL);
} }

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/opendir.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>FatFs - f_opendir</title> <title>FatFs - f_opendir</title>
</head> </head>
@ -15,8 +16,8 @@
<p>ディレクトリを開きます。</p> <p>ディレクトリを開きます。</p>
<pre> <pre>
FRESULT f_opendir ( FRESULT f_opendir (
DIR* <em>DirObject</em>, /* ディレクトリ・ブジェクト構造体へのポインタ */ DIR* <em>DirObject</em>, <span>/* ディレクトリ・ブジェクト構造体へのポインタ */</span>
const XCHAR* <em>DirName</em> /* ディレクトリ名へのポインタ */ const TCHAR* <em>DirName</em> <span>/* ディレクトリ名へのポインタ */</span>
); );
</pre> </pre>
</div> </div>
@ -42,7 +43,7 @@ FRESULT f_opendir (
<dt>FR_INVALID_NAME</dt> <dt>FR_INVALID_NAME</dt>
<dd>パス名が不正。</dd> <dd>パス名が不正。</dd>
<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>
@ -52,7 +53,7 @@ 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>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/printf.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>FatFs - f_printf</title> <title>FatFs - f_printf</title>
</head> </head>
@ -15,8 +16,8 @@
<p>ファイルに書式化文字列を書き込みます。</p> <p>ファイルに書式化文字列を書き込みます。</p>
<pre> <pre>
int f_printf ( int f_printf (
FIL* <em>FileObject</em>, /* ファイル・オブジェクト */ FIL* <em>FileObject</em>, <span>/* ファイル・オブジェクト */</span>
const char* <em>Foramt</em>, /* 書式制御文字列 */ const TCHAR* <em>Foramt</em>, <span>/* 書式制御文字列 */</span>
... ...
); );
</pre> </pre>
@ -38,7 +39,7 @@ int f_printf (
<div class="para"> <div class="para">
<h4>戻り値</h4> <h4>戻り値</h4>
<p>文字列が正常に書き込まれると書き込んだ文字数が返されます。ディスクが満杯またはその他エラーにより正常に書き込まれなかったときは<tt>EOF</tt>(-1)が返されます。</p> <p>文字列が正常に書き込まれると書き込まれた文字数が返されます。ディスクが満杯またはその他エラーにより正常に書き込まれなかったときは関数は失敗し<tt>EOF (-1)</tt>が返されます。</p>
</div> </div>
@ -46,8 +47,8 @@ int f_printf (
<h4>解説</h4> <h4>解説</h4>
<p>この関数は<a href="putc.html">f_putc()</a>および<a href="puts.html">f_puts()</a>のラッパー関数です。書式制御機能はサブセットとなっていて、書式制御文字は次に示すものが使用可能です。</p> <p>この関数は<a href="putc.html">f_putc()</a>および<a href="puts.html">f_puts()</a>のラッパー関数です。書式制御機能はサブセットとなっていて、書式制御文字は次に示すものが使用可能です。</p>
<ul> <ul>
<li>タイプ: <tt>c s d u X</tt></li> <li>タイプ: <tt>c C s S d D u U x X b B</tt></li>
<li>精度指定: <tt>l</tt></li> <li>精度指定: <tt>l L</tt></li>
<li>フラグ: <tt>0</tt></li> <li>フラグ: <tt>0</tt></li>
</ul> </ul>
</div> </div>
@ -56,18 +57,19 @@ int f_printf (
<div class="para"> <div class="para">
<h4>対応情報</h4> <h4>対応情報</h4>
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_STRFUNC</tt>が 1または 2のとき使用可能になります。2の時は、出力に含まれる<tt>'\n'</tt><tt>"\r\n"</tt>に展開されてファイルに書き込まれます。</p> <p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_STRFUNC</tt>が 1または 2のとき使用可能になります。2の時は、出力に含まれる<tt>'\n'</tt><tt>"\r\n"</tt>に展開されてファイルに書き込まれます。</p>
<p>APIにUnicodeが選択されている(<tt>_LFN_UNICODE</tt>が1)ときは、UTF-8エンコードでファイルに書き込みます。それ以外の時は無変換(1文字1バイト)で書き込みます。</p>
</div> </div>
<div class="para"> <div class="para">
<h4>使用例</h4> <h4>使用例</h4>
<pre> <pre>
f_printf(&amp;fil, "%6d", -200); // " -200" f_printf(&amp;fil, "%6d", -200); <span>/* " -200" */</span>
f_printf(&amp;fil, "%02u", 5); // "05" f_printf(&amp;fil, "%02u", 5); <span>/* "05" */</span>
f_printf(&amp;fil, "%ld", 12345678L); // "12345678" f_printf(&amp;fil, "%ld", 12345678L); <span>/* "12345678" */</span>
f_printf(&amp;fil, "%08lX", 1194684UL); // "00123ABC" f_printf(&amp;fil, "%08lX", 1194684UL); <span>/* "00123ABC" */</span>
f_printf(&amp;fil, "%s", "String"); // "String" f_printf(&amp;fil, "%s", "String"); <span>/* "String" */</span>
f_printf(&amp;fil, "%c", 'a'); // "a" f_printf(&amp;fil, "%c", 'a'); <span>/* "a" */</span>
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/putc.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>FatFs - f_putc</title> <title>FatFs - f_putc</title>
</head> </head>
@ -15,8 +16,8 @@
<p>ファイルに文字を書き込みます。</p> <p>ファイルに文字を書き込みます。</p>
<pre> <pre>
int f_putc ( int f_putc (
int <em>Chr</em>, /* 書き込む文字 */ TCHAR <em>Chr</em>, <span>/* 書き込む文字 */</span>
FIL* <em>FileObject</em> /* ファイル・オブジェクト */ FIL* <em>FileObject</em> <span>/* ファイル・オブジェクト */</span>
); );
</pre> </pre>
</div> </div>
@ -34,7 +35,8 @@ int f_putc (
<div class="para"> <div class="para">
<h4>戻り値</h4> <h4>戻り値</h4>
<p>文字が正常に書き込まれると書き込んだ文字が返されます。ディスクが満杯またはその他エラーにより書き込まれなかったときは<tt>EOF</tt>が返されます。</p> <p>文字が正常に書き込まれると書き込んだ文字が返されます。ディスクが満杯またはエラーにより書き込まれなかったときは<tt>EOF (-1)</tt>が返されます。</p>
<p>APIにUnicodeが選択されている(<tt>_LFN_UNICODE</tt>が1)ときは、UTF-8エンコードでファイルに書き込みます。それ以外の時は無変換(1文字1バイト)で書き込みます。</p>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/puts.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>FatFs - f_puts</title> <title>FatFs - f_puts</title>
</head> </head>
@ -15,8 +16,8 @@
<p>ファイルに文字列を書き込みます。</p> <p>ファイルに文字列を書き込みます。</p>
<pre> <pre>
int f_puts ( int f_puts (
const char* <em>Str</em>, /* 文字列 */ const TCHAR* <em>Str</em>, <span>/* 文字列 */</span>
FIL* <em>FileObject</em> /* ファイル・オブジェクト */ FIL* <em>FileObject</em> <span>/* ファイル・オブジェクト */</span>
); );
</pre> </pre>
</div> </div>
@ -34,7 +35,8 @@ int f_puts (
<div class="para"> <div class="para">
<h4>戻り値</h4> <h4>戻り値</h4>
<p>文字列が正常に書き込まれると書き込んだ文字数が返されます。ディスクが満杯またはその他エラーにより正常に書き込まれなかったときは<tt>EOF</tt>が返されます。</p> <p>文字列が正常に書き込まれると、書き込まれた文字数が返されます。ディスクが満杯またはエラーにより正常に書き込まれなかったときは<tt>EOF (-1)</tt>が返されます。</p>
<p>APIにUnicodeが選択されている(<tt>_LFN_UNICODE</tt>が1)ときは、UTF-8エンコードでファイルに書き込みます。それ以外の時は無変換(1文字1バイト)で書き込みます。</p>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/read.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>FatFs - f_read</title> <title>FatFs - f_read</title>
</head> </head>
@ -15,10 +16,10 @@
<p>ファイルからデータを読み出します。</p> <p>ファイルからデータを読み出します。</p>
<pre> <pre>
FRESULT f_read ( FRESULT f_read (
FIL* <em>FileObject</em>, /* ファイル・オブジェクト構造体 */ FIL* <em>FileObject</em>, <span>/* ファイル・オブジェクト構造体 */</span>
void* <em>Buffer</em>, /* 読み出したデータを格納するバッファ */ void* <em>Buffer</em>, <span>/* 読み出したデータを格納するバッファ */</span>
UINT <em>ByteToRead</em>, /* 読み出すバイト数 */ UINT <em>ByteToRead</em>, <span>/* 読み出すバイト数 */</span>
UINT* <em>ByteRead</em> /* 読み出されたバイト数 */ UINT* <em>ByteRead</em> <span>/* 読み出されたバイト数 */</span>
); );
</pre> </pre>
</div> </div>
@ -59,7 +60,7 @@ FRESULT f_read (
<div class="para"> <div class="para">
<h4>解説</h4> <h4>解説</h4>
<p>読み込み開始位置は、現在のファイルR/Wポインタからになります。ファイルR/Wポインタは読み込まれたバイト数だけ進みます。読み込み中にファイルの終端に達すると、<tt>*ByteRead</tt><tt>ByteToRead</tt>よりも小さくなります。</p> <p>読み込み開始位置は、現在のリード/ライト・ポインタからになります。リード/ライト・ポインタは読み込まれたバイト数だけ進みます。関数が正常終了した後は、<tt>*ByteRead</tt>の値をチェックすべきです。<tt>*ByteRead</tt><tt>ByteToRead</tt>よりも小さいときは、読み込み中にファイルの終端に達したことを示しています。</p>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/readdir.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>FatFs - f_readdir</title> <title>FatFs - f_readdir</title>
</head> </head>
@ -15,8 +16,8 @@
<p>ディレクトリ項目を読み出します</p> <p>ディレクトリ項目を読み出します</p>
<pre> <pre>
FRESULT f_readdir ( FRESULT f_readdir (
DIR* <em>DirObject</em>, /* ディレクトリ・ブジェクト構造体へのポインタ */ DIR* <em>DirObject</em>, <span>/* ディレクトリ・ブジェクト構造体へのポインタ */</span>
FILINFO* <em>FileInfo</em> /* ファイル情報構造体へのポインタ */ FILINFO* <em>FileInfo</em> <span>/* ファイル情報構造体へのポインタ */</span>
); );
</pre> </pre>
</div> </div>
@ -51,7 +52,7 @@ 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格納バッファにヌル文字列が返されます。</p> <p>LFN機能が有効な時は、f_readdir関数の呼び出しに先立ってFILINFO構造体の<tt>lfname</tt><tt>lfsize</tt>が有効な値で初期化されていなければなりません。<tt>lfname</tt>はLFNを格納するバッファで、<tt>lfsize</tt>はそのバッファ・サイズ(文字数)です。次の条件に一つでも該当する場合は、LFN格納バッファにヌル文字列が返されます。</p>
<ul> <ul>
<li>そのディレクトリ項目にLFNが存在しない。</li> <li>そのディレクトリ項目にLFNが存在しない。</li>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/rename.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>FatFs - f_rename</title> <title>FatFs - f_rename</title>
</head> </head>
@ -15,8 +16,8 @@
<p>ファイルまたはディレクトリの名前の変更または移動。</p> <p>ファイルまたはディレクトリの名前の変更または移動。</p>
<pre> <pre>
FRESULT f_rename ( FRESULT f_rename (
const XCHAR* <em>OldName</em>, /* 古いファイルまたはディレクトリ名 */ const TCHAR* <em>OldName</em>, <span>/* 古いファイルまたはディレクトリ名 */</span>
const XCHAR* <em>NewName</em> /* 新しいファイルまたはディレクトリ名 */ const TCHAR* <em>NewName</em> <span>/* 新しいファイルまたはディレクトリ名 */</span>
); );
</pre> </pre>
</div> </div>
@ -27,7 +28,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>
@ -60,7 +61,7 @@ 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>
@ -80,10 +81,10 @@ FRESULT f_rename (
<div class="para"> <div class="para">
<h4>使用例</h4> <h4>使用例</h4>
<pre> <pre>
/* ファイルまたはサブディレクトリの名前を変更する */ <span>/* ファイルまたはサブディレクトリの名前を変更する */</span>
f_rename("oldname.txt", "newname.txt"); f_rename("oldname.txt", "newname.txt");
/* ファイルまたはサブディレクトリの名前の変更と別のディレクトリへの移動 */ <span>/* ファイルまたはサブディレクトリの名前の変更と別のディレクトリへの移動 */</span>
f_rename("oldname.txt", "dir1/newname.txt"); f_rename("oldname.txt", "dir1/newname.txt");
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/sdir.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>FatFs - DIR</title> <title>FatFs - DIR</title>
</head> </head>
@ -14,18 +15,18 @@
<h2>DIR</h2> <h2>DIR</h2>
<p><tt>DIR</tt>構造体は、f_opendir(), f_readdir()のワーク・エリアとして使用されます。アプリケーションから変更可能なメンバはありません。</p> <p><tt>DIR</tt>構造体は、f_opendir(), f_readdir()のワーク・エリアとして使用されます。アプリケーションから変更可能なメンバはありません。</p>
<pre> <pre>
typedef struct _DIR_ { typedef struct {
FATFS* fs; /* Pointer to the owner file system object */ FATFS* fs; <span>/* 親ファイル・システム・オブジェクトへのポインタ */</span>
WORD id; /* Owner file system mount ID */ WORD id; <span>/* 親ファイル・システム・オブジェクトのマウントID */</span>
WORD index; /* Current index number */ WORD index; <span>/* 次に読み出すディレクトリ・インデックス番号 */</span>
DWORD sclust; /* Table start cluster (0:Static table) */ DWORD sclust; <span>/* ディレクトリ開始クラスタ (0:ルート) */</span>
DWORD clust; /* Current cluster */ DWORD clust; <span>/* 現在のクラスタ番号 */</span>
DWORD sect; /* Current sector */ DWORD sect; <span>/* 現在のセクタ番号 */</span>
BYTE* dir; /* Pointer to the current SFN entry in the win[] */ BYTE* dir; <span>/* 現在のSFNエントリへのポインタ */</span>
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ BYTE* fn; <span>/* SFNバッファへのポインタ (in/out) {file[8],ext[3],status[1]} */</span>
#if _USE_LFN #if _USE_LFN
WCHAR* lfn; /* Pointer to the LFN working buffer */ WCHAR* lfn; <span>/* LFNバッファへのポインタ */</span>
WORD lfn_idx; /* Last matched LFN index (0xFFFF:No LFN) */ WORD lfn_idx; <span>/* 最後にマッチしたLFNエントリのインデックス (0xFFFF:無効) */</span>
#endif #endif
} DIR; } DIR;
</pre> </pre>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/sfatfs.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>FatFs - FATFS</title> <title>FatFs - FATFS</title>
</head> </head>
@ -15,33 +16,36 @@
<p><tt>FATFS</tt>構造体は、個々の論理ドライブのダイナミック・ワーク・エリアを保持し、f_mount()でFatFsモジュールに登録されます。標準状態では次のようなメンバになっています。アプリケーションから書き換え可能なメンバはありません。</p> <p><tt>FATFS</tt>構造体は、個々の論理ドライブのダイナミック・ワーク・エリアを保持し、f_mount()でFatFsモジュールに登録されます。標準状態では次のようなメンバになっています。アプリケーションから書き換え可能なメンバはありません。</p>
<pre> <pre>
typedef struct _FATFS_ { typedef struct {
BYTE fs_type; /* FAT sub type */ BYTE fs_type; <span>/* FATタイプ */</span>
BYTE drive; /* Physical drive number */ BYTE drv; <span>/* 物理ドライブ番号 */</span>
BYTE csize; /* Number of sectors per cluster */ BYTE csize; <span>/* クラスタ当たりのセクタ数 */</span>
BYTE n_fats; /* Number of FAT copies */ BYTE n_fats; <span>/* FATの多重化数 */</span>
BYTE wflag; /* win[] dirty flag (1:must be written back) */ BYTE wflag; <span>/* win[]ダーティ・フラグ */</span>
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */ BYTE fsi_flag; <span>/* fsinfoダーティ・フラグ */</span>
WORD id; /* File system mount ID */ WORD id; <span>/* ファイル・システム・マウントID */</span>
WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */ WORD n_rootdir; <span>/* ルート・ディレクトリのエントリ数 (FAT12/16) */</span>
#if _FS_REENTRANT
HANDLE h_mutex; /* Handle to the mutex (Platform dependent) */
#endif
#if _MAX_SS != 512 #if _MAX_SS != 512
WORD s_size; /* Sector size */ WORD ssize; <span>/* セクタ・サイズ (可変セクタ長のみ) */</span>
#endif
#if _FS_REENTRANT
HANDLE h_mutex; <span>/* 同期オブジェクトID */</span>
#endif #endif
#if !_FS_READONLY #if !_FS_READONLY
DWORD last_clust; /* Last allocated cluster */ DWORD last_clust; <span>/* 最後に割り当てられたクラスタ番号 */</span>
DWORD free_clust; /* Number of free clusters */ DWORD free_clust; <span>/* 空きクラスタ数 */</span>
DWORD fsi_sector; /* fsinfo sector */ DWORD fsi_sector; <span>/* fsinfoセクタ (FAT32) */</span>
#endif #endif
DWORD sects_fat; /* Sectors per fat */ #if _FS_RPATH
DWORD max_clust; /* Maximum cluster# + 1. Number of clusters is max_clust - 2 */ DWORD cdir; <span>/* カレント・ディレクトリのクラスタ (0:ルート) */</span>
DWORD fatbase; /* FAT start sector */ #endif
DWORD dirbase; /* Root directory start sector (Cluster# on FAT32) */ DWORD n_fatent; <span>/* FATのエントリ数 (= クラスタ数 + 2) */</span>
DWORD database; /* Data start sector */ DWORD fsize; <span>/* FAT 1個当たりのセクタ数 */</span>
DWORD winsect; /* Current sector appearing in the win[] */ DWORD fatbase; <span>/* FAT領域開始セクタ */</span>
BYTE win[_MAX_SS]; /* Disk access window for Directory/FAT */ DWORD dirbase; <span>/* ルート・ディレクトリ開始セクタ (FAT32: クラスタ番号) */</span>
DWORD database; <span>/* データ領域開始区セクタ */</span>
DWORD winsect; <span>/* win[]に現れているセクタ番号 */</span>
BYTE win[_MAX_SS]; <span>/* ディスク・アクセス・ウィンドウ */</span>
} FATFS; } FATFS;
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/sfile.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>FatFs - FIL</title> <title>FatFs - FIL</title>
</head> </head>
@ -12,25 +13,31 @@
<div class="para"> <div class="para">
<h2>FIL</h2> <h2>FIL</h2>
<p><tt>FIL</tt>構造体は、f_open()で作成され、そのファイルの状態を保持します。アプリケーションから書き換え可能なメンバはありません</p> <p><tt>FIL</tt>構造体は、f_open関数で作成され、そのファイルの状態を保持します。また、f_close関数でファイルが閉じられると無効化されます。アプリケーションからの書き換えが可能なメンバは<tt>cltbl</tt>のみです。非タイニー構成では内部にセクタ・バッファが確保されるので、サイズに注意が必要です</p>
<pre> <pre>
typedef struct _FIL_ { typedef struct {
FATFS* fs; /* Pointer to the owner file system object */ FATFS* fs; <span>/* 親ファイル・システム・オブジェクトへのポインタ */</span>
WORD id; /* Owner file system mount ID */ WORD id; <span>/* 親ファイル・システム・オブジェクトのマウントID */</span>
BYTE flag; /* File status flags */ BYTE flag; <span>/* ファイル・ステータス・フラグ */</span>
BYTE csect; /* Sector address in the cluster */ BYTE pad1;
DWORD fptr; /* File R/W pointer */ DWORD fptr; <span>/* ファイル読み書きポインタ(ファイル先頭からのバイト・オフセット) */</span>
DWORD fsize; /* File size */ DWORD fsize; <span>/* ファイル・サイズ(バイト単位) */</span>
DWORD org_clust; /* File start cluster */ DWORD org_clust; <span>/* ファイル開始クラスタ番号 (0: fsize==0) */</span>
DWORD curr_clust; /* Current cluster */ DWORD curr_clust; <span>/* 現在のクラスタ */</span>
DWORD dsect; /* Current data sector */ DWORD dsect; <span>/* 現在のデータ・セクタ */</span>
#if _FS_READONLY == 0 #if _FS_READONLY == 0
DWORD dir_sect; /* Sector containing the directory entry */ DWORD dir_sect; <span>/* このファイルのディレクトリ・エントリのあるセクタ */</span>
BYTE* dir_ptr; /* Ponter to the directory entry in the window */ BYTE* dir_ptr; <span>/* このファイルのディレクトリへのポインタ */</span>
#endif
#if _USE_FASTSEEK
DWORD* cltbl; <span>/* ファイルのクラスタ・リンク情報へのポインタ */</span>
#endif
#if _FS_SHARE
UINT lockid; <span>/* ファイル・ロックID */</span>
#endif #endif
#if !_FS_TINY #if !_FS_TINY
BYTE buf[_MAX_SS]; /* File R/W buffer */ BYTE buf[_MAX_SS]; <span>/* データ転送バッファ */</span>
#endif #endif
} FIL; } FIL;
</pre> </pre>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/sfileinfo.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>FatFs - FILINFO</title> <title>FatFs - FILINFO</title>
</head> </head>
@ -14,15 +15,15 @@
<h2>FILINFO</h2> <h2>FILINFO</h2>
<p><tt>FILINFO</tt>構造体は、<tt>f_stat(), f_readdir()</tt>で返されるファイル情報を保持します。</p> <p><tt>FILINFO</tt>構造体は、<tt>f_stat(), f_readdir()</tt>で返されるファイル情報を保持します。</p>
<pre> <pre>
typedef struct _FILINFO_ { typedef struct {
DWORD fsize; /* File size */ DWORD fsize; <span>/* ファイル・サイズ */</span>
WORD fdate; /* Last modified date */ WORD fdate; <span>/* 最後に更新された日付 */</span>
WORD ftime; /* Last modified time */ WORD ftime; <span>/* 最後に更新された時刻 */</span>
BYTE fattrib; /* Attribute */ BYTE fattrib; <span>/* アトリビュート */</span>
char fname[13]; /* Short file name (8.3 format) */ TCHAR fname[13]; <span>/* 短いファイル名 (8.3フォーマット) */</span>
#if _USE_LFN #if _USE_LFN
XCHAR* lfname; /* Pointer to the LFN buffer */ TCHAR* lfname; <span>/* 長いファイル名のバッファへのポインタ */</span>
int lfsize; /* Size of LFN buffer [characters] */ int lfsize; <span>/* 長いファイル名のバッファのサイズ [文字数] */</span>
#endif #endif
} FILINFO; } FILINFO;
</pre> </pre>
@ -59,7 +60,7 @@ typedef struct _FILINFO_ {
<dt>fname[]</dt> <dt>fname[]</dt>
<dd>8.3形式の名前が<tt>'\0'</tt>で終わる文字列として格納されます。非LFN構成のときは、常に大文字で返されます。LFN構成のときは短い名前が返されますが、ASCII英字が小文字になる場合があります。</dd> <dd>8.3形式の名前が<tt>'\0'</tt>で終わる文字列として格納されます。非LFN構成のときは、常に大文字で返されます。LFN構成のときは短い名前が返されますが、ASCII英字が小文字になる場合があります。</dd>
<dt>lfname</dt> <dt>lfname</dt>
<dd>返される長いファイル名を格納するバッファへのポインタ。この構造体を使用する前にアプリケーションにより初期化されなければなりません。非LFN構成のときはこのメンバは存在しません。</dd> <dd>返される長いファイル名を格納するバッファへのポインタ。この構造体を使用する前にアプリケーションにより初期化されなければなりません。このメンバにNULLが設定されるとLFNは返されません。非LFN構成のときはこのメンバは存在しません。</dd>
<dt>lfsize</dt> <dt>lfsize</dt>
<dd>長いファイル名を格納するバッファのサイズ(文字数)。この構造体を使用する前にアプリケーションにより初期化されなければなりません。非LFN構成のときはこのメンバは存在しません。</dd> <dd>長いファイル名を格納するバッファのサイズ(文字数)。この構造体を使用する前にアプリケーションにより初期化されなければなりません。非LFN構成のときはこのメンバは存在しません。</dd>
</dl> </dl>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/stat.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>FatFs - f_stat</title> <title>FatFs - f_stat</title>
</head> </head>
@ -14,8 +15,8 @@
<h2>f_stat</h2> <h2>f_stat</h2>
<pre> <pre>
FRESULT f_stat ( FRESULT f_stat (
const char* <em>FileName</em>, /* ファイルまたはディレクトリ名へのポインタ */ const TCHAR* <em>FileName</em>, <span>/* ファイルまたはディレクトリ名へのポインタ */</span>
FILINFO* <em>FileInfo</em> /* ファイル情報構造体へのポインタ * FILINFO* <em>FileInfo</em> <span>/* ファイル情報構造体へのポインタ *
); );
</pre> </pre>
</div> </div>
@ -43,7 +44,7 @@ FRESULT f_stat (
<dt>FR_INVALID_NAME</dt> <dt>FR_INVALID_NAME</dt>
<dd>パス名が不正。</dd> <dd>パス名が不正。</dd>
<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>
@ -53,7 +54,7 @@ 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>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/sync.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>FatFs - f_sync</title> <title>FatFs - f_sync</title>
</head> </head>
@ -15,7 +16,7 @@
<p>書き込み中のファイルのキャッシュされた情報をフラッシュします。</p> <p>書き込み中のファイルのキャッシュされた情報をフラッシュします。</p>
<pre> <pre>
FRESULT f_sync ( FRESULT f_sync (
FIL* <em>FileObject</em> /* ファイル・オブジェクト構造体へのポインタ */ FIL* <em>FileObject</em> <span>/* ファイル・オブジェクト構造体へのポインタ */</span>
); );
</pre> </pre>
</div> </div>
@ -48,7 +49,7 @@ 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>と同じ処理を実行しますが、ファイルは引き続き開かれたままになり、読み書きを続行できます。ロギングなど、書き込みモードで長時間ファイルが開かれているアプリケーションにおいて、定期的または区切りの良いところでこの関数を使用することにより、不意の電源断やメディアの取り外しにより失われるデータを最小にすることができます。実際のところ、<tt>f_close()</tt>内ではこの関数を呼び出した後ファイル・オブジェクトを無効化しているだけなので、<tt>f_close()</tt>直前の<tt>f_sync()</tt>は意味がありません。</p>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/truncate.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>FatFs - f_truncate</title> <title>FatFs - f_truncate</title>
</head> </head>
@ -15,7 +16,7 @@
<p>ファイル長を切り詰めます。</p> <p>ファイル長を切り詰めます。</p>
<pre> <pre>
FRESULT f_truncate ( FRESULT f_truncate (
FIL* <em>FileObject</em> /* ファイル・オブジェクトへのポインタ */ FIL* <em>FileObject</em> <span>/* ファイル・オブジェクトへのポインタ */</span>
); );
</pre> </pre>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/unlink.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>FatFs - f_unlink</title> <title>FatFs - f_unlink</title>
</head> </head>
@ -15,7 +16,7 @@
<p>オブジェクトを削除します。</p> <p>オブジェクトを削除します。</p>
<pre> <pre>
FRESULT f_unlink ( FRESULT f_unlink (
const XCHAR* <em>FileName</em> /* オブジェクト名へのポインタ */ const TCHAR* <em>FileName</em> <span>/* オブジェクト名へのポインタ */</span>
); );
</pre> </pre>
</div> </div>
@ -55,7 +56,9 @@ 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>
<dt>FR_LOCKED</dt>
<dd>ファイル共有機能によるアクセス拒否。</dd>
</dl> </dl>
</div> </div>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/utime.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>FatFs - f_utime</title> <title>FatFs - f_utime</title>
</head> </head>
@ -15,8 +16,8 @@
<p>オブジェクトのタイムスタンプを変更します。</p> <p>オブジェクトのタイムスタンプを変更します。</p>
<pre> <pre>
FRESULT f_utime ( FRESULT f_utime (
const XCHAR* <em>FileName</em>, /* オブジェクト名へのポインタ */ const TCHAR* <em>FileName</em>, <span>/* オブジェクト名へのポインタ */</span>
const FILINFO* <em>TimeDate</em> /* 設定する日付 */ const FILINFO* <em>TimeDate</em> <span>/* 設定する日付 */</span>
); );
</pre> </pre>
</div> </div>
@ -44,7 +45,7 @@ FRESULT f_utime (
<dt>FR_INVALID_NAME</dt> <dt>FR_INVALID_NAME</dt>
<dd>パス名が不正。</dd> <dd>パス名が不正。</dd>
<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>
@ -56,7 +57,7 @@ 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>
@ -67,6 +68,30 @@ FRESULT f_utime (
</div> </div>
<div class="para">
<h4>使用例</h4>
<pre>
FRESULT set_timestamp (
char *obj, <span>/* ファイル名へのポインタ */</span>
int year,
int month,
int mday,
int hour,
int min,
int sec
)
{
FILINFO fno;
fno.fdate = (WORD)(((year - 1980) * 512U) | month * 32U | mday);
fno.ftime = (WORD)(hour * 2048U | min * 32U | sec / 2U);
return f_utime(obj, &fno);
}
</pre>
</div>
<div class="para"> <div class="para">
<h4>対応情報</h4> <h4>対応情報</h4>
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_FS_MINIMIZE == 0</tt>のときに使用可能です。</p> <p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_FS_MINIMIZE == 0</tt>のときに使用可能です。</p>

View File

@ -4,6 +4,7 @@
<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="up" title="FatFs" href="../00index_j.html"> <link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/write.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>FatFs - f_write</title> <title>FatFs - f_write</title>
</head> </head>
@ -15,10 +16,10 @@
<p>ファイルにデータを書き込みます。</p> <p>ファイルにデータを書き込みます。</p>
<pre> <pre>
FRESULT f_write ( FRESULT f_write (
FIL* <em>FileObject</em>, /* ファイル・オブジェクト */ FIL* <em>FileObject</em>, <span>/* ファイル・オブジェクト */</span>
const void* <em>Buffer</em>, /* 書き込みデータ */ const void* <em>Buffer</em>, <span>/* 書き込みデータ */</span>
UINT <em>ByteToWrite</em>, /* 書き込むバイト数 */ UINT <em>ByteToWrite</em>, <span>/* 書き込むバイト数 */</span>
UINT* <em>ByteWritten</em> /* 書き込まれたバイト数 */ UINT* <em>ByteWritten</em> <span>/* 書き込まれたバイト数 */</span>
); );
</pre> </pre>
</div> </div>
@ -59,7 +60,7 @@ FRESULT f_write (
<div class="para"> <div class="para">
<h4>解説</h4> <h4>解説</h4>
<p>書き込み開始位置は、ファイルR/Wポインタの位置からになります。ファイルR/Wポインタは実際に書き込まれたバイト数だけ進みます。関数が正常終了した後、要求したバイト数が書き込まれたかどうか<tt>*ByteWritten</tt>をチェックすべきです。<tt>*ByteWritten &lt; ByteToWrite</tt>のときは、ディスク・フルを意味します。</p> <p>書き込み開始位置は、リード/ライト・ポインタの位置からになります。リード/ライト・ポインタは実際に書き込まれたバイト数だけ進みます。関数が正常終了した後、要求したバイト数が書き込まれたかどうか<tt>*ByteWritten</tt>をチェックすべきです。<tt>*ByteWritten &lt; ByteToWrite</tt>のときは、ディスク・フルを意味します。ディスク・フルが発生しているときまたはそれに近いときは、制御が帰るまで時間がかかる場合があります。</p>
</div> </div>

View File

@ -1,3 +1,11 @@
R0.08, May 15, 2010
Added a memory configuration option. (_USE_LFN)
Added file lock feature. (_FS_SHARE)
Added fast seek feature. (_USE_FASTSEEK)
Changed some types on the API, XCHAR->TCHAR.
Changed fname member in the FILINFO structure on Unicode cfg.
String functions support UTF-8 encoding files on Unicode cfg.
R0.07e, Nov 3, 2009 R0.07e, Nov 3, 2009
Separated out configuration options from ff.h to ffconf.h. Separated out configuration options from ff.h to ffconf.h.
Added a configuration option, _LFN_UNICODE. Added a configuration option, _LFN_UNICODE.

View File

@ -1,4 +1,4 @@
FatFs Module Source Files R0.07e (C)ChaN, 2009 FatFs Module Source Files R0.08 (C)ChaN, 2010
FILES FILES
@ -24,7 +24,7 @@ AGREEMENTS
small embedded systems. This is a free software and is opened for education, small embedded systems. This is a free software and is opened for education,
research and commercial developments under license policy of following trems. research and commercial developments under license policy of following trems.
Copyright (C) 2009, ChaN, all right reserved. Copyright (C) 2010, ChaN, all right reserved.
* The FatFs module is a free software and there is NO WARRANTY. * The FatFs module is a free software and there is NO WARRANTY.
* No restriction on use. You can use, modify and redistribute it for * No restriction on use. You can use, modify and redistribute it for
@ -103,8 +103,15 @@ REVISION HISTORY
Added f_chdrive(). Added f_chdrive().
Added proper case conversion for extended characters. Added proper case conversion for extended characters.
Nov 03,'2009 R0.07e Separated out configuration options from ff.h to ffconf.h. Nov 03, 2009 R0.07e Separated out configuration options from ff.h to ffconf.h.
Added a configuration option, _LFN_UNICODE. Added a configuration option, _LFN_UNICODE.
Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH. Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
Fixed name matching error on the 13 char boundary. Fixed name matching error on the 13 char boundary.
Changed f_readdir() to return the SFN with always upper case on non-LFN cfg. Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
May 15, 2010, R0.08 Added a memory configuration option. (_USE_LFN)
Added file lock feature. (_FS_SHARE)
Added fast seek feature. (_USE_FASTSEEK)
Changed some types on the API, XCHAR->TCHAR.
Changed fname member in the FILINFO structure on Unicode cfg.
String functions support UTF-8 encoding files on Unicode cfg.

View File

@ -9,6 +9,7 @@
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* Correspondence between physical drive number and physical drive. */ /* Correspondence between physical drive number and physical drive. */
/*-----------------------------------------------------------------------*/
#define ATA 0 #define ATA 0
#define MMC 1 #define MMC 1
@ -18,6 +19,7 @@
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* Inidialize a Drive */ /* Inidialize a Drive */
/*-----------------------------------------------------------------------*/
DSTATUS disk_initialize ( DSTATUS disk_initialize (
BYTE drv /* Physical drive nmuber (0..) */ BYTE drv /* Physical drive nmuber (0..) */
@ -52,6 +54,7 @@ DSTATUS disk_initialize (
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* Return Disk Status */ /* Return Disk Status */
/*-----------------------------------------------------------------------*/
DSTATUS disk_status ( DSTATUS disk_status (
BYTE drv /* Physical drive nmuber (0..) */ BYTE drv /* Physical drive nmuber (0..) */
@ -86,6 +89,7 @@ DSTATUS disk_status (
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* Read Sector(s) */ /* Read Sector(s) */
/*-----------------------------------------------------------------------*/
DRESULT disk_read ( DRESULT disk_read (
BYTE drv, /* Physical drive nmuber (0..) */ BYTE drv, /* Physical drive nmuber (0..) */
@ -123,6 +127,12 @@ DRESULT disk_read (
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* Write Sector(s) */ /* Write Sector(s) */
/*-----------------------------------------------------------------------*/
/* The FatFs module will issue multiple sector transfer request
/ (count > 1) to the disk I/O layer. The disk function should process
/ the multiple sector transfer properly Do. not translate it into
/ multiple single sector transfers to the media, or the data read/write
/ performance may be drasticaly decreased. */
#if _READONLY == 0 #if _READONLY == 0
DRESULT disk_write ( DRESULT disk_write (
@ -162,6 +172,7 @@ DRESULT disk_write (
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* Miscellaneous Functions */ /* Miscellaneous Functions */
/*-----------------------------------------------------------------------*/
DRESULT disk_ioctl ( DRESULT disk_ioctl (
BYTE drv, /* Physical drive nmuber (0..) */ BYTE drv, /* Physical drive nmuber (0..) */

View File

@ -26,7 +26,6 @@ typedef enum {
/*---------------------------------------*/ /*---------------------------------------*/
/* Prototypes for disk control functions */ /* Prototypes for disk control functions */
BOOL assign_drives (int argc, char *argv[]);
DSTATUS disk_initialize (BYTE); DSTATUS disk_initialize (BYTE);
DSTATUS disk_status (BYTE); DSTATUS disk_status (BYTE);
DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE); DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE);

2006
src/ff.c

File diff suppressed because it is too large Load Diff

359
src/ff.h
View File

@ -1,25 +1,30 @@
/*---------------------------------------------------------------------------/ /*---------------------------------------------------------------------------/
/ FatFs - FAT file system module include file R0.07e (C)ChaN, 2009 / FatFs - FAT file system module include file R0.08 (C)ChaN, 2010
/----------------------------------------------------------------------------/ /----------------------------------------------------------------------------/
/ FatFs module is a generic FAT file system module for small embedded systems. / 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 / This is a free software that opened for education, 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) 2010, ChaN, all right reserved.
/ /
/ * The FatFs module is a free software and there is NO WARRANTY. / * The FatFs module is a free software and there is NO WARRANTY.
/ * No restriction on use. You can use, modify and redistribute it for / * No restriction on use. You can use, modify and redistribute it for
/ personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY. / personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
/ * Redistributions of source code must retain the above copyright notice. / * Redistributions of source code must retain the above copyright notice.
/
/----------------------------------------------------------------------------*/ /----------------------------------------------------------------------------*/
#ifndef _FATFS #ifndef _FATFS
#define _FATFS 0x007E #define _FATFS 8085 /* Revision ID */
#ifdef __cplusplus
extern "C" {
#endif
#include "integer.h" /* Basic integer types */ #include "integer.h" /* Basic integer types */
#include "ffconf.h" /* FatFs configuration options */ #include "ffconf.h" /* FatFs configuration options */
#if _FATFS != _FFCONFIG #if _FATFS != _FFCONF
#error Wrong configuration file (ffconf.h). #error Wrong configuration file (ffconf.h).
#endif #endif
@ -219,50 +224,18 @@
/* Character code support macros */ /* Definitions corresponds to volume management */
#define IsUpper(c) (((c)>='A')&&((c)<='Z'))
#define IsLower(c) (((c)>='a')&&((c)<='z'))
#if _DF1S /* DBCS configuration */
#ifdef _DF2S /* Two 1st byte areas */
#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E))
#else /* One 1st byte area */
#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E)
#endif
#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))
#else /* Two 2nd byte areas */
#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E))
#endif
#else /* SBCS configuration */
#define IsDBCS1(c) 0
#define IsDBCS2(c) 0
#endif /* _DF1S */
/* Definitions corresponds to multi partition */
#if _MULTI_PARTITION /* Multiple partition configuration */ #if _MULTI_PARTITION /* Multiple partition configuration */
#define LD2PD(drv) (Drives[drv].pd) /* Get physical drive# */
typedef struct _PARTITION { #define LD2PT(drv) (Drives[drv].pt) /* Get partition# */
typedef struct {
BYTE pd; /* Physical drive# */ BYTE pd; /* Physical drive# */
BYTE pt; /* Partition # (0-3) */ BYTE pt; /* Partition # (0-3) */
} PARTITION; } PARTITION;
extern const PARTITION Drives[]; /* Logical drive# to physical location conversion table */
extern
const PARTITION Drives[]; /* Logical drive# to physical location conversion table */
#define LD2PD(drv) (Drives[drv].pd) /* Get physical drive# */
#define LD2PT(drv) (Drives[drv].pt) /* Get partition# */
#else /* Single partition configuration */ #else /* Single partition configuration */
#define LD2PD(drv) (drv) /* Physical drive# is equal to the logical drive# */ #define LD2PD(drv) (drv) /* Physical drive# is equal to the logical drive# */
#define LD2PT(drv) 0 /* Always mounts the 1st partition */ #define LD2PT(drv) 0 /* Always mounts the 1st partition */
@ -270,120 +243,142 @@ const PARTITION Drives[]; /* Logical drive# to physical location conversion ta
/* Definitions corresponds to multiple sector size */ /* Type of path name strings on FatFs API */
#if _MAX_SS == 512 /* Single sector size */ #if _LFN_UNICODE /* Unicode string */
#define SS(fs) 512U #if !_USE_LFN
#error _LFN_UNICODE must be 0 in non-LFN cfg.
#endif
#ifndef _INC_TCHAR
typedef WCHAR TCHAR;
#define _T(x) L ## x
#define _TEXT(x) L ## x
#endif
#elif _MAX_SS == 1024 || _MAX_SS == 2048 || _MAX_SS == 4096 /* Multiple sector size */ #else /* ANSI/OEM string */
#define SS(fs) ((fs)->s_size) #ifndef _INC_TCHAR
typedef char TCHAR;
#else #define _T(x) x
#error Sector size must be 512, 1024, 2048 or 4096. #define _TEXT(x) x
#endif
#endif #endif
/* Type of file name on FatFs API */ /* Definitions corresponds to file shareing feature */
#if _LFN_UNICODE && _USE_LFN #if _FS_SHARE
typedef WCHAR XCHAR; /* Unicode */ #if _FS_READONLY
#else #error _FS_SHARE must be 0 on R/O cfg.
typedef char XCHAR; /* SBCS, DBCS */ #endif
typedef struct {
DWORD clu; /* File ID 1, directory */
WORD idx; /* File ID 2, index in the directory */
WORD ctr; /* File open counter, 0:none, 0x01..0xFF:read open count, 0x100:in write open */
} FILESEM;
#endif #endif
/* File system object structure */ /* File system object structure (FATFS) */
typedef struct _FATFS_ { typedef struct {
BYTE fs_type; /* FAT sub type */ BYTE fs_type; /* FAT sub-type (0:Not mounted) */
BYTE drive; /* Physical drive number */ BYTE drv; /* Physical drive number */
BYTE csize; /* Number of sectors per cluster */ BYTE csize; /* Sectors per cluster (1,2,4...128) */
BYTE n_fats; /* Number of FAT copies */ BYTE n_fats; /* Number of FAT copies (1,2) */
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) */ 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 (FAT12/16) */
#if _FS_REENTRANT
_SYNC_t sobj; /* Identifier of sync object */
#endif
#if _MAX_SS != 512 #if _MAX_SS != 512
WORD s_size; /* Sector size */ WORD ssize; /* Bytes per sector (512,1024,2048,4096) */
#endif
#if _FS_REENTRANT
_SYNC_t sobj; /* Identifier of sync object */
#endif #endif
#if !_FS_READONLY #if !_FS_READONLY
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 (FAT32) */
#endif #endif
#if _FS_RPATH #if _FS_RPATH
DWORD cdir; /* Current directory (0:root)*/ DWORD cdir; /* Current directory start cluster (0:root) */
#endif
DWORD n_fatent; /* Number of FAT entries (= number of clusters + 2) */
DWORD fsize; /* Sectors per FAT */
DWORD fatbase; /* FAT start sector */
DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */
DWORD database; /* Data start sector */
DWORD winsect; /* Current sector appearing in the win[] */
BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and Data on tiny cfg) */
#if _FS_SHARE
FILESEM flsem[_FS_SHARE]; /* File lock semaphores */
#endif #endif
DWORD sects_fat; /* Sectors per fat */
DWORD max_clust; /* Maximum cluster# + 1. Number of clusters is max_clust - 2 */
DWORD fatbase; /* FAT start sector */
DWORD dirbase; /* Root directory start sector (Cluster# on FAT32) */
DWORD database; /* Data start sector */
DWORD winsect; /* Current sector appearing in the win[] */
BYTE win[_MAX_SS];/* Disk access window for Directory/FAT */
} FATFS; } FATFS;
/* Directory object structure */ /* File object structure (FIL) */
typedef struct _DIR_ { typedef struct {
FATFS* fs; /* Pointer to the owner file system object */ FATFS* fs; /* Pointer to the owner file system object */
WORD id; /* Owner file system mount ID */ WORD id; /* Owner file system mount ID */
WORD index; /* Current read/write index number */ BYTE flag; /* File status flags */
DWORD sclust; /* Table start cluster (0:Static table) */ BYTE pad1;
DWORD clust; /* Current cluster */ DWORD fptr; /* File read/write pointer */
DWORD sect; /* Current sector */ DWORD fsize; /* File size */
BYTE* dir; /* Pointer to the current SFN entry in the win[] */ DWORD org_clust; /* File start cluster (0 when fsize==0) */
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ DWORD curr_clust; /* Current cluster */
#if _USE_LFN DWORD dsect; /* Current data sector */
WCHAR* lfn; /* Pointer to the LFN working buffer */
WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
#endif
} DIR;
/* File object structure */
typedef struct _FIL_ {
FATFS* fs; /* Pointer to the owner file system object */
WORD id; /* Owner file system mount ID */
BYTE flag; /* File status flags */
BYTE csect; /* Sector address in the cluster */
DWORD fptr; /* File R/W pointer */
DWORD fsize; /* File size */
DWORD org_clust; /* File start cluster */
DWORD curr_clust; /* Current cluster */
DWORD dsect; /* Current data sector */
#if !_FS_READONLY #if !_FS_READONLY
DWORD dir_sect; /* Sector containing the directory entry */ DWORD dir_sect; /* Sector containing the directory entry */
BYTE* dir_ptr; /* Ponter to the directory entry in the window */ BYTE* dir_ptr; /* Ponter to the directory entry in the window */
#endif
#if _USE_FASTSEEK
DWORD* cltbl; /* Pointer to the cluster link map table */
#endif
#if _FS_SHARE
UINT lockid; /* File lock ID */
#endif #endif
#if !_FS_TINY #if !_FS_TINY
BYTE buf[_MAX_SS];/* File R/W buffer */ BYTE buf[_MAX_SS]; /* File data read/write buffer */
#endif #endif
} FIL; } FIL;
/* File status structure */ /* Directory object structure (DIR) */
typedef struct _FILINFO_ { typedef struct {
DWORD fsize; /* File size */ FATFS* fs; /* Pointer to the owner file system object */
WORD fdate; /* Last modified date */ WORD id; /* Owner file system mount ID */
WORD ftime; /* Last modified time */ WORD index; /* Current read/write index number */
BYTE fattrib; /* Attribute */ DWORD sclust; /* Table start cluster (0:Root dir) */
char fname[13]; /* Short file name (8.3 format) */ DWORD clust; /* Current cluster */
DWORD sect; /* Current sector */
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
#if _USE_LFN #if _USE_LFN
XCHAR* lfname; /* Pointer to the LFN buffer */ WCHAR* lfn; /* Pointer to the LFN working buffer */
int lfsize; /* Size of LFN buffer [chrs] */ WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
#endif
} DIR;
/* File status structure (FILINFO) */
typedef struct {
DWORD fsize; /* File size */
WORD fdate; /* Last modified date */
WORD ftime; /* Last modified time */
BYTE fattrib; /* Attribute */
TCHAR fname[13]; /* Short file name (8.3 format) */
#if _USE_LFN
TCHAR* lfname; /* Pointer to the LFN buffer */
int lfsize; /* Size of LFN buffer [chrs] */
#endif #endif
} FILINFO; } FILINFO;
@ -392,22 +387,25 @@ typedef struct _FILINFO_ {
/* File function return code (FRESULT) */ /* File function return code (FRESULT) */
typedef enum { typedef enum {
FR_OK = 0, /* 0 */ FR_OK = 0, /* (0) Succeeded */
FR_DISK_ERR, /* 1 */ FR_DISK_ERR, /* (1) A hard error occured in the low level disk I/O layer */
FR_INT_ERR, /* 2 */ FR_INT_ERR, /* (2) Assertion failed */
FR_NOT_READY, /* 3 */ FR_NOT_READY, /* (3) The physical drive cannot work */
FR_NO_FILE, /* 4 */ FR_NO_FILE, /* (4) Could not find the file */
FR_NO_PATH, /* 5 */ FR_NO_PATH, /* (5) Could not find the path */
FR_INVALID_NAME, /* 6 */ FR_INVALID_NAME, /* (6) The path name format is invalid */
FR_DENIED, /* 7 */ FR_DENIED, /* (7) Acces denied due to prohibited access or directory full */
FR_EXIST, /* 8 */ FR_EXIST, /* (8) Acces denied due to prohibited access */
FR_INVALID_OBJECT, /* 9 */ FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
FR_WRITE_PROTECTED, /* 10 */ FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
FR_INVALID_DRIVE, /* 11 */ FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
FR_NOT_ENABLED, /* 12 */ FR_NOT_ENABLED, /* (12) The volume has no work area */
FR_NO_FILESYSTEM, /* 13 */ FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume on the physical drive */
FR_MKFS_ABORTED, /* 14 */ FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
FR_TIMEOUT /* 15 */ FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
FR_LOCKED, /* (16) The operation is rejected according to the file shareing policy */
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
FR_TOO_MANY_OPEN_FILES /* (18) Number of open files > _FS_SHARE */
} FRESULT; } FRESULT;
@ -416,66 +414,77 @@ typedef enum {
/* FatFs module application interface */ /* FatFs module application interface */
FRESULT f_mount (BYTE, FATFS*); /* Mount/Unmount a logical drive */ FRESULT f_mount (BYTE, FATFS*); /* Mount/Unmount a logical drive */
FRESULT f_open (FIL*, const XCHAR*, BYTE); /* Open or create a file */ FRESULT f_open (FIL*, const TCHAR*, BYTE); /* Open or create a file */
FRESULT f_read (FIL*, void*, UINT, UINT*); /* Read data from a file */ FRESULT f_read (FIL*, void*, UINT, UINT*); /* Read data from a file */
FRESULT f_write (FIL*, const void*, UINT, UINT*); /* Write data to a file */
FRESULT f_lseek (FIL*, DWORD); /* Move file pointer of a file object */ FRESULT f_lseek (FIL*, DWORD); /* Move file pointer of a file object */
FRESULT f_close (FIL*); /* Close an open file object */ FRESULT f_close (FIL*); /* Close an open file object */
FRESULT f_opendir (DIR*, const XCHAR*); /* Open an existing directory */ FRESULT f_opendir (DIR*, const TCHAR*); /* Open an existing directory */
FRESULT f_readdir (DIR*, FILINFO*); /* Read a directory item */ FRESULT f_readdir (DIR*, FILINFO*); /* Read a directory item */
FRESULT f_stat (const XCHAR*, FILINFO*); /* Get file status */ FRESULT f_stat (const TCHAR*, FILINFO*); /* Get file status */
FRESULT f_getfree (const XCHAR*, DWORD*, FATFS**); /* Get number of free clusters on the drive */ #if !_FS_READONLY
FRESULT f_write (FIL*, const void*, UINT, UINT*); /* Write data to a file */
FRESULT f_getfree (const TCHAR*, DWORD*, FATFS**); /* Get number of free clusters on the drive */
FRESULT f_truncate (FIL*); /* Truncate file */ FRESULT f_truncate (FIL*); /* Truncate file */
FRESULT f_sync (FIL*); /* Flush cached data of a writing file */ FRESULT f_sync (FIL*); /* Flush cached data of a writing file */
FRESULT f_unlink (const XCHAR*); /* Delete an existing file or directory */ FRESULT f_unlink (const TCHAR*); /* Delete an existing file or directory */
FRESULT f_mkdir (const XCHAR*); /* Create a new directory */ FRESULT f_mkdir (const TCHAR*); /* Create a new directory */
FRESULT f_chmod (const XCHAR*, BYTE, BYTE); /* Change attriburte of the file/dir */ FRESULT f_chmod (const TCHAR*, BYTE, BYTE); /* Change attriburte of the file/dir */
FRESULT f_utime (const XCHAR*, const FILINFO*); /* Change timestamp of the file/dir */ FRESULT f_utime (const TCHAR*, const FILINFO*); /* Change timestamp of the file/dir */
FRESULT f_rename (const XCHAR*, const XCHAR*); /* Rename/Move a file or directory */ FRESULT f_rename (const TCHAR*, const TCHAR*); /* Rename/Move a file or directory */
#endif
#if _USE_FORWARD
FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*); /* Forward data to the stream */ FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*); /* Forward data to the stream */
FRESULT f_mkfs (BYTE, BYTE, WORD); /* Create a file system on the drive */ #endif
FRESULT f_chdir (const XCHAR*); /* Change current directory */ #if _USE_MKFS
FRESULT f_mkfs (BYTE, BYTE, UINT); /* Create a file system on the drive */
#endif
#if _FS_RPATH
FRESULT f_chdir (const TCHAR*); /* Change current directory */
FRESULT f_chdrive (BYTE); /* Change current drive */ FRESULT f_chdrive (BYTE); /* Change current drive */
#endif
#if _USE_STRFUNC #if _USE_STRFUNC
int f_putc (int, FIL*); /* Put a character to the file */ int f_putc (TCHAR, FIL*); /* Put a character to the file */
int f_puts (const char*, FIL*); /* Put a string to the file */ int f_puts (const TCHAR*, FIL*); /* Put a string to the file */
int f_printf (FIL*, const char*, ...); /* Put a formatted string to the file */ int f_printf (FIL*, const TCHAR*, ...); /* Put a formatted string to the file */
char* f_gets (char*, int, FIL*); /* Get a string from the file */ TCHAR* f_gets (TCHAR*, int, FIL*); /* Get a string from the file */
#define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0) #define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
#define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0) #define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
#ifndef EOF #ifndef EOF
#define EOF -1 #define EOF (-1)
#endif #endif
#endif #endif
/*--------------------------------------------------------------*/ /*--------------------------------------------------------------*/
/* User defined functions */ /* Additional user defined functions */
/* Real time clock */ /* RTC function */
#if !_FS_READONLY #if !_FS_READONLY
DWORD get_fattime (void); /* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20-16: Day(1-31) */ DWORD get_fattime (void);
/* 15-11: Hour(0-23), 10-5: Minute(0-59), 4-0: Second(0-29 *2) */
#endif #endif
/* Unicode - OEM code conversion */ /* Unicode support functions */
#if _USE_LFN #if _USE_LFN /* Unicode - OEM code conversion */
WCHAR ff_convert (WCHAR, UINT); WCHAR ff_convert (WCHAR, UINT); /* OEM-Unicode bidirectional conversion */
WCHAR ff_wtoupper (WCHAR); WCHAR ff_wtoupper (WCHAR); /* Unicode upper-case conversion */
#if _USE_LFN == 3 /* Memory functions */
void* ff_memalloc (UINT); /* Allocate memory block */
void ff_memfree (void*); /* Free memory block */
#endif
#endif #endif
/* Sync functions */ /* Sync functions */
#if _FS_REENTRANT #if _FS_REENTRANT
BOOL ff_cre_syncobj(BYTE, _SYNC_t*); int ff_cre_syncobj (BYTE, _SYNC_t*);/* Create a sync object */
BOOL ff_del_syncobj(_SYNC_t); int ff_del_syncobj (_SYNC_t); /* Delete a sync object */
BOOL ff_req_grant(_SYNC_t); int ff_req_grant (_SYNC_t); /* Lock sync object */
void ff_rel_grant(_SYNC_t); void ff_rel_grant (_SYNC_t); /* Unlock sync object */
#endif #endif
/*--------------------------------------------------------------*/ /*--------------------------------------------------------------*/
/* Flags and offset address */ /* Flags and offset address */
@ -484,7 +493,9 @@ void ff_rel_grant(_SYNC_t);
#define FA_READ 0x01 #define FA_READ 0x01
#define FA_OPEN_EXISTING 0x00 #define FA_OPEN_EXISTING 0x00
#if _FS_READONLY == 0 #define FA__ERROR 0x80
#if !_FS_READONLY
#define FA_WRITE 0x02 #define FA_WRITE 0x02
#define FA_CREATE_NEW 0x04 #define FA_CREATE_NEW 0x04
#define FA_CREATE_ALWAYS 0x08 #define FA_CREATE_ALWAYS 0x08
@ -492,7 +503,6 @@ void ff_rel_grant(_SYNC_t);
#define FA__WRITTEN 0x20 #define FA__WRITTEN 0x20
#define FA__DIRTY 0x40 #define FA__DIRTY 0x40
#endif #endif
#define FA__ERROR 0x80
/* FAT sub type (FATFS.fs_type) */ /* FAT sub type (FATFS.fs_type) */
@ -514,8 +524,12 @@ void ff_rel_grant(_SYNC_t);
#define AM_MASK 0x3F /* Mask of defined bits */ #define AM_MASK 0x3F /* Mask of defined bits */
/* FatFs refers the members in the FAT structures with byte offset instead /* Fast seek function */
/ of structure member because there are incompatibility of the packing option #define CREATE_LINKMAP 0xFFFFFFFF
/* FatFs refers the members in the FAT structures with byte offset instead of
/ structure member because there are incompatibility of the packing option
/ between various compilers. */ / between various compilers. */
#define BS_jmpBoot 0 #define BS_jmpBoot 0
@ -592,5 +606,8 @@ void ff_rel_grant(_SYNC_t);
#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *(BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8); *(BYTE*)((ptr)+2)=(BYTE)((DWORD)(val)>>16); *(BYTE*)((ptr)+3)=(BYTE)((DWORD)(val)>>24) #define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *(BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8); *(BYTE*)((ptr)+2)=(BYTE)((DWORD)(val)>>16); *(BYTE*)((ptr)+3)=(BYTE)((DWORD)(val)>>24)
#endif #endif
#ifdef __cplusplus
}
#endif
#endif /* _FATFS */ #endif /* _FATFS */

181
src/ffconf.h Normal file
View File

@ -0,0 +1,181 @@
/*---------------------------------------------------------------------------/
/ FatFs - FAT file system module configuration file R0.08 (C)ChaN, 2010
/----------------------------------------------------------------------------/
/
/ CAUTION! Do not forget to make clean the project after any changes to
/ the configuration options.
/
/----------------------------------------------------------------------------*/
#ifndef _FFCONF
#define _FFCONF 8085 /* Revision ID */
/*---------------------------------------------------------------------------/
/ Function and Buffer Configurations
/----------------------------------------------------------------------------*/
#define _FS_TINY 0 /* 0:Normal or 1:Tiny */
/* 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 _FS_READONLY 0 /* 0:Read/Write or 1:Read only */
/* 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 /* 0, 1, 2 or 3 */
/* 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 _USE_STRFUNC 0 /* 0:Disable or 1/2:Enable */
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
#define _USE_MKFS 0 /* 0:Disable or 1:Enable */
/* To enable f_mkfs function, set _USE_MKFS to 1 and set _FS_READONLY to 0 */
#define _USE_FORWARD 0 /* 0:Disable or 1:Enable */
/* To enable f_forward function, set _USE_FORWARD to 1 and set _FS_TINY to 1. */
#define _USE_FASTSEEK 0 /* 0:Disable or 1:Enable */
/* To enable fast seek feature, set _USE_FASTSEEK to 1. */
/*---------------------------------------------------------------------------/
/ Locale and Namespace Configurations
/----------------------------------------------------------------------------*/
#define _CODE_PAGE 932
/* The _CODE_PAGE specifies the OEM code page to be used on the target system.
/ Incorrect setting of the code page can cause a file open failure.
/
/ 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 only (Valid for non LFN cfg.)
*/
#define _USE_LFN 0 /* 0 to 3 */
#define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */
/* The _USE_LFN option switches the LFN support.
/
/ 0: Disable LFN. _MAX_LFN and _LFN_UNICODE have no effect.
/ 1: Enable LFN with static working buffer on the bss. NOT REENTRANT.
/ 2: Enable LFN with dynamic working buffer on the STACK.
/ 3: Enable LFN with dynamic working buffer on the HEAP.
/
/ The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes. When enable LFN,
/ Unicode handling functions ff_convert() and ff_wtoupper() must be added
/ to the project. When enable to use heap, memory control functions
/ ff_memalloc() and ff_memfree() must be added to the project. */
#define _LFN_UNICODE 0 /* 0:ANSI/OEM or 1:Unicode */
/* To switch the character code set on FatFs API to Unicode,
/ enable LFN feature and set _LFN_UNICODE to 1. */
#define _FS_RPATH 0 /* 0:Disable or 1:Enable */
/* 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. */
/*---------------------------------------------------------------------------/
/ Physical Drive Configurations
/----------------------------------------------------------------------------*/
#define _DRIVES 1
/* Number of volumes (logical drives) to be used. */
#define _MAX_SS 512 /* 512, 1024, 2048 or 4096 */
/* Maximum sector size to be handled.
/ Always set 512 for memory card and hard disk but a larger value may be
/ required for floppy disk (512/1024) and optical disk (512/2048).
/ When _MAX_SS is larger than 512, GET_SECTOR_SIZE command must be implememted
/ to the disk_ioctl function. */
#define _MULTI_PARTITION 0 /* 0:Single parition or 1:Multiple partition */
/* 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[]. */
/*---------------------------------------------------------------------------/
/ System Configurations
/----------------------------------------------------------------------------*/
#define _WORD_ACCESS 0 /* 0 or 1 */
/* Set 0 first and it is always compatible with all platforms. The _WORD_ACCESS
/ option defines which access method is used to the word data on the FAT volume.
/
/ 0: Byte-by-byte access.
/ 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 size. */
#define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */
#define _FS_TIMEOUT 1000 /* Timeout period in unit of time ticks */
#define _SYNC_t HANDLE /* O/S dependent type of sync object. e.g. HANDLE, OS_EVENT*, ID and etc.. */
/* Include a header file here to define O/S system calls */
/* #include <windows.h>, <ucos_ii.h.h>, <semphr.h> or ohters. */
/* The _FS_REENTRANT option switches the reentrancy of the FatFs module.
/
/ 0: Disable reentrancy. _SYNC_t and _FS_TIMEOUT have no effect.
/ 1: Enable reentrancy. Also user provided synchronization handlers,
/ ff_req_grant, ff_rel_grant, ff_del_syncobj and ff_cre_syncobj
/ function must be added to the project. */
#define _FS_SHARE 0 /* 0:Disable or >=1:Enable */
/* To enable file shareing feature, set _FS_SHARE to >= 1 and also user
provided memory handlers, ff_memalloc and ff_memfree function must be
added to the project. The value defines number of files can be opened
per volume. */
#endif /* _FFCONFIG */

View File

@ -3,17 +3,21 @@
/*-------------------------------------------*/ /*-------------------------------------------*/
#ifndef _INTEGER #ifndef _INTEGER
#define _INTEGER
#ifdef _WIN32 /* FatFs development platform */
#if 0
#include <windows.h> #include <windows.h>
#else #include <tchar.h>
#else /* Embedded platform */
/* These types must be 16-bit, 32-bit or larger integer */ /* These types must be 16-bit, 32-bit or larger integer */
typedef int INT; typedef int INT;
typedef unsigned int UINT; typedef unsigned int UINT;
/* These types must be 8-bit integer */ /* These types must be 8-bit integer */
typedef signed char CHAR; typedef char CHAR;
typedef unsigned char UCHAR; typedef unsigned char UCHAR;
typedef unsigned char BYTE; typedef unsigned char BYTE;
@ -28,10 +32,6 @@ typedef long LONG;
typedef unsigned long ULONG; typedef unsigned long ULONG;
typedef unsigned long DWORD; typedef unsigned long DWORD;
/* Boolean type */
typedef enum { FALSE = 0, TRUE } BOOL;
#endif #endif
#define _INTEGER
#endif #endif

View File

@ -9,7 +9,7 @@
#define _TINY_TABLE 0 #define _TINY_TABLE 0
#if !_USE_LFN || _CODE_PAGE != 932 #if !_USE_LFN || _CODE_PAGE != 932
#error This file is not needed in current configuration. #error This file is not needed in current configuration. Remove from the project.
#endif #endif
@ -111,7 +111,7 @@ const WCHAR uni2sjis[] = {
0x3088, 0x82E6, 0x3089, 0x82E7, 0x308A, 0x82E8, 0x308B, 0x82E9, 0x3088, 0x82E6, 0x3089, 0x82E7, 0x308A, 0x82E8, 0x308B, 0x82E9,
0x308C, 0x82EA, 0x308D, 0x82EB, 0x308E, 0x82EC, 0x308F, 0x82ED, 0x308C, 0x82EA, 0x308D, 0x82EB, 0x308E, 0x82EC, 0x308F, 0x82ED,
0x3090, 0x82EE, 0x3091, 0x82EF, 0x3092, 0x82F0, 0x3093, 0x82F1, 0x3090, 0x82EE, 0x3091, 0x82EF, 0x3092, 0x82F0, 0x3093, 0x82F1,
0x3094, 0x8394, 0x309B, 0x814A, 0x309C, 0x814B, 0x309D, 0x8154, 0x309B, 0x814A, 0x309C, 0x814B, 0x309D, 0x8154,
0x309E, 0x8155, 0x30A1, 0x8340, 0x30A2, 0x8341, 0x30A3, 0x8342, 0x309E, 0x8155, 0x30A1, 0x8340, 0x30A2, 0x8341, 0x30A3, 0x8342,
0x30A4, 0x8343, 0x30A5, 0x8344, 0x30A6, 0x8345, 0x30A7, 0x8346, 0x30A4, 0x8343, 0x30A5, 0x8344, 0x30A6, 0x8345, 0x30A7, 0x8346,
0x30A8, 0x8347, 0x30A9, 0x8348, 0x30AA, 0x8349, 0x30AB, 0x834A, 0x30A8, 0x8347, 0x30A9, 0x8348, 0x30AA, 0x8349, 0x30AB, 0x834A,
@ -1979,7 +1979,7 @@ const WCHAR sjis2uni[] = {
0x8386, 0x30E6, 0x8387, 0x30E7, 0x8388, 0x30E8, 0x8389, 0x30E9, 0x8386, 0x30E6, 0x8387, 0x30E7, 0x8388, 0x30E8, 0x8389, 0x30E9,
0x838A, 0x30EA, 0x838B, 0x30EB, 0x838C, 0x30EC, 0x838D, 0x30ED, 0x838A, 0x30EA, 0x838B, 0x30EB, 0x838C, 0x30EC, 0x838D, 0x30ED,
0x838E, 0x30EE, 0x838F, 0x30EF, 0x8390, 0x30F0, 0x8391, 0x30F1, 0x838E, 0x30EE, 0x838F, 0x30EF, 0x8390, 0x30F0, 0x8391, 0x30F1,
0x8392, 0x30F2, 0x8393, 0x30F3, 0x8394, 0x3094, 0x8394, 0x30F4, 0x8392, 0x30F2, 0x8393, 0x30F3, 0x8394, 0x30F4,
0x8395, 0x30F5, 0x8396, 0x30F6, 0x839F, 0x0391, 0x83A0, 0x0392, 0x8395, 0x30F5, 0x8396, 0x30F6, 0x839F, 0x0391, 0x83A0, 0x0392,
0x83A1, 0x0393, 0x83A2, 0x0394, 0x83A3, 0x0395, 0x83A4, 0x0396, 0x83A1, 0x0393, 0x83A2, 0x0394, 0x83A3, 0x0395, 0x83A4, 0x0396,
0x83A5, 0x0397, 0x83A6, 0x0398, 0x83A7, 0x0399, 0x83A8, 0x039A, 0x83A5, 0x0397, 0x83A6, 0x0398, 0x83A7, 0x0399, 0x83A8, 0x039A,
@ -3760,9 +3760,9 @@ WCHAR ff_convert ( /* Converted code, 0 means conversion error */
do { do {
c = *p; c = *p;
p += 2; p += 2;
} while (c && c != src);
p -= 3; p -= 3;
c = *p; c = *p;
} while (c && c != src);
} else { /* Unicode to OEMCP */ } else { /* Unicode to OEMCP */
li = 0; hi = sizeof(uni2sjis) / 4 - 1; li = 0; hi = sizeof(uni2sjis) / 4 - 1;
for (n = 16; n; n--) { for (n = 16; n; n--) {

View File

@ -8,7 +8,7 @@
#if !_USE_LFN || _CODE_PAGE != 936 #if !_USE_LFN || _CODE_PAGE != 936
#error This file is not needed in current configuration. #error This file is not needed in current configuration. Remove from the project.
#endif #endif
static static

View File

@ -1,14 +1,14 @@
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/* Unicode - OEM code bidirectional converter (C)ChaN, 2009 */ /* Unicode - OEM code bidirectional converter (C)ChaN, 2009 */
/* */ /* */
/* CP949 (Korean) */ /* CP949 (Korean EUC-KR) */
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
#include "../ff.h" #include "../ff.h"
#if !_USE_LFN || _CODE_PAGE != 949 #if !_USE_LFN || _CODE_PAGE != 949
#error This file is not needed in current configuration. #error This file is not needed in current configuration. Remove from the project.
#endif #endif

View File

@ -8,7 +8,7 @@
#if !_USE_LFN || _CODE_PAGE != 950 #if !_USE_LFN || _CODE_PAGE != 950
#error This file is not needed in current configuration. #error This file is not needed in current configuration. Remove from the project.
#endif #endif

View File

@ -351,7 +351,7 @@ const WCHAR Tbl[] = { /* CP1252(0x80-0xFF) to Unicode conversion table */
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
0x00D8, 0x00D9, 0x00DA, 0x00BD, 0x00DC, 0x00DD, 0x00DE, 0x00DF, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
@ -494,7 +494,7 @@ const WCHAR Tbl[] = { /* CP1258(0x80-0xFF) to Unicode conversion table */
#if !_TBLDEF || !_USE_LFN #if !_TBLDEF || !_USE_LFN
#error This file is not needed in current configuration #error This file is not needed in current configuration. Remove from the project.
#endif #endif

View File

@ -1,19 +1,17 @@
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/* Sample code of OS dependent synchronization object controls */ /* Sample code of OS dependent controls for FatFs R0.08 */
/* for FatFs R0.07c (C)ChaN, 2009 */ /* (C)ChaN, 2010 */
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
#include <windows.h> /* Win32 */ #include <stdlib.h> /* ANSI memory controls */
//#include <ucos_ii.h> /* uC/OS-II */ #include <malloc.h> /* ANSI memory controls */
//#include <semphr.h> /* FreeRTOS */
#include "../ff.h" #include "../ff.h"
#if _FS_REENTRANT
#if _FS_REENTRANT
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/* Create a Synchronization Object for a Volume /* Create a Synchronization Object
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/* This function is called in f_mount function to create a new /* This function is called in f_mount function to create a new
/ synchronization object, such as semaphore and mutex. When a FALSE is / synchronization object, such as semaphore and mutex. When a FALSE is
@ -30,7 +28,7 @@ BOOL ff_cre_syncobj ( /* TRUE:Function succeeded, FALSE:Could not create due to
*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 = SyncObjects[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 */
@ -85,14 +83,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, _FS_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, _FS_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 */ // ret = (xSemaphoreTake(sobj, _FS_TIMEOUT) == pdTRUE) ? TRUE : FALSE; /* FreeRTOS */
return ret; return ret;
} }
@ -119,9 +117,35 @@ void ff_rel_grant (
} }
#endif
#else
#error This file is not needed in this configuration.
#if _USE_LFN == 3 /* LFN with a working buffer on the heap */
/*------------------------------------------------------------------------*/
/* Allocate a memory block */
/*------------------------------------------------------------------------*/
/* If a NULL is returned, the file function fails with FR_NOT_ENOUGH_CORE.
*/
void* ff_memalloc ( /* Returns pointer to the allocated memory block */
UINT size /* Number of bytes to allocate */
)
{
return malloc(size);
}
/*------------------------------------------------------------------------*/
/* Free a memory block */
/*------------------------------------------------------------------------*/
void ff_memfree(
void* mblock /* Pointer to the memory block to free */
)
{
free(mblock);
}
#endif #endif