11 Commits

Author SHA1 Message Date
Christopher Williams 73b919bedf FatFs R0.12, released April 12, 2016 2017-05-10 19:03:44 -07:00
Christopher Williams 95374bbf12 FatFs R0.11a, released September 5, 2015 2015-10-19 09:15:49 -07:00
Christopher Williams 095cc0fc01 R0.11 with patch 1
March 9, 2015

At the thread-safe configuration (_FS_REENTRANT == 1), an unexpected
operation to the volume can result a wrong volume lock. For example,
f_open() ==> media change ==> f_close(), in this case the volume gets
left locked and following function calls to the volume will be locked
out until a forced initialization of the volume by f_mount(). To solve
this problem, apply this patch to the ff.c.
2015-03-11 11:05:58 -07:00
Christopher Williams 9acb379950 FatFs R0.11, released Febrary 9, 2015 2015-03-11 11:05:10 -07:00
Christopher Williams 9ca3490602 Merge branch 'R0.10c+patch2' 2015-01-31 09:59:02 -07:00
Christopher Williams 9f9053a1f0 Merge branch 'R0.10c+patch1' 2015-01-31 09:58:59 -07:00
Christopher Williams 40fee11f59 R0.10c with patch 2
November 26, 2014

_FS_NORTC feature does not work properly.
2015-01-31 09:57:42 -07:00
Christopher Williams f253f45166 R0.10c with patch 1
November 13, 2014

f_unlink function does not remove cluster chain of the file. It reads to
a lost cluster of the FAT volume. This is added at a bugfix of R0.10c.
2015-01-31 09:53:27 -07:00
Christopher Williams 0e89a5798f FatFs R0.10c, released November 9, 2014 2015-01-31 09:34:51 -07:00
Christopher Williams 762b341574 FatFS R0.10b, released May 19, 2014 2015-01-31 09:26:48 -07:00
Christopher Williams 935031e4e5 Add some information about FatFs 2014-01-14 21:27:17 -07:00
134 changed files with 10986 additions and 8228 deletions
+21
View File
@@ -0,0 +1,21 @@
FatFs
=====
This is a copy of FatFs, a "generic FAT file system module for small embedded
systems", by ChaN. See http://elm-chan.org/fsw/ff/00index_e.html.
License
=======
FatFs module is a free software that opened under license policy of
following conditions.
Copyright (C) 2015, ChaN, all right reserved.
1. Redistributions of source code must retain the above copyright notice,
this condition and the following disclaimer.
This software is provided by the copyright holder and contributors "AS IS"
and any warranties related to this software are DISCLAIMED.
The copyright owner or contributors be NOT LIABLE for any damages caused
by use of this software.
+91 -63
View File
@@ -1,11 +1,13 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en"> <html lang="en">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <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">
<meta name="description" content="Open source FAT file system module for embedded projects"> <meta http-equiv="cache-control" content="no-cache">
<meta name="description" content="Open source FAT file system for embedded projects">
<link rel="start" title="Site Top" href="../../"> <link rel="start" title="Site Top" href="../../">
<link rel="up" title="Freewares" href="../../fsw_e.html"> <link rel="up" title="Freewares" href="../../fsw_e.html">
<link rel="alternate" hreflang="en" title="Original" href="http://elm-chan.org/fsw/ff/00index_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>FatFs - Generic FAT File System Module</title> <title>FatFs - Generic FAT File System Module</title>
@@ -17,21 +19,22 @@
<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, 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> <p>FatFs is a generic FAT file system module for small embedded systems. The FatFs module is written in compliance with ANSI C (C89) and completely separated from the disk I/O layer. Therefore it is independent of the platform. It can be incorporated into small microcontrollers with limited resource, such as 8051, PIC, AVR, ARM, Z80, 78K and etc. Also Petit FatFs module for tiny microcontrollers is available <a href="http://elm-chan.org/fsw/ff/00index_p.html">here</a>.</p>
<h4>Features</h4> <h4>Features</h4>
<ul> <ul>
<li>Windows compatible FAT file system.</li> <li>Windows compatible FAT/exFAT file system.</li>
<li>Platform independent. Easy to port.</li> <li>Platform independent. Easy to port.</li>
<li>Very small footprint for code and work area.</li> <li>Very small footprint for code and work area.</li>
<li>Various configuration options: <li>Various <a href="en/config.html">configuration options</a> to support for:
<ul> <ul>
<li>Multiple volumes (physical drives and partitions).</li> <li>Multiple volumes (physical drives and partitions).</li>
<li>Multiple ANSI/OEM code pages including DBCS.</li> <li>Multiple ANSI/OEM code pages including DBCS.</li>
<li>Long file name support in ANSI/OEM or Unicode.</li> <li>Long file name in ANSI/OEM or Unicode.</li>
<li>RTOS support.</li> <li>exFAT file system.</li>
<li>Multiple sector size support.</li> <li>RTOS envilonment.</li>
<li>Read-only, minimized API, I/O buffer and etc...</li> <li>Fixed or variable sector size.</li>
<li>Read-only, optional API, I/O buffer and etc...</li>
</ul> </ul>
</li> </li>
</ul> </ul>
@@ -40,56 +43,76 @@
<div class="para"> <div class="para">
<h3>Application Interface</h3> <h3>Application Interface</h3>
<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> <img src="img/layers1.png" class="rset" width="245" height="220" alt="layer">
<ul> <ul>
<li><a href="en/mount.html">f_mount</a> - Register/Unregister a work area</li> <li>File Access
<li><a href="en/open.html">f_open</a> - Open/Create a file</li> <ul>
<li><a href="en/close.html">f_close</a> - Close an open file</li> <li><a href="en/open.html">f_open</a> - Open/Create a file</li>
<li><a href="en/read.html">f_read</a> - Read file</li> <li><a href="en/close.html">f_close</a> - Close an open file</li>
<li><a href="en/write.html">f_write</a> - Write file</li> <li><a href="en/read.html">f_read</a> - Read data</li>
<li><a href="en/lseek.html">f_lseek</a> - Move read/write pointer, Expand file size</li> <li><a href="en/write.html">f_write</a> - Write data</li>
<li><a href="en/truncate.html">f_truncate</a> - Truncate file size</li> <li><a href="en/lseek.html">f_lseek</a> - Move read/write pointer, Expand size</li>
<li><a href="en/sync.html">f_sync</a> - Flush cached data</li> <li><a href="en/truncate.html">f_truncate</a> - Truncate size</li>
<li><a href="en/forward.html">f_forward</a> - Forward file data to the stream</li> <li><a href="en/sync.html">f_sync</a> - Flush cached data</li>
<li><a href="en/stat.html">f_stat</a> - Check existance of a file or sub-directory</li> <li><a href="en/forward.html">f_forward</a> - Forward data to the stream</li>
<li><a href="en/opendir.html">f_opendir</a> - Open a directory</li> <li><a href="en/expand.html">f_expand</a> - Allocate a contiguous block to the file</li>
<li><a href="en/closedir.html">f_closedir</a> - Close an open directory</li> <li><a href="en/gets.html">f_gets</a> - Read a string</li>
<li><a href="en/readdir.html">f_readdir</a> - Read a directory item</li> <li><a href="en/putc.html">f_putc</a> - Write a character</li>
<li><a href="en/mkdir.html">f_mkdir</a> - Create a sub-directory</li> <li><a href="en/puts.html">f_puts</a> - Write a string</li>
<li><a href="en/unlink.html">f_unlink</a> - Remove a file or sub-directory</li> <li><a href="en/printf.html">f_printf</a> - Write a formatted string</li>
<li><a href="en/chmod.html">f_chmod</a> - Change attribute</li> <li><a href="en/tell.html">f_tell</a> - Get current read/write pointer</li>
<li><a href="en/utime.html">f_utime</a> - Change timestamp</li> <li><a href="en/eof.html">f_eof</a> - Test for end-of-file</li>
<li><a href="en/rename.html">f_rename</a> - Rename/Move a file or sub-directory</li> <li><a href="en/size.html">f_size</a> - Get size</li>
<li><a href="en/chdir.html">f_chdir</a> - Change current directory</li> <li><a href="en/error.html">f_error</a> - Test for an error</li>
<li><a href="en/chdrive.html">f_chdrive</a> - Change current drive</li> </ul>
<li><a href="en/getcwd.html">f_getcwd</a> - Retrieve the current directory</li> </li>
<li><a href="en/getfree.html">f_getfree</a> - Get free clusters</li> <li>Directory Access
<li><a href="en/getlabel.html">f_getlabel</a> - Get volume label</li> <ul>
<li><a href="en/setlabel.html">f_setlabel</a> - Set volume label</li> <li><a href="en/opendir.html">f_opendir</a> - Open a directory</li>
<li><a href="en/mkfs.html">f_mkfs</a> - Create a file system on the drive</li> <li><a href="en/closedir.html">f_closedir</a> - Close an open directory</li>
<li><a href="en/fdisk.html">f_fdisk</a> - Divide a physical drive</li> <li><a href="en/readdir.html">f_readdir</a> - Read an directory item</li>
<li><a href="en/gets.html">f_gets</a> - Read a string</li> <li><a href="en/findfirst.html">f_findfirst</a> - Open a directory and read first item matched</li>
<li><a href="en/putc.html">f_putc</a> - Write a character</li> <li><a href="en/findnext.html">f_findnext</a> - Read a next item matched</li>
<li><a href="en/puts.html">f_puts</a> - Write a string</li> </ul>
<li><a href="en/printf.html">f_printf</a> - Write a formatted string</li> </li>
<li><a href="en/tell.html">f_tell</a> - Get current read/write pointer</li> <li>File/Directory Management
<li><a href="en/eof.html">f_eof</a> - Test for end-of-file on a file</li> <ul>
<li><a href="en/size.html">f_size</a> - Get size of a file</li> <li><a href="en/stat.html">f_stat</a> - Check existance of a file or sub-directory</li>
<li><a href="en/error.html">f_error</a> - Test for an error on a file</li> <li><a href="en/unlink.html">f_unlink</a> - Remove a file or sub-directory</li>
<li><a href="en/rename.html">f_rename</a> - Rename or move a file or sub-directory</li>
<li><a href="en/chmod.html">f_chmod</a> - Change attribute of a file or sub-directory</li>
<li><a href="en/utime.html">f_utime</a> - Change timestamp of a file or sub-directory</li>
<li><a href="en/mkdir.html">f_mkdir</a> - Create a sub-directory</li>
<li><a href="en/chdir.html">f_chdir</a> - Change current directory</li>
<li><a href="en/chdrive.html">f_chdrive</a> - Change current drive</li>
<li><a href="en/getcwd.html">f_getcwd</a> - Retrieve the current directory and drive</li>
</ul>
</li>
<li>Volume Management
<ul>
<li><a href="en/mount.html">f_mount</a> - Register/Unregister a work area of a volume</li>
<li><a href="en/mkfs.html">f_mkfs</a> - Create an FAT volume on the logical drive</li>
<li><a href="en/fdisk.html">f_fdisk</a> - Create logical drives on the physical drive</li>
<li><a href="en/getfree.html">f_getfree</a> - Get total size and free size on the volume</li>
<li><a href="en/getlabel.html">f_getlabel</a> - Get volume label</li>
<li><a href="en/setlabel.html">f_setlabel</a> - Set volume label</li>
</ul>
</li>
</ul> </ul>
</div> </div>
<div class="para"> <div class="para">
<h3>Disk I/O Interface</h3> <h3>Device Control Interface</h3>
<p>Since the FatFs module is completely separated from disk I/O layer, it requires following functions 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 implementations are also available in the downloads.</p> <img src="img/layers2.png" class="rset" width="245" height="220" alt="layer">
<p>Since the FatFs module is a file system layer, it is completely separated from the physical devices, such as memory card, harddisk and any type of storage device. FatFs accesses the storage devices via a simple interface shown below. The low level device control module is <em>not a part of FatFs module</em>. It is provided by implementer. Also sample implementations for some platforms are available in the downloads.</p>
<ul> <ul>
<li><a href="en/dinit.html">disk_initialize</a> - Initialize disk drive</li> <li><a href="en/dstat.html">disk_status</a> - Get device status</li>
<li><a href="en/dstat.html">disk_status</a> - Get disk status</li> <li><a href="en/dinit.html">disk_initialize</a> - Initialize device</li>
<li><a href="en/dread.html">disk_read</a> - Read sector(s)</li> <li><a href="en/dread.html">disk_read</a> - Read sector(s)</li>
<li><a href="en/dwrite.html">disk_write</a> - Write sector(s)</li> <li><a href="en/dwrite.html">disk_write</a> - Write sector(s)</li>
<li><a href="en/dioctl.html">disk_ioctl</a> - Control device dependent features</li> <li><a href="en/dioctl.html">disk_ioctl</a> - Control device dependent functions</li>
<li><a href="en/fattime.html">get_fattime</a> - Get current time</li> <li><a href="en/fattime.html">get_fattime</a> - Get current time</li>
</ul> </ul>
</div> </div>
@@ -98,20 +121,25 @@
<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 projects 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>Read first: <a href="en/appnote.html">FatFs module application note</a> <span class="mfd">April 12, 2016</span></li>
<li>Read first: <a href="en/appnote.html">FatFs module application note</a></li> <li>Download: <a href="ff12.zip">FatFs R0.12</a> | <a href="updates.txt">Updates</a> | <a href="patches.html">Patches</a> <span class="mfd">April 12, 2016</span></li>
<li><a href="http://nemuisan.blog.bai.ne.jp/">Nemuisan's Blog</a> (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li> <li>Download: <a href="ffsample.zip">FatFs sample projects for various platforms</a> <span class="mfd">April 12, 2016</span></li>
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a> (Examples for LPC2000, AT91SAM and STM32)</li> <li>Download: <a href="archives.html">Old Releases</a></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>Community: <a href="http://elm-chan.org/fsw/ff/bd/">FatFs User Forum</a></li>
<li><a href="http://elm-chan.org/docs/fat.html">The basics of FAT file system [ja]</a></li> <li><a href="https://msdn.microsoft.com/en-us/windows/hardware/gg463080.aspx">FAT32 Specification by Microsoft</a>↗ (The authorized document on FAT 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/fat.html">The basics of FAT file system [ja]</a></li>
<li><a href="img/rwtest.png">Benchmark 1</a> (ATmega64/9.2MHz with MMC via SPI, HDD/CFC via GPIO)</li> <li><a href="http://elm-chan.org/docs/mmc/mmc_e.html">How to Use MMC/SDC</a></li>
<li><a href="img/rwtest2.png">Benchmark 2</a> (LPC2368/72MHz with MMC via MCI)</li> <li><a href="http://elm-chan.org/junk/fa/faff.html">Playing with FlashAir and FatFs</a></li>
</ul> <li><a href="http://stm32f4-discovery.com/2014/07/library-21-read-sd-card-fatfs-stm32f4xx-devices/">Read SD card with FatFs on STM32F4xx devices by Tilen Majerle</a>↗ (Quick and easy implementation for STM32F4-Discovery)</li>
<li><a href="http://nemuisan.blog.bai.ne.jp/">Nemuisan's Blog</a>↗ (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li>
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a>↗ (Examples for LPC2000, AT91SAM and STM32)</li>
<li><a href="img/rwtest1.png">Benchmark 1</a> (ATmega1284/20MHz with MMC via USART in SPI, CFC via GPIO)</li>
<li><a href="img/rwtest2.png">Benchmark 2</a> (LPC2368/72MHz with MMC via MCI)</li>
<li><a href="rc/fd.mp4">Demo movie of an application</a> (this project is in ffsample.zip/lpc23xx)</li></ul>
</div> </div>
<hr> <hr>
<p class="foot"><a href="http://elm-chan.org/fsw/ff/00index_e.html">Go to FatFs home page</a></p> <p class="foot"><a href="../../fsw_e.html">Return</a></p>
</body> </body>
</html> </html>
+102 -73
View File
@@ -1,36 +1,39 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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">
<meta name="description" content="組み込みシステム向け汎用FATファイル・システム"> <meta http-equiv="cache-control" content="no-cache">
<meta name="description" content="組み込みシステム向け汎用FATファイルシステム">
<link rel="start" title="Site Top" href="../../index_j.html"> <link rel="start" title="Site Top" href="../../index_j.html">
<link rel="up" title="Freewares" href="../../fsw.html"> <link rel="up" title="Freewares" href="../../fsw.html">
<link rel="alternate" hreflang="en" title="英文" href="00index_e.html"> <link rel="alternate" hreflang="ja" title="オリジナル版" href="http://elm-chan.org/fsw/ff/00index_j.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>FatFs 汎用FATファイルシステムモジュール</title> <title>FatFs 汎用FATファイルシステム モジュール</title>
</head> </head>
<body> <body>
<h1>FatFs 汎用FATファイルシステムモジュール</h1> <h1>FatFs 汎用FATファイルシステム モジュール</h1>
<hr> <hr>
<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, 68k, H8, ARMなど安価なマイコンでも使用可能です。FatFsをシュリンクした<a href="http://elm-chan.org/fsw/ff/00index_p.html">ぷちFatFs</a>もあります。</p> <p>FatFsは小規模な組み込みシステム向けの汎用FATファイルシステム モジュールです。ANSI C(C89)準拠でハードウェア アーキテクチャには依存しないので、必要なワーク エリアが確保できれば、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/exFATファイル システム</li>
<li>プラットフォーム非依存</li> <li>プラットフォーム非依存</li>
<li>コンパクトなコードとRAM使用量</li> <li>コンパクトなコードとRAM使用量</li>
<li>多くの構成オプション: <li>多くの<a href="ja/config.html">構成オプション</a>:
<ul> <ul>
<li>複数のボリューム(物理ドライブ・区画)</li> <li>ボリューム構成(物理ドライブ・区画)</li>
<li>DBCSを含む複数のANSI/OEMコードページ</li> <li>DBCSを含む複数のANSI/OEMコード ページの選択</li>
<li>長いファイル名(LFN) (Unicode APIも選択可)</li> <li>長いファイル名(LFN)への対応</li>
<li>マルチタスク関連</li> <li>exFATファイルシステムへの対応</li>
<li>マルチ・セクタ・サイズ</li> <li>RTOS環境への対応</li>
<li>リード・オンリー構成、一部APIの削除、バッファ構成、その他…</li> <li>セクタ サイズ(固定/可変)</li>
<li>リード オンリー構成、一部APIの削除、バッファ構成、その他…</li>
</ul> </ul>
</li> </li>
</ul> </ul>
@@ -38,79 +41,105 @@
<div class="para"> <div class="para">
<h3>上位レイヤインターフェース</h3> <h3>上位レイヤ インターフェース</h3>
<p>FatFsモジュールは、アプリケーション・レイヤに対し、次のファイル操作関数(API)を提供します。つまり、このリストはFatFsにできることをシンプルに示しています。</p> <img src="img/layers1.png" class="rset" width="245" height="220" alt="layer">
<ul> <ul>
<li><a href="ja/mount.html">f_mount</a> - ワークエリアの登録・削除</li> <li>ファイル アクセス
<li><a href="ja/open.html">f_open</a> - ファイルのオープン・作成</li> <ul>
<li><a href="ja/close.html">f_close</a> - ファイルのクローズ</li> <li><a href="ja/open.html">f_open</a> - ファイルのオープン・作成</li>
<li><a href="ja/read.html">f_read</a> - ファイルの読み出し</li> <li><a href="ja/close.html">f_close</a> - ファイルのクローズ</li>
<li><a href="ja/write.html">f_write</a> - ファイルの書き込み</li> <li><a href="ja/read.html">f_read</a> - データの読み出し</li>
<li><a href="ja/lseek.html">f_lseek</a> - リード/ライト・ポインタの移動, ファイルの拡張</li> <li><a href="ja/write.html">f_write</a> - データの書き込み</li>
<li><a href="ja/truncate.html">f_truncate</a> - ファイル・サイズの切り詰め</li> <li><a href="ja/lseek.html">f_lseek</a> - リード/ライト ポインタの移動, サイズの拡張</li>
<li><a href="ja/sync.html">f_sync</a> - キャッシュされたデータのフラッシュ</li> <li><a href="ja/truncate.html">f_truncate</a> - サイズの切り詰め</li>
<li><a href="ja/forward.html">f_forward</a> - ファイル・データをストリーム関数に転送</li> <li><a href="ja/sync.html">f_sync</a> - キャッシュされたデータのフラッシュ</li>
<li><a href="ja/stat.html">f_stat</a> - ファイル/サブ・ディレクトリの存在チェックと情報の取得</li> <li><a href="ja/forward.html">f_forward</a> - データをストリーム関数に転送</li>
<li><a href="ja/opendir.html">f_opendir</a> - ディレクトリのオープン</li> <li><a href="ja/expand.html">f_expand</a> - 連続領域の割り当て</li>
<li><a href="ja/closedir.html">f_closedir</a> - ディレクトリのクローズ</li> <li><a href="ja/gets.html">f_gets</a> - 文字列の読み出し</li>
<li><a href="ja/readdir.html">f_readdir</a> - ディレクトリの読み出し</li> <li><a href="ja/putc.html">f_putc</a> - 文字の書き込み</li>
<li><a href="ja/mkdir.html">f_mkdir</a> - サブ・ディレクトリの作成</li> <li><a href="ja/puts.html">f_puts</a> - 文字列の書き込み</li>
<li><a href="ja/unlink.html">f_unlink</a> - ファイル/サブ・ディレクトリの削除</li> <li><a href="ja/printf.html">f_printf</a> - 書式化文字列の書き込み</li>
<li><a href="ja/chmod.html">f_chmod</a> - ファイル/サブ・ディレクトリの属性の変更</li> <li><a href="ja/tell.html">f_tell</a> - リード/ライト ポインタの取得</li>
<li><a href="ja/utime.html">f_utime</a> - ファイル/サブ・ディレクトリのタイムスタンプの変更</li> <li><a href="ja/eof.html">f_eof</a> - 終端の有無の取得</li>
<li><a href="ja/rename.html">f_rename</a> - ファイル/サブ・ディレクトリの名前変更・移動</li> <li><a href="ja/size.html">f_size</a> - サイズの取得</li>
<li><a href="ja/chdir.html">f_chdir</a> - カレント・ディレクトリの変更</li> <li><a href="ja/error.html">f_error</a> - エラーの有無の取得</li>
<li><a href="ja/chdrive.html">f_chdrive</a> - カレント・ドライブの変更</li> </ul>
<li><a href="ja/getcwd.html">f_getcwd</a> - カレント・ディレクトリの取得</li> </li>
<li><a href="ja/getfree.html">f_getfree</a> - ボリューム空き領域の取得</li> <li>ディレクトリ アクセス
<li><a href="ja/getlabel.html">f_getlabel</a> - ボリューム・ラベルの取得</li> <ul>
<li><a href="ja/setlabel.html">f_setlabel</a> - ボリューム・ラベルの設定</li> <li><a href="ja/opendir.html">f_opendir</a> - ディレクトリのオープン</li>
<li><a href="ja/mkfs.html">f_mkfs</a> - 論理ドライブのフォーマット</li> <li><a href="ja/closedir.html">f_closedir</a> - ディレクトリのクローズ</li>
<li><a href="ja/fdisk.html">f_fdisk</a> - 物理ドライブの分割</li> <li><a href="ja/readdir.html">f_readdir</a> - 項目の読み出し</li>
<li><a href="ja/gets.html">f_gets</a> - 文字列の読み出し</li> <li><a href="ja/findfirst.html">f_findfirst</a> - ディレクトリのオープンと最初の検索項目の読み出し</li>
<li><a href="ja/putc.html">f_putc</a> - 文字の書き込み</li> <li><a href="ja/findnext.html">f_findnext</a> - 次の検索項目の読み出し</li>
<li><a href="ja/puts.html">f_puts</a> - 文字列の書き込み</li> </ul>
<li><a href="ja/printf.html">f_printf</a> - 書式化文字列の書き込み</li> </li>
<li><a href="ja/tell.html">f_tell</a> - 現在のリード/ライト・ポインタの取得</li> <li>ファイル/ディレクトリ管理
<li><a href="ja/eof.html">f_eof</a> - ファイル終端の有無の取得</li> <ul>
<li><a href="ja/size.html">f_size</a> - ファイル・サイズの取得</li> <li><a href="ja/stat.html">f_stat</a> - ファイル/サブ ディレクトリの存在チェックと情報の取得</li>
<li><a href="ja/error.html">f_error</a> - ファイルのエラーの有無の取得</li> <li><a href="ja/unlink.html">f_unlink</a> - ファイル/サブ ディレクトリの削除</li>
<li><a href="ja/rename.html">f_rename</a> - ファイル/サブ ディレクトリの名前の変更・移動</li>
<li><a href="ja/chmod.html">f_chmod</a> - ファイル/サブ ディレクトリの属性の変更</li>
<li><a href="ja/utime.html">f_utime</a> - ファイル/サブ ディレクトリのタイムスタンプの変更</li>
<li><a href="ja/mkdir.html">f_mkdir</a> - サブ ディレクトリの作成</li>
<li><a href="ja/chdir.html">f_chdir</a> - カレント ディレクトリの変更</li>
<li><a href="ja/chdrive.html">f_chdrive</a> - カレント ドライブの変更</li>
<li><a href="ja/getcwd.html">f_getcwd</a> - カレント ディレクトリの取得</li>
</ul>
</li>
<li>ボリューム管理
<ul>
<li><a href="ja/mount.html">f_mount</a> - ボリューム ワーク エリアの登録・抹消</li>
<li><a href="ja/mkfs.html">f_mkfs</a> - 論理ドライブ上にFATボリュームを作成</li>
<li><a href="ja/fdisk.html">f_fdisk</a> - 物理ドライブ上に複数の論理ドライブを作成</li>
<li><a href="ja/getfree.html">f_getfree</a> - ボリュームのサイズと空きサイズの取得</li>
<li><a href="ja/getlabel.html">f_getlabel</a> - ボリューム ラベルの取得</li>
<li><a href="ja/setlabel.html">f_setlabel</a> - ボリューム ラベルの設定</li>
</ul>
</li>
</ul> </ul>
</div> </div>
<div class="para"> <div class="para">
<h3>下位レイヤインターフェース</h3> <h3>下位レイヤ インターフェース</h3>
<p>FatFsモジュールは、単なるファイル・システム・レイヤなので、ストレージ・デバイス制御レイヤは含まれません。使用するストレージに対応した制御関数は、ユーザによって提供される必要があります。FatFsモジュールは、下位レイヤに対し少なくとも次のインターフェースを要求します。OS関連機能を有効にしたときは、これに加えてプロセス/メモリ関連関数も必要になります。サンプル・プロジェクトに下位レイヤの実装例を示します。</p> <img src="img/layers2.png" class="rset" width="245" height="220" alt="layer">
<p>FatFsモジュールは、単なるファイル システム レイヤなので、その下位に当たるストレージ デバイス制御レイヤは含まれません。プラットフォームやストレージ デバイスに対応した制御レイヤは、インプリメンタによって提供される必要があります。FatFsモジュールは、下位レイヤに対し標準的には次のインターフェースを要求します。一部の拡張機能、たとえばOS関連機能を有効にしたときは、加えてプロセス/メモリ操作関数なども必要になります。サンプル プロジェクトに下位レイヤの実装例を示します。</p>
<ul> <ul>
<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> <li><a href="ja/dinit.html">disk_initialize</a> - デバイスの初期化</li>
<li><a href="ja/dread.html">disk_read</a> - データの読み出し</li> <li><a href="ja/dread.html">disk_read</a> - データの読み出し</li>
<li><a href="ja/dwrite.html">disk_write</a> - データの書き込み</li> <li><a href="ja/dwrite.html">disk_write</a> - データの書き込み</li>
<li><a href="ja/dioctl.html">disk_ioctl</a> - その他のドライブ制御</li> <li><a href="ja/dioctl.html">disk_ioctl</a> - その他のデバイス制御</li>
<li><a href="ja/fattime.html">get_fattime</a> - 日付・時刻の取得</li> <li><a href="ja/fattime.html">get_fattime</a> - 日付・時刻の取得</li>
</ul> </ul>
</div> </div>
<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="ja/appnote.html">FatFsモジュール アプリケーション ノート</a> <span class="mfd">2016. 4. 12</span></li>
<li>最初に読め: <a href="ja/appnote.html">FatFsモジュール・アプリケーション・ノート</a></li> <li>ダウンロード: <a href="ff12.zip">FatFs R0.12</a> | <a href="updates.txt">変更点</a> | <a href="patches.html">パッチ</a> <span class="mfd">2016. 4. 12</span></li>
<li><a href="http://nemuisan.blog.bai.ne.jp/">ねむいさんのぶろぐ</a> (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li> <li>ダウンロード: <a href="ffsample.zip">サンプル プロジェクト</a> <span class="mfd">2016. 4. 12</span></li>
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a> (Examples for LPC2000, AT91SAM and STM32)</li> <li>ダウンロード: <a href="archives.html">旧バージョン</a></li>
<li><a href="http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx">FATファイル・システム仕様書 by Microsoft</a> (The reference document on FAT file system)</li> <li>コミュニティ: <a href="http://elm-chan.org/fsw/ff/bd/">FatFsユーザ フォーラム</a></li>
<li><a href="http://elm-chan.org/docs/fat.html">FATファイルシステム概要</a> (↑を読むためのガイド)</li> <li><a href="https://msdn.microsoft.com/en-us/windows/hardware/gg463080.aspx">FATファイルシステム仕様 by Microsoft</a> (The reference document on FAT file system)</li>
<li><a href="http://elm-chan.org/docs/mmc/mmc.html">MMCの使いかた</a></li> <li><a href="http://elm-chan.org/docs/fat.html">FATファイルシステム概要</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="http://elm-chan.org/docs/mmc/mmc.html">MMCの使いかた</a></li>
<li><a href="img/rwtest2.png">パフォーマンス・テスト2</a> (LPC2368/72MHz with MMC via MCI)</li> <li><a href="http://elm-chan.org/junk/fa/faff.html">FlashAirとFatFs [ja]</a></li>
<li><a href="http://stm32f4-discovery.com/2014/07/library-21-read-sd-card-fatfs-stm32f4xx-devices/">Read SD card with FatFs on STM32F4xx devices by Tilen Majerle</a>↗ (Quick and easy implementation for STM32F4-Discovery)</li>
<li><a href="http://nemuisan.blog.bai.ne.jp/">ねむいさんのぶろぐ</a>↗ (Well written implementations for STM32F/SDIO and LPC2300/MCI)</li>
<li><a href="http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/arm_memcards/index.html">ARM-Projects by Martin THOMAS</a>↗ (Examples for LPC2000, AT91SAM and STM32)</li>
<li><a href="img/rwtest1.png">パフォーマンス テスト1</a> (ATmega1284/20MHz with MMC via USART in SPI, CFC via GPIO)</li>
<li><a href="img/rwtest2.png">パフォーマンス テスト2</a> (LPC2368/72MHz with MMC via MCI)</li>
<li><a href="rc/fd.mp4">応用例のデモ動画</a> (This project is in ffsample.zip/lpc23xx)</li></ul>
</ul> </ul>
</div> </div>
<hr> <hr>
<p class="foot"><a href="http://elm-chan.org/fsw/ff/00index_j.html">FatFsホームページへ</a></p> <p class="foot"><a href="../../fsw.html">戻る</a></p>
</body> </body>
</html> </html>
+11 -7
View File
@@ -7,6 +7,8 @@ a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative
abbr {border-width: 1px;} abbr {border-width: 1px;}
p {margin: 0 0 0.3em 1em;} p {margin: 0 0 0.3em 1em;}
i {margin: 0 0.3em 0 0;}
b {margin: 0 0.1em;}
em {font-style: normal; font-weight: bold; margin: 0 0.1em;} em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
strong {} strong {}
pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; font-size: 85%; font-family: "Consolas", "Courier New", monospace; background-color: white;} pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; font-size: 85%; font-family: "Consolas", "Courier New", monospace; background-color: white;}
@@ -17,6 +19,7 @@ tt {margin: 0 0.2em; font-size: 0.85em; font-family: "Consolas", "Courier New",
tt.arg {font-style: italic;} tt.arg {font-style: italic;}
ol {margin: 0.5em 2.5em;} ol {margin: 0.5em 2.5em;}
ul {margin: 0.5em 2em;} ul {margin: 0.5em 2em;}
ul ul {margin: 0 2em 0.5em 1em;}
dl {margin: 0.5em 1em;} dl {margin: 0.5em 1em;}
dd {margin: 0 2em;} dd {margin: 0 2em;}
dt {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;} dt {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;}
@@ -28,8 +31,8 @@ div.para {clear: both; font-family: serif;}
div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; } div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
.equ {text-indent: 0; margin: 1em 2em 1em;} .equ {text-indent: 0; margin: 1em 2em 1em;}
.indent {margin-left: 2em;} .indent {margin-left: 2em;}
.rset {float: right; margin: 0 0 0.5em 0.5em;} .rset {float: right; margin: 0.3em 0 0.5em 0.5em;}
.lset {float: left; margin: 0 0.5em 0.5em 0.5em;} .lset {float: left; margin: 0.3em 0.5em 0.5em 0.5em;}
ul.flat li {list-style-type: none; margin: 0;} ul.flat li {list-style-type: none; margin: 0;}
a.imglnk img {border: 1px solid;} a.imglnk img {border: 1px solid;}
.iequ {white-space: nowrap; font-weight: bold;} .iequ {white-space: nowrap; font-weight: bold;}
@@ -41,13 +44,14 @@ a.imglnk img {border: 1px solid;}
.cal {text-align: center; } .cal {text-align: center; }
h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;} h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;}
p.hdd {float: right; text-align: right; margin-top: 0.5em;}
hr.hds {clear: both; margin-bottom: 1em;}
h2 {font-size: 2em; font-family: sans-serif; background-color: #d8d8FF; padding: 0.5em 0.5em; margin: 0 0 0.5em;} h2 {font-size: 2em; font-family: sans-serif; background-color: #d8d8FF; padding: 0.5em 0.5em; 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;} div.doc h3 {border-color: #b0d8d8; border-style: solid; border-width: 0px 0px 4px 12px; padding: 4px; margin-top: 3em;}
h5 {font-size: 1em; font-family: sans-serif; margin: 0.5em 0 0em;} h4 {font-size: 1.2em; font-family: sans-serif; margin: 2em 0 0.2em;}
h5 {font-size: 1em; font-family: sans-serif; margin: 1em 0 0em;}
p.hdd {float: right; text-align: right; margin-top: 0.5em;}
hr.hds {clear: both; margin-bottom: 1em;}
kbd {letter-spacing: 0;}
small {font-size: 80%;} small {font-size: 80%;}
.indent {margin-left: 2em;} .indent {margin-left: 2em;}
+12 -8
View File
@@ -9,7 +9,9 @@ a:hover {background-color: #a0ffff;}
a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;} a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;}
abbr {border-width: 1px;} abbr {border-width: 1px;}
p {text-indent: 1em; margin: 0 0 0.3em 0.5em;} p {text-indent: 0.8em; margin: 0 0 0.3em 0.5em;}
i {margin: 0 0.3em 0 0;}
b {margin: 0 0.1em;}
em {font-style: normal; font-weight: bold; margin: 0 0.1em;} em {font-style: normal; font-weight: bold; margin: 0 0.1em;}
strong {} strong {}
pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; letter-spacing: 0; font-size: 0.85em; font-family: "Consolas", "Courier New", "MS ゴシック", monospace; background-color: white;} pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; letter-spacing: 0; font-size: 0.85em; font-family: "Consolas", "Courier New", "MS ゴシック", monospace; background-color: white;}
@@ -20,6 +22,7 @@ tt {margin: 0 0.2em; letter-spacing: 0; font-size: 0.85em; font-family: "Consola
tt.arg {font-style: italic;} tt.arg {font-style: italic;}
ol {margin: 0.5em 2.5em;} ol {margin: 0.5em 2.5em;}
ul {margin: 0.5em 2em;} ul {margin: 0.5em 2em;}
ul ul {margin: 0 2em 0.5em 1em;}
dl {margin: 0.5em 1em;} dl {margin: 0.5em 1em;}
dd {margin: 0em 2em;} dd {margin: 0em 2em;}
dt {font-size: 0.85em; font-family: "Consolas", "Courier New", "MS ゴシック", monospace;} dt {font-size: 0.85em; font-family: "Consolas", "Courier New", "MS ゴシック", monospace;}
@@ -31,8 +34,8 @@ div.para {clear: both; font-family: "
div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; } div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; }
.equ {text-indent: 0; margin: 1em 2em 1em;} .equ {text-indent: 0; margin: 1em 2em 1em;}
.indent {margin-left: 2em;} .indent {margin-left: 2em;}
.rset {float: right; margin: 0 0 0.5em 0.5em;} .rset {float: right; margin: 0.3em 0 0.5em 0.5em;}
.lset {float: left; margin: 0 0.5em 0.5em 0.5em;} .lset {float: left; margin: 0.3em 0.5em 0.5em 0.5em;}
ul.flat li {list-style-type: none; margin: 0;} ul.flat li {list-style-type: none; margin: 0;}
a.imglnk img {border: 1px solid;} a.imglnk img {border: 1px solid;}
.iequ {white-space: nowrap; font-weight: bold;} .iequ {white-space: nowrap; font-weight: bold;}
@@ -44,13 +47,14 @@ a.imglnk img {border: 1px solid;}
.cal {text-align: center; } .cal {text-align: center; }
h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;} h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;}
p.hdd {float: right; text-align: right; margin-top: 0.5em;}
hr.hds {clear: both; margin-bottom: 1em;}
h2 {font-size: 2em; font-family: "MS Pゴシック",sans-serif; background-color: #d8d8FF; padding: 0.5em 0.5em; margin: 0 0 0.5em;} h2 {font-size: 2em; font-family: "MS Pゴシック",sans-serif; background-color: #d8d8FF; padding: 0.5em 0.5em; margin: 0 0 0.5em;}
h3 {font-size: 1.5em; font-family: "MS Pゴシック",sans-serif; margin: 1.5em 0 0.5em;} h3 {font-size: 1.5em; font-family: "MS Pゴシック",sans-serif; margin: 1.5em 0 0.5em;}
h4 {font-size: 1.2em; font-family: "MS Pゴシック",sans-serif; margin: 1em 0 0.2em;} div.doc h3 {border-color: #b0d8d8; border-style: solid; border-width: 0px 0px 4px 12px; padding: 4px; margin-top: 3em;}
h5 {font-size: 1em; font-family: "MS Pゴシック",sans-serif; margin: 0.5em 0 0em;} h4 {font-size: 1.2em; font-family: "MS Pゴシック",sans-serif; margin: 2em 0 0.2em;}
h5 {font-size: 1em; font-family: "MS Pゴシック",sans-serif; margin: 1em 0 0em;}
p.hdd {float: right; text-align: right; margin-top: 0.5em;}
hr.hds {clear: both; margin-bottom: 1em;}
kbd {letter-spacing: 0;}
small {font-size: 80%;} small {font-size: 80%;}
.indent {margin-left: 2em;} .indent {margin-left: 2em;}
+142 -134
View File
@@ -15,20 +15,20 @@
<li><a href="#port">How to Port</a></li> <li><a href="#port">How to Port</a></li>
<li><a href="#limits">Limits</a></li> <li><a href="#limits">Limits</a></li>
<li><a href="#memory">Memory Usage</a></li> <li><a href="#memory">Memory Usage</a></li>
<li><a href="#reduce">Module Size Reduction</a></li> <li><a href="#reduce">Reducing Module Size</a></li>
<li><a href="#lfn">Long File Name</a></li> <li><a href="#lfn">Long File Name</a></li>
<li><a href="#unicode">Unicode API</a></li> <li><a href="#unicode">Unicode API</a></li>
<li><a href="#exfat">exFAT File System</a></li>
<li><a href="#reentrant">Re-entrancy</a></li> <li><a href="#reentrant">Re-entrancy</a></li>
<li><a href="#dup">Duplicated File Access</a></li> <li><a href="#dup">Duplicated File Access</a></li>
<li><a href="#fs1">Performance Effective File Access</a></li> <li><a href="#fs1">Performance Effective File Access</a></li>
<li><a href="#fs2">Considerations on Flash Memory Media</a></li> <li><a href="#fs2">Considerations on Flash Memory Media</a></li>
<li><a href="#critical">Critical Section</a></li> <li><a href="#critical">Critical Section</a></li>
<li><a href="#fs3">Extended Use of APIs</a></li> <li><a href="#fs3">Extended Use of FatFs API</a></li>
<li><a href="#license">About FatFs License</a></li> <li><a href="#license">About FatFs License</a></li>
</ol> </ol>
<hr>
<div class="para" id="port"> <div class="para doc" id="port">
<h3>How to Port</h3> <h3>How to Port</h3>
<h4>Basic considerations</h4> <h4>Basic considerations</h4>
@@ -37,184 +37,188 @@
<li>ANSI C<br> <li>ANSI C<br>
The FatFs module is a middleware written in ANSI C (C89). There is no platform dependence, so long as the compiler is in compliance with ANSI C.</li> The FatFs module is a middleware written in ANSI C (C89). 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 <tt>integer.h</tt>. 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 <tt>char</tt>/<tt>short</tt>/<tt>long</tt> are 8/16/32 bit and <tt>int</tt> is 16 or 32 bit. These correspondence are defined in <tt>integer.h</tt>. 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>
<h4>System organizations</h4> <h4>System organizations</h4>
<p>The dependency diagram shown below is a typical configuration of the embedded system with FatFs module.</p> <p>The dependency diagram shown below is a typical but not specific configuration of the embedded system with FatFs module.</p>
<p><img src="../img/modules.png" width="580" height="280" alt="dependency diagram"></p> <p><img src="../img/modules.png" width="580" height="280" alt="dependency diagram"></p>
<p>(a) If a working disk module with FatFs API is provided, no additional function is needed. (b) To attach existing disk drivers with different API, glue functions are needed to translate the APIs between FatFs and the drivers.</p>
<p><img src="../img/funcs.png" width="750" height="420" alt="functional diagram"></p>
<h4>Which function is required?</h4> <h4>Which function is required?</h4>
<p>You need to provide only low level disk I/O functions that required by FatFs module and nothing else. If a working disk module for the target is already existing, you need to write only glue functions to attach it to the FatFs module. If not, you need to port any other disk module or write it from scratch. Most of defined functions are not that always required. For example, disk write function is not required in read-only configuration. Following table shows which function is required depends on configuration options.</p> <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 system is already existing, you need to write only glue functions to attach it to the FatFs module. If not, you need to port any other disk module or write it from scratch. Most of defined functions are not that always required. For example, disk write function is not required at read-only configuration. Following table shows which function is required depends on the configuration options.</p>
<table class="lst2"> <table class="lst2">
<tr><th>Function</th><th>Required when:</th><th>Note</th></tr> <tr><th>Function</th><th>Required when</th><th>Note</th></tr>
<tr><td>disk_initialize<br>disk_status<br>disk_read</td><td>Always</td><td rowspan="5">Disk I/O functions.<br>Samples available in ffsample.zip.<br>There are many implementations on the web.</td></tr> <tr><td>disk_status<br>disk_initialize<br>disk_read</td><td>Always</td><td rowspan="5">Disk I/O functions.<br>Samples available in ffsample.zip.<br>There are many implementations on the web.</td></tr>
<tr><td>disk_write<br>get_fattime<br>disk_ioctl (CTRL_SYNC)</td><td>_FS_READONLY == 0</td></tr> <tr><td>disk_write<br>get_fattime<br>disk_ioctl (CTRL_SYNC)</td><td>_FS_READONLY == 0</td></tr>
<tr><td>disk_ioctl (GET_SECTOR_COUNT)<br>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr> <tr><td>disk_ioctl (GET_SECTOR_COUNT)<br>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr>
<tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS != _MIN_SS</td></tr> <tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS != _MIN_SS</td></tr>
<tr><td>disk_ioctl (CTRL_ERASE_SECTOR)</td><td>_USE_ERASE == 1</td></tr> <tr><td>disk_ioctl (CTRL_TRIM)</td><td>_USE_TRIM == 1</td></tr>
<tr><td>ff_convert<br>ff_wtoupper</td><td>_USE_LFN &gt;= 1</td><td>Unicode support functions.<br>Available in option/cc*.c.</td></tr> <tr><td>ff_convert<br>ff_wtoupper</td><td>_USE_LFN != 0</td><td>Unicode support functions.<br>Just add option/unicode.c to the project.</td></tr>
<tr><td>ff_cre_syncobj<br>ff_del_syncobj<br>ff_req_grant<br>ff_rel_grant</td><td>_FS_REENTRANT == 1</td><td rowspan="2">O/S dependent functions.<br>Samples available in option/syscall.c.</td></tr> <tr><td>ff_cre_syncobj<br>ff_del_syncobj<br>ff_req_grant<br>ff_rel_grant</td><td>_FS_REENTRANT == 1</td><td rowspan="2">O/S dependent functions.<br>Samples available in option/syscall.c.</td></tr>
<tr><td>ff_mem_alloc<br>ff_mem_free</td><td>_USE_LFN == 3</td></tr> <tr><td>ff_mem_alloc<br>ff_mem_free</td><td>_USE_LFN == 3</td></tr>
</table> </table>
</div> </div>
<div class="para" id="limits"> <div class="para doc" id="limits">
<h3>Limits</h3> <h3>Limits</h3>
<ul> <ul>
<li>FAT sub-types: FAT12, FAT16 and FAT32.</li> <li>File system type: FAT12, FAT16, FAT32(r0.0) and exFAT(r1.0).</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. (upto 4G-1 bytes)</li> <li>Volume size: Upto 2 TiB at 512 bytes/sector.</li>
<li>Volume size: Depends on FAT specs. (upto 2T bytes at 512 bytes/sector)</li> <li>File size: Upto 4 GiB - 1 on FAT volume and virtually unlimited on exFAT volume.</li>
<li>Cluster size: Depends on FAT specs. (upto 64K bytes at 512 bytes/sector)</li> <li>Cluster size: Upto 128 sector on FAT volume, upto 32768 sectors on exFAT volume.</li>
<li>Sector size: Depends on FAT specs. (512..4096 bytes)</li> <li>Sector size: 512, 1024, 2048 and 4096 bytes.</li>
</ul> </ul>
</div> </div>
<div class="para" id="memory"> <div class="para doc" id="memory">
<h3>Memory Usage</h3> <h3>Memory Usage</h3>
<p>The memory usage varies depends on the <a href="config.html">configuration options</a>.</p>
<table class="lst2"> <table class="lst2">
<tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>CM3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX600</th><th>IA-32</th></tr> <tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>CM3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX600</th><th>IA-32</th></tr>
<tr class="cal"> <td>Compiler</td><td>GCC</td><td>GCC</td><td>GCC</td><td>GCC</td><td>CH38</td><td>C30</td><td>CC78K0R</td><td>CA850</td><td>SHC</td><td>RXC</td><td>VC6</td></tr> <tr class="cal"> <td>Compiler</td><td>GCC</td><td>GCC</td><td>GCC</td><td>GCC</td><td>CH38</td><td>C30</td><td>CC78K0R</td><td>CA850</td><td>SHC</td><td>RXC</td><td>MSC</td></tr>
<tr class="cal"> <td>_WORD_ACCESS</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td><td>1</td></tr>
<!-- ARM Thumb CM3 AVR H8 PIC24 RL78 V850ES SH-2A RX600 IA-32 --> <!-- ARM Thumb CM3 AVR H8 PIC24 RL78 V850ES SH-2A RX600 IA-32 -->
<tr class="lst3 ral"><td class="cal">text (Full, R/W)</td><td>10675</td><td>7171</td><td>6617</td><td>13355</td><td>10940</td><td>11722</td><td>13262</td><td>8113</td><td>9048</td><td>6032</td><td>7952</td></tr> <tr class="ral"><td class="cal">text (Full, R/W)</td><td>10.1k</td><td>6.6k</td><td>6.2k</td><td>12.1k</td><td>10.5k</td><td>11.2k</td><td>12.6k</td><td>8.5k</td><td>8.7k</td><td>6.3k</td><td>8.4k</td></tr>
<tr class="ral"> <td class="cal">text (Min, R/W)</td> <td>6727</td><td>4631</td><td>4331</td> <td>8569</td> <td>7262</td> <td>7720</td> <td>9088</td><td>5287</td><td>5800</td><td>3948</td><td>5183</td></tr> <tr class="ral"><td class="cal">text (Min, R/W)</td> <td>6.6k</td><td>4.5k</td><td>4.2k</td> <td>7.9k</td> <td>7.0k</td> <td>7.6k</td> <td>8.8k</td><td>5.9k</td><td>5.8k</td><td>4.3k</td><td>5.8k</td></tr>
<tr class="ral"> <td class="cal">text (Full, R/O)</td> <td>4731</td><td>3147</td><td>2889</td> <td>6235</td> <td>5170</td> <td>5497</td> <td>6482</td><td>3833</td><td>3972</td><td>2862</td><td>3719</td></tr> <tr class="ral"><td class="cal">text (Full, R/O)</td> <td>4.8k</td><td>3.1k</td><td>2.9k</td> <td>5.8k</td> <td>5.1k</td> <td>5.5k</td> <td>6.4k</td><td>4.1k</td><td>4.0k</td><td>3.1k</td><td>4.0k</td></tr>
<tr class="ral"> <td class="cal">text (Min, R/O)</td> <td>3559</td><td>2485</td><td>2295</td> <td>4575</td> <td>4064</td> <td>4240</td> <td>5019</td><td>2993</td><td>3104</td><td>2214</td><td>2889</td></tr> <tr class="ral"><td class="cal">text (Min, R/O)</td> <td>3.5k</td><td>2.4k</td><td>2.3k</td> <td>4.4k</td> <td>3.9k</td> <td>4.2k</td> <td>5.0k</td><td>3.3k</td><td>3.1k</td><td>2.4k</td><td>3.1k</td></tr>
<tr class="ral"> <td class="cal">bss</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td></tr> <tr class="ral"><td class="cal">bss</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td></tr>
<tr class="ral"> <td class="cal">Work area<br>(_FS_TINY == 0)</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*544</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*544</td><td>V*560<br>+ F*544</td><td>V*560<br>+ F*544</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*550</td></tr> <tr class="ral"><td class="cal">Work area<br><small>(_FS_TINY == 0)</small></td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td></tr>
<tr class="ral"> <td class="cal">Work area<br>(_FS_TINY == 1)</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*32</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*32</td><td>V*560<br>+ F*32</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td></tr> <tr class="ral"><td class="cal">Work area<br><small>(_FS_TINY == 1)</small></td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</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, <em>V</em> denotes number of volumes and <em>F</em> denotes 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, <em>V</em> denotes option <tt>_VOLUMES</tt> and <em>F</em> denotes number of open files. All samples here are optimezed in code size.</p>
<pre> <pre>
FatFs R0.10a options: FatFs R0.12 options:
_FS_READONLY 0 (R/W) or 1 (R/O) _FS_READONLY 0 (R/W) or 1 (R/O)
_FS_MINIMIZE 0 (Full function) or 3 (Minimized function) _FS_MINIMIZE 0 (Full, with all basic functions) or 3 (Min, with fully minimized)
_USE_STRFUNC 0 (Disable string functions) _FS_TINY 0 (Default) or 1 (Tiny file object)
_USE_MKFS 0 (Disable f_mkfs function) And any other options are left unchanged from original setting.
_USE_FORWARD 0 (Disable f_forward function)
_USE_FASTSEEK 0 (Disable fast seek feature)
_CODE_PAGE 932 (Japanese Shift-JIS)
_USE_LFN 0 (Disable LFN feature)
_MAX_SS 512 (Fixed sector size)
_FS_RPATH 0 (Disable relative path feature)
_FS_LABEL 0 (Disable volume label functions)
_VOLUMES V (Number of logical drives to be used)
_MULTI_PARTITION 0 (Single partition per drive)
_FS_REENTRANT 0 (Disable thread safe)
_FS_LOCK 0 (Disable file lock control)
</pre> </pre>
</div> </div>
<div class="para" id="reduce"> <div class="para doc" id="reduce">
<h3>Module Size Reduction</h3> <h3>Reducing Modle Size</h3>
<p>Follwing table shows which API function is removed by configuration options for the module size reduction.</p> <p>Follwing table shows which API function is removed by configuration options for the module size reduction. To use any API function, the row of the function must be clear.</p>
<table class="lst2"> <table class="lst2">
<tr><td rowspan="2">Function</td><td colspan="4">_FS_MINIMIZE</td><td colspan="2">_FS_READONLY</td><td colspan="2">_USE_STRFUNC</td><td colspan="3">_FS_RPATH</td><td colspan="2">_FS_LABEL</td><td colspan="2">_USE_MKFS</td><td colspan="2">_USE_FORWARD</td><td colspan="2">_MULTI_PARTITION</td></tr> <tr><td rowspan="2">Function</td><td colspan="4">_FS_<br>MINIMIZE</td><td colspan="2">_FS_<br>READONLY</td><td colspan="2">_USE_<br>STRFUNC</td><td colspan="3">_FS_<br>RPATH</td><td colspan="2">_USE_<br>FIND</td><td colspan="2">_USE_<br>CHMOD</td><td colspan="2">_USE_<br>EXPAND</td><td colspan="2">_USE_<br>LABEL</td><td colspan="2">_USE_<br>MKFS</td><td colspan="2">_USE_<br>FORWARD</td><td colspan="2">_MULTI_<br>PARTITION</td></tr>
<tr><td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0&nbsp;&nbsp;</td><td>1/2</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td></tr> <tr> <td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td></tr>
<tr class="lst3"><td>f_mount</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr class="lst3">
<tr><td>f_open</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <td>f_mount</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_close</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_open</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_read</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_close</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_write</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_read</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_sync</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_write</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_lseek</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_sync</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_opendir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_lseek</td> <td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_closedir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_opendir</td> <td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_readdir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_closedir</td> <td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_stat</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_readdir</td> <td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_getfree</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_findfirst</td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_truncate</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_findnext</td> <td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_unlink</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_stat</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_mkdir</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_getfree</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_chmod</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_truncate</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_utime</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_unlink</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_rename</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_mkdir</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_chdir</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_rename</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_chdrive</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_chdir</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_getcwd</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_chdrive</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_getlabel</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_getcwd</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_setlabel</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_chmod</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_forward</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr> <tr><td>f_utime</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_mkfs</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_getlabel</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_fdisk</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td>x</td><td></td></tr> <tr><td>f_setlabel</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_putc</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_expand</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_puts</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_forward</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td></tr>
<tr><td>f_printf</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_mkfs</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_gets</td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_fdisk</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td>x</td><td> </td></tr>
<tr><td>f_putc</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_puts</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_printf</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_gets</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
</table> </table>
</div> </div>
<div class="para" id="lfn"> <div class="para doc" id="lfn">
<h3>Long File Name</h3> <h3>Long File Name</h3>
<p>The FatFs module has started to support long file name (LFN) at revision 0.07. The two different file names, SFN and LFN, of a file is transparent in the file functions except for f_readdir function. To enable LFN feature, set <tt>_USE_LFN</tt> to 1, 2 or 3, and add a Unicode code conversion function <tt>ff_convert()</tt> and <tt>ff_wtoupper()</tt> to the project. The LFN feature requiers a certain working buffer in addition. The buffer size can be configured by <tt>_MAX_LFN</tt> corresponding to the available memory size. The size of long file name will reach up to 255 characters, so that the <tt>_MAX_LFN</tt> should be set to 255 for full featured LFN operation. If the size of working buffer is insufficient for the given file name, the file function fails with <tt>FR_INVALID_NAME</tt>. When enable the LFN feature with re-entrant feature, <tt>_USE_LFN</tt> must be set to 2 or 3. In this case, the file function allocates the working buffer on the stack or heap. The working buffer occupies <tt>(_MAX_LFN + 1) * 2</tt> bytes.</p> <p>FatFs module supports long file name (LFN). The two different file names, short file name (SFN) and LFN, of a file is transparent on the API except for <tt>f_readdir</tt> function. The support for LFN is disabled by default. To enable the LFN, set <tt><a href="config.html#use_lfn">_USE_LFN</a></tt> to 1, 2 or 3, and add <tt>option/unicode.c</tt> to the project. The LFN requiers a certain working buffer in addition. The buffer size can be configured by <tt><a href="config.html#max_lfn">_MAX_LFN</a></tt> according to the available memory. The length of an LFN will be up to 255 characters, so that the <tt>_MAX_LFN</tt> should be set to 255 for all file names. If the size of working buffer is insufficient for the input file name, the file function fails with <tt>FR_INVALID_NAME</tt>. When use any re-entry to the API with LFN is enabled, <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 ARM7TDMI</caption> <caption>With LFN at CM3+gcc</caption>
<tr><th>Code page</th><th>Program size</th></tr> <tr><th><tt>_CODE_PAGE</tt></th><th>Code size</th></tr>
<tr><td>SBCS</td><td>+3.7K</td></tr> <tr><td>SBCS</td><td>+2.8K</td></tr>
<tr><td>932(Shift-JIS)</td><td>+62K</td></tr> <tr><td>932(Japanese)</td><td>+62.6k</td></tr>
<tr><td>936(GBK)</td><td>+177K</td></tr> <tr><td>936(Simplified Chinese)</td><td>+177k</td></tr>
<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(Traditional Chinese)</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. Especially, in the CJK region, tens of thousands of characters are being used. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased that shown in the table. As the result, the FatFs with LFN feature with those code pages will not able to be implemented to most 8-bit microcontrollers.</p> <p>When the LFN is enabled, the module size will be increased depends on the configured code page. Right table shows how much code size increased when LFN is enabled with some code pages. Especially, in the CJK region, tens of thousands of characters are being used. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased as shown in the table. As the result, the FatFs with LFN enebled with those code pages will not able to be ported on the most 8-bit MCU systems.</p>
<p>Note that the LFN feature on the FAT file system is a patent of Microsoft Corporation. This is not the case on FAT32 but most FAT32 drivers come with the LFN feature. FatFs can swich the LFN feature off by configuration option. When enable LFN feature on the commercial products, a license from Microsoft may be required depends on the final destination.</p> <p>Note that the support for LFN on the FAT volume is a patent of Microsoft Corporation. This is not the case on FAT32 but most FAT32 drivers come with the support for LFN. FatFs can switch the LFN on/off by configuration option. When enable LFN on the commercial products, you will need to be licensed by Microsoft depends on the final destination of the products.</p>
</div> </div>
<div class="para" id="unicode"> <div class="para doc" id="unicode">
<h3>Unicode API</h3> <h3>Unicode API</h3>
<p>By default, FatFs uses ANSI/OEM code set on the API under LFN configuration. FatFs can also switch the character encoding to Unicode on the API (<tt>_LFN_UNICODE</tt>). This means the FatFs supports the True-LFN feature. For more information, refer to the description in the <a href="filename.html">file name</a>.</p> <p>By default, FatFs uses ANSI/OEM code set on the API even at LFN configuration. FatFs can also switch the character encoding on the API to Unicode by configuration option <tt><a href="config.html#lfn_unicode">_LFN_UNICODE</a></tt>. This means that FatFs supports the full featured LFN specification. The data type <tt>TCHAR</tt> specifies any string on the API is an alias of <tt>char</tt>(ANSI) or <tt>WCHAR</tt>(UTF-16). For more information, refer to the description in the <a href="filename.html#uni">file name</a>.</p>
</div> </div>
<div class="para" id="reentrant"> <div class="para doc" id="exfat">
<h3>exFAT File System</h3>
<p>The exFAT (Microsoft's Extended File Allocation Table) file system is a replacement of the FAT file system which has been widely used in the embedded systems and consumer devices. It is adopted by SDA (SD Association) as a recommended file system for high capacity SD cards (&gt;32GB) and they are being shipped with this format, so that the exFAT will soon become one of the standard file systems for removable media.</p>
<p>The exFAT file system allows the file size larger than 4 GiB limit what FAT file system allows upto and some file system overhead, especially file allocation delay, are reduced as well. This feature improves the write throughput to the file. However a problem on the current implementation of FatFs is that write throughput on the fragmented file with extension of size gets less than the throughput on the FAT volume. Pre-allocating a contiguous block with <tt>f_expand</tt> function may be a workaround of this problem.</p>
<p>Note that the exFAT is a patent of Microsoft Corporation. The exFAT function of FatFs is an implementation based on US. Pat. App. Pub. No. 2009/0164440 A1. FatFs module can swich the exFAT on or off by configuration option. When enable the exFAT on the commercial products, you will need to be licensed by Microsoft depends on the final destination of the products.</p></div>
<p><em>Remark: Enabling exFAT discards C89 compatibility due to need for 64-bit integer type.</em></p>
<div class="para doc" id="reentrant">
<h3>Re-entrancy</h3> <h3>Re-entrancy</h3>
<p>The file operations to the different volume is always re-entrant and can work simultaneously. The file operations to the same volume is not re-entrant but it can also be configured to thread-safe with <tt>_FS_REENTRANT</tt> option. In this case, also the OS dependent synchronization object control functions, <tt>ff_cre_syncobj(), ff_del_syncobj(), ff_req_grant() and ff_rel_grant()</tt> must be added to the project.</p> <p>The file operations to the different volume is always re-entrant regardless of configurations except when LFN enabled with static working buffer. It can work simultaneously without any mutual exclusion.</p>
<p>When a file function is called while the volume is in use by any other task, the file function is suspended until that task leaves file function. If wait time exceeded a period defined by <tt>_TIMEOUT</tt>, the file function will abort with <tt>FR_TIMEOUT</tt>. The timeout feature might not be supported by some RTOS.</p> <p>The file operations to the same volume is not re-entrant but it can also be configured thread-safe by option <tt><a href="config.html#fs_reentrant">_FS_REENTRANT</a></tt>. It enables to control exclusive use of each file system object. In this case, also the OS dependent synchronization object control functions, <tt>ff_cre_syncobj/ff_del_syncobj/ff_req_grant/ff_rel_grant</tt>, needed to be added to the project. There are some examples in the <tt>option/syscall.c</tt>.</p>
<p>There is an exception for <tt>f_mount(), f_mkfs(), f_fdisk()</tt> function. These functions are not re-entrant to the same volume or corresponding physical drive. When use these functions, all other tasks must unmount the volume and avoid to access the volume.</p> <p>When a file function is called while the volume is being accessed by any other task, the file function to the volume will be suspended until that task leaves the file function. If the wait time exceeded a period defined by <tt>_TIMEOUT</tt>, the file function will abort with <tt>FR_TIMEOUT</tt>. The timeout function might not be supported on the some RTOSs.</p>
<p>Note that this section describes on the re-entrancy of the FatFs module itself but also the low level disk I/O layer will need to be re-entrant.</p> <p>There is an exception on the re-entrancy for <tt>f_mount/f_mkfs/f_fdisk</tt> function. These volume management functions are not re-entrant to the same volume and corresponding physical drive. When use these functions, any other tasks need to avoid to access the volume.</p>
<p>Note that this section describes on the re-entrancy of the FatFs module itself. The <tt>_FS_REENTRANT</tt> controls only exclusive use of each file system object and it does not that prevent to re-enter the low level disk functions. For example, only <tt>disk_status</tt> function can be re-entered at single volume system and any disk function can be re-entered at multiple volume system. Thus the low level disk I/O layer must be always thread-safe when any FatFs API is re-entered by two or more tasks.</p>
</div> </div>
<div class="para" id="dup"> <div class="para doc" id="dup">
<h3>Duplicated File Access</h3> <h3>Duplicated File Access</h3>
<p>FatFs module does not support the read/write collision control of duplicated open to a file. The duplicated open is permitted only when each of open method to a file is read mode. The duplicated open with one or more write mode to a file is always prohibited, and also open file must not be renamed and deleted. A violation of these rules can cause data corruption.</p> <p>FatFs module does not support the read/write collision control of duplicated open to a file. The duplicated open is permitted only when each of open method to a file is read mode. The duplicated open with one or more write mode to a file is always prohibited, and also open file must not be renamed or deleted. A violation of these rules can cause data colluption.</p>
<p>The file lock control can also be available by <tt>_FS_LOCK</tt> option. The value defines the number of open objects to manage simultaneously. In this case, if any open, rename or remove that violating the file shareing rule that described above is attempted, the file function will fail with <tt>FR_LOCKED</tt>. If number of open objects gets larger than <tt>_FS_LOCK</tt>, the open function will fail with <tt>FR_TOO_MANY_OPEN_FILES</tt>.</p> <p>The file lock control can be enabled by <tt><a href="config.html#fs_lock">_FS_LOCK</a></tt> option. The value of option defines the number of open objects to manage simultaneously. In this case, if any open, rename or remove that violating the file shareing rule that described above is attempted, the file function will rejected with <tt>FR_LOCKED</tt>. If number of open objects, files and sub-directories, is equal to <tt>_FS_LOCK</tt>, an extra <tt>f_open/f_opendir</tt> function will fail with <tt>FR_TOO_MANY_OPEN_FILES</tt>.</p>
</div> </div>
<div class="para" id="fs1"> <div class="para doc" id="fs1">
<h3>Performance Effective File Access</h3> <h3>Performance Effective File Access</h3>
<p>For good performance to read/write files on the small embedded system, application programmer should consider what process is done in the FatFs module. The file data on the volume is transferred in following sequence by <tt>f_read()</tt> function.</p> <p>For good read/write throughput on the small embedded systems with limited size of memory, application programmer should consider what process is done in the FatFs module. The file data on the volume is transferred in following sequence by <tt>f_read</tt> function.</p>
<p>Figure 1. Sector miss-aligned read (short)<br> <p>Figure 1. Sector misaligned read (short)<br>
<img src="../img/f1.png" width="490" height="110" alt=""> <img src="../img/f1.png" width="490" height="110" alt="">
</p> </p>
<p>Figure 2. Sector miss-aligned read (long)<br> <p>Figure 2. Sector misaligned read (long)<br>
<img src="../img/f2.png" width="490" height="140" alt=""> <img src="../img/f2.png" width="490" height="140" alt="">
</p> </p>
<p>Figure 3. Sector aligned read<br> <p>Figure 3. Fully sector aligned read<br>
<img src="../img/f3.png" width="490" height="119" alt=""> <img src="../img/f3.png" width="490" height="119" alt="">
</p> </p>
<p>The file I/O buffer is a sector buffer to read/write a partial data on the sector. The sector buffer is either file private sector buffer on each file object or shared sector buffer in the file system object. The buffer configuration option <tt>_FS_TINY</tt> determins which sector buffer is used for the file data transfer. When tiny buffer (1) is selected, data memory consumption is reduced 512 bytes each file object. In this case, FatFs module uses only a sector buffer in the file system object for file data transfer and FAT/directory access. The disadvantage of the tiny buffer configuration is: the FAT data cached in the sector buffer will be lost by file data transfer and it must be reloaded at every cluster boundary. However it will be suitable for most application from view point of the decent performance and low memory comsumption.</p> <p>The file I/O buffer is a sector buffer to read/write a part of data on the sector. The sector buffer is either file private sector buffer on each file object or shared sector buffer in the file system object. The buffer configuration option <tt><a href="config.html#fs_tiny">_FS_TINY</a></tt> determins which sector buffer is used for the file data transfer. When tiny buffer configuration (1) is selected, data memory consumption is reduced <tt>_MAX_SS</tt> bytes each file object. In this case, FatFs module uses only a sector buffer in the file system object for file data transfer and FAT/directory access. The disadvantage of the tiny buffer configuration is: the FAT data cached in the sector buffer will be lost by file data transfer and it must be reloaded at every cluster boundary. However it will be suitable for most application from view point of the decent performance and low memory comsumption.</p>
<p>Figure 1 shows that a partial sector, sector mis-aligned part of the file, is transferred via the file I/O buffer. On long data transfer shown in Figure 2, middle of transfer data that covers one or more sector is transferred to the application buffer directly. Figure 3 shows that the case of entier transfer data is aligned to the sector boundary. In this case, file I/O buffer is not used. On the direct transfer, the maximum extent of sectors are read with <tt>disk_read()</tt> function at a time but the multiple sector transfer never across the cluster boundary even if it is contiguous.</p> <p>Figure 1 shows that a partial sector, sector misaligned part of the file, is transferred via the file I/O buffer. At long data transfer shown in Figure 2, middle of transfer data that covers one or more sector is transferred to the application buffer directly. Figure 3 shows that the case of entier transfer data is aligned to the sector boundary. In this case, file I/O buffer is not used. On the direct transfer, the maximum extent of sectors are read with <tt>disk_read</tt> function at a time but the multiple sector transfer is divided at cluster boundary even if it is contiguous.</p>
<p>Therefore taking effort to sector aligned read/write accesss avoids buffered data transfer and the read/write performance will be improved. Besides the effect, cached FAT data will not be flushed by file data transfer at the tiny configuration, so that it can achieve same performance as non-tiny configuration with small memory footprint.</p> <p>Therefore taking effort to sector aligned read/write accesss eliminates buffered data transfer and the read/write performance will be improved. Besides the effect, cached FAT data will not be flushed by file data transfer at the tiny configuration, so that it can achieve same performance as non-tiny configuration with small memory footprint.</p>
</div> </div>
<div class="para" id="fs2"> <div class="para doc" id="fs2">
<h3>Considerations on Flash Memory Media</h3> <h3>Considerations on Flash Memory Media</h3>
<p>To maximize the write performance of flash memory media, such as SDC and CFC, it must be controlled in consideration of its characteristitcs.</p> <p>To maximize the write performance of flash memory media, such as SDC, CFC and U Disk, it must be controlled in consideration of its characteristitcs.</p>
<h4>Using Mutiple-Sector Write</h4> <h4>Using Mutiple-Sector Write</h4>
<div class="rset"> <div class="rset">
Figure 6. Comparison between Multiple/Single Sector Write<br> Figure 6. Comparison between Multiple/Single Sector Write<br>
<img src="../img/f6.png" width="630" height="148" alt="fig.6"> <img src="../img/f6.png" width="630" height="148" alt="fig.6">
</div> </div>
<p>The write throughput of the flash memory media becomes the worst at single sector write and it increases proportional to the number of sectors per a write transaction. This effect more appers at more fast bus clock and its ratio often becomes grater than ten. The number of write transaction also affects the life time of the media. Therefore the application program should write the data in large block as possible. The ideal block size is cluster size or power of 2 bytes and the byte offset should be aligned to the block. Of course all layers between the application and the media must support multiple sector write feature, however most of open-source disk drivers lack it. Do not split a multiple sector write request into single sector writes or the write throughput gets poor. Note that FatFs module and its sample disk drivers supprt multiple sector read/write feature.</p> <p>The write throughput of the flash memory media becomes the worst at single sector write transaction. The write throughput increases as the number of sectors per a write transaction as shown in Figure 6. This effect more appers at faster interface speed and the performance ratio often becomes grater than ten. <a href="../img/rwtest2.png">This graph</a> is clearly explaining how fast is multiple block write (W:16K, 32 sectors) than single block write (W:100, 1 sector), and also larger card tends to be slow at single block write. Number of write transactions also affects life time of the flash memory media. When compared at same amount of write data, the single sector write in Figure 6 above wears flash memory media 16 times more than multiple sector write in Figure 6 below. Single sector write is pretty pain for the flash memory media.</p>
<p>Therefore the application program should write the data in large block as possible. The ideal write chunk size and alighment is size of sector, and size of cluster is the best. Of course all layers between the application and the storage device must have consideration on multiple sector write, however most of open-source memory card drivers lack it. Do not split a multiple sector write request into single sector write transactions or the write throughput gets poor. Note that FatFs module and its sample disk drivers supprt multiple sector read/write operation. </p>
<h4>Forcing Memory Erase</h4> <h4>Forcing Memory Erase</h4>
<p>When remove a file with <tt>f_remove()</tt> function, the data clusters occupied by the file are marked 'free' on the FAT. But the data sectors containing the file data are not that applied any process, so that the file data left occupies a part of the flash memory array as 'live block'. If the file data is forced erased on removing the file, the number of free blocks on the flash memory will be increased. This may skip internal block erase operation to the data block on next write. As the result the write performance might be improved. To enable this feature, set <tt>_USE_ERASE</tt> to 1. Note that this is a feature with expectation of internal process of the flash memory media. It may not always effective and <tt>f_remove()</tt> function will take a time to remove a large file. Most applications will not need this feature.</p> <p>When remove a file with <tt>f_remove</tt> function, the data clusters occupied by the file are marked 'free' on the FAT. But the data sectors containing the file data are not that applied any process, so that the file data left occupies a part of the flash memory array as 'live block'. If the file data is forced erased on removing the file, those data blocks will be turned in to the free block pool. This may skip internal block erase operation to the data block on next write operation. As the result the write performance might be improved. FatFs can manage this function by setting <tt><a href="config.html#use_trim">_USE_TRIM</a></tt> to 1. Note that this is an expectation of internal process of the flash memory storage and not that always effective. Also <tt>f_remove</tt> function will take a time when remove a large file. Most applications will not need this function.</p>
</div> </div>
<div class="para" id="critical"> <div class="para doc" id="critical">
<h3>Critical Section</h3> <h3>Critical Section</h3>
<p>If a write operation to the FAT volume is interrupted due to any accidental failure, such as sudden blackout, incorrect disk removal and unrecoverable disk error, the FAT structure on the volume can be collapted. Following images shows the critical section of the FatFs module.</p> <p>If a write operation to the FAT volume is interrupted due to any accidental failure, such as sudden blackout, incorrect media removal and unrecoverable disk error, the FAT structure on the volume can be broken. Following images shows the critical section of the FatFs module.</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">
@@ -226,47 +230,51 @@ Figure 5. Minimized critical section<br>
<br class="clr"> <br class="clr">
<p>An interruption in the red section can cause a cross link; as a result, the object being changed can be lost. If an interruption in the yellow section is occured, there is one or more possibility listed below.</p> <p>An interruption in the red section can cause a cross link; as a result, the object being changed can be lost. If an interruption in the yellow section is occured, there is one or more possibility listed below.</p>
<ul> <ul>
<li>The file data being rewrited is collapted.</li> <li>The file data being rewrited is collapsed.</li>
<li>The file being appended returns initial state.</li> <li>The file being appended returns initial state.</li>
<li>The file created as new is gone.</li> <li>The file created as new is gone.</li>
<li>The file created as new or overwritten remains but no content.</li> <li>The file created as new or overwritten remains but no content.</li>
<li>Efficiency of disk use gets worse due to lost clusters.</li> <li>Efficiency of disk use gets worse due to lost clusters.</li>
</ul> </ul>
<p>Each case does not affect the files that not opened in write mode. To minimize risk of data loss, the critical section can be minimized by minimizing the time that file is opened in write mode or using <tt>f_sync()</tt> function as shown in Figure 5.</p> <p>Each case does not affect the files that not opened in write mode. To minimize risk of data loss, the critical section can be minimized by minimizing the time that file is opened in write mode or using <tt>f_sync</tt> function as shown in Figure 5.</p>
</div> </div>
<div class="para" id="fs3"> <div class="para doc" id="fs3">
<h3>Extended Use of APIs</h3> <h3>Extended Use of FatFs API</h3>
<p>These are examples of extended use of FatFs APIs. New item will be added whenever a useful code is found.</p> <p>These are examples of extended use of FatFs APIs. New item will be added whenever a useful code is found.</p>
<ol> <ol>
<li><a href="../img/app1.c">Open or create a file for append</a></li> <li><a href="../img/app1.c">Open or create a file for append</a></li>
<li><a href="../img/app2.c">Empty a directory</a></li> <li><a href="../img/app2.c">Empty a directory</a></li>
<li><a href="../img/app3.c">Allocate contiguous area to the file</a></li> <li><a href="../img/app3.c">Allocate contiguous area to the file</a> (R0.11a and older)</li>
<li><a href="../img/app4.c">Function/Compatible checker for low level disk I/O module</a></li> <li><a href="../img/app4.c">Function/Compatible checker for low level disk I/O module</a></li>
<li><a href="../img/mkfatimg.zip">FAT image creator</a></li>
</ol> </ol>
</div> </div>
<div class="para" id="license"> <div class="para doc" id="license">
<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>FatFs has being developped as a personal project of the author, ChaN. It is free from the code anyone else wrote at current release. Following code block shows a copy of the FatFs license document that included in the source files.</p>
<pre>/*----------------------------------------------------------------------------/ <pre>
/ FatFs - FAT file system module R0.10a (C)ChaN, 2014 /*----------------------------------------------------------------------------/
/ FatFs - FAT file system module R0.12 (C)ChaN, 2016
/-----------------------------------------------------------------------------/ /-----------------------------------------------------------------------------/
/ FatFs module is a generic FAT file system module for small embedded systems. / FatFs module is a free software that opened under license policy of
/ This is a free software that opened for education, research and commercial / following conditions.
/ developments under license policy of following trems.
/ /
/ Copyright (C) 2014, ChaN, all right reserved. / Copyright (C) 2016, ChaN, all right reserved.
/ /
/ * The FatFs module is a free software and there is NO WARRANTY. / 1. Redistributions of source code must retain the above copyright notice,
/ * No restriction on use. You can use, modify and redistribute it for / this condition and the following disclaimer.
/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
/ * Redistributions of source code must retain the above copyright notice.
/ /
/-----------------------------------------------------------------------------/</pre> / This software is provided by the copyright holder and contributors "AS IS"
<p>Therefore FatFs license is one of the BSD-style licenses but there is a significant feature. Because FatFs is for embedded projects, the conditions of redistributions in binary form, such as embedded code, hex file and binary library, are not specified to increase its usability. The documentation of the distributions need not include about FatFs and its license document, and it may also. This is equivalent to the BSD 1-Clause License. Of course FatFs is compatible with the projects under GNU GPL. When redistribute the FatFs with any modification, the license can also be changed to GNU GPL or BSD-style license.</p> / and any warranties related to this software are DISCLAIMED.
/ The copyright owner or contributors be NOT LIABLE for any damages caused
/ by use of this software.
/----------------------------------------------------------------------------*/
</pre>
<p>Therefore FatFs license is one of the BSD-style licenses but there is a significant feature. FatFs is mainly intended for embedded systems. In order to extend the usability for commercial products, the redistributions of FatFs in binary form, such as embedded code or any forms without source code, does not need to explain about use of FatFs in the documentations. This is equivalent to the 1-clause BSD license. Of course FatFs is compatible with the most open source software licenses including GNU GPL. When you redistribute the FatFs source code with any modification or create a fork, the license can also be changed to GNU GPL, BSD-style license or any open source software licenses that not conflict with FatFs license.</p>
</div> </div>
<p class="foot"><a href="../00index_e.html">Return</a></p> <p class="foot"><a href="../00index_e.html">Return Home</a></p>
</body> </body>
</html> </html>
+1 -1
View File
@@ -50,7 +50,7 @@ FRESULT f_chdir (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_chdir()</tt> function changes the current directory of the logical drive. The current directory of a drive is initialized to the root directory when the drive is auto-mounted. Note that the current directory is retained in the each file system object so that it also affects other tasks that using the volume.</p> <p>The <tt>f_chdir</tt> function changes the current directory of the logical drive. The current directory of a drive is initialized to the root directory when the drive is auto-mounted. Note that the current directory is retained in the each file system object so that it also affects other tasks that using the volume.</p>
</div> </div>
+1 -1
View File
@@ -41,7 +41,7 @@ FRESULT f_chdrive (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_chdrive()</tt> function changes the current drive. The initial value of the current drive number is 0. Note that the current drive is retained in a static variable so that it also affects other tasks that using the file functions.</p> <p>The <tt>f_chdrive</tt> function changes the current drive. The initial value of the current drive number is 0. Note that the current drive is retained in a static variable so that it also affects other tasks that using the file functions.</p>
</div> </div>
<div class="para comp"> <div class="para comp">
+3 -3
View File
@@ -66,13 +66,13 @@ FRESULT f_chmod (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_chmod()</tt> function changes the attribute of a file or sub-directory.</p> <p>The <tt>f_chmod</tt> function changes the attribute of a file or sub-directory.</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<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>_USE_CHMOD == 1</tt>.</p>
</div> </div>
@@ -80,7 +80,7 @@ FRESULT f_chmod (
<h4>Example</h4> <h4>Example</h4>
<pre> <pre>
<span class="c">/* Set read-only flag, clear archive flag and others are left unchanged. */</span> <span class="c">/* Set read-only flag, clear archive flag and others are left unchanged. */</span>
f_chmod("file.txt", AR_RDO, AR_RDO | AR_ARC); f_chmod("file.txt", AM_RDO, AM_RDO | AM_ARC);
</pre> </pre>
</div> </div>
+2 -3
View File
@@ -36,7 +36,6 @@ FRESULT f_close (
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>, <a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>, <a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#tm">FR_TIMEOUT</a> <a href="rc.html#tm">FR_TIMEOUT</a>
</p> </p>
@@ -45,8 +44,8 @@ FRESULT f_close (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_close()</tt> function closes an open file object. If any data has been written to the file, the cached information of the file is written back to the volume. After the function succeeded, the file object is no longer valid and it can be discarded.</p> <p>The <tt>f_close</tt> function closes an open file object. If any data has been written to the file, the cached information of the file is written back to the volume. After the function succeeded, the file object is no longer valid and it can be discarded.</p>
<p>Note that if the file object is in read-only mode and <tt>_FS_LOCK</tt> option is not enabled, the file object can also be discarded without this process. However it is not recommended for future compatibility.</p> <p>Note that if the file object is in read-only mode and <tt>_FS_LOCK</tt> option is not enabled, the file object can also be discarded without this process. However this is not recommended for future compatibility.</p>
</div> </div>
+2 -2
View File
@@ -43,8 +43,8 @@ FRESULT f_closedir (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_closedir()</tt> function closes an open directory object. After the function succeeded, the file object is no longer valid and it can be discarded.</p> <p>The <tt>f_closedir</tt> function closes an open directory object. After the function succeeded, the directory object is no longer valid and it can be discarded.</p>
<p>Note that the directory object can also be discarded without this process unless <tt>_FS_LOCK</tt> option is not enabled. However it is not recommended for future compatibility.</p> <p>Note that the directory object can also be discarded without this process when option <tt>_FS_LOCK</tt> is not enabled. However this is not recommended for future compatibility.</p>
</div> </div>
+204
View File
@@ -0,0 +1,204 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/config.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - Configuration Options</title>
</head>
<body>
<h1>Configuration Options</h1>
<p>There are many options to configure the functions of FatFs for each project. The configuration options are defined in the <tt>ffconf.h</tt>.</p>
<div class="para doc" id="func">
<h3>Function Configurations</h3>
<h4 id="fs_readonly">_FS_READONLY</h4>
<p>Read/Write (0) or Read-only (1). Read-only configuration removes writing API functions, <tt>f_write</tt>, <tt>f_sync</tt>, <tt>f_unlink</tt>, <tt>f_mkdir</tt>, <tt>f_chmod</tt>, <tt>f_rename</tt>, <tt>f_truncate</tt>, <tt>f_getfree</tt> and optional writing functions as well.</p>
<h4 id="fs_minimize">_FS_MINIMIZE</h4>
<p>This option defines minimization level to remove some basic API functions as follows:</p>
<table class="lst1">
<tr><th>Value</th><th>Description</th></tr>
<tr><td>0</td><td>All basic API functions are available.</td></tr>
<tr><td>1</td><td><tt>f_stat</tt>, <tt>f_getfree</tt>, <tt>f_unlink</tt>, <tt>f_mkdir</tt>, <tt>f_chmod</tt>, <tt>f_utime</tt>, <tt>f_truncate</tt> and <tt>f_rename</tt> function are removed.</td></tr>
<tr><td>2</td><td><tt>f_opendir</tt>, <tt>f_readdir</tt> and <tt>f_closedir</tt> function are removed in addition to 1.</td></tr>
<tr><td>3</td><td><tt>f_lseek</tt> function is removed in addition to 2.</td></tr>
</table>
<h4 id="use_strfunc">_USE_STRFUNC</h4>
<p>This option switches string functions, <tt>f_gets</tt>, <tt>f_putc</tt>, <tt>f_puts</tt> and <tt>f_printf</tt>.</p>
<table class="lst1">
<tr><th>Value</th><th>Description</th></tr>
<tr><td>0</td><td>Disable string functions.</td></tr>
<tr><td>1</td><td>Enable string functions without LF-CRLF conversion.</td></tr>
<tr><td>2</td><td>Enable string functions with LF-CRLF conversion.</td></tr>
</table>
<h4 id="use_find">_USE_FIND</h4>
<p>Disable (0) or Enable (1) filtered directory read functions, <tt>f_findfirst</tt> and <tt>f_findnext</tt>. Also <tt>_FS_MINIMIZE</tt> needs to be 0 or 1.</p>
<h4 id="use_mkfs">_USE_MKFS</h4>
<p>Disable (0) or Enable (1) <tt>f_mkfs</tt> function.</p>
<h4 id="use_fastseek">_USE_FASTSEEK</h4>
<p>Disable (0) or Enable (1) fast seek function to enable accelerated mode of <tt>f_lseek</tt>, <tt>f_read</tt> and <tt>f_write</tt> function. For more information, read <a href="lseek.html">here</a>.</p>
<h4 id="use_expand">_USE_EXPAND</h4>
<p>Disable (0) or Enable (1) , <tt>f_enpand</tt> function. Also <tt>_FS_READONLY</tt> needs to be 0.</p>
<h4 id="use_chmod">_USE_CHMOD</h4>
<p>Disable (0) or Enable (1) metadata manipulation functions, <tt>f_chmod</tt> and <tt>f_utime</tt>. Also <tt>_FS_READONLY</tt> needs to be 0.</p>
<h4 id="use_label">_USE_LABEL</h4>
<p>Disable (0) or Enable (1) volume label functions, <tt>f_getlabel</tt> and <tt>f_setlabel</tt>.</p>
<h4 id="use_forward">_USE_FORWARD</h4>
<p>Disable (0) or Enable (1) <tt>f_forward</tt> function. Also <tt>_FS_TINY</tt> needs to be 1.</p>
</div>
<div class="para doc" id="name">
<h3>Namespace and Locale Configurations</h3>
<h4 id="code_page">_CODE_PAGE</h4>
<p>This option specifies the OEM code page to be used on the target system. Incorrect setting of the code page can cause a file open failure. If any extended character is not used at all, there is no difference between any code pages.</p>
<table class="lst1">
<tr><th>Value</th><th>Description</th></tr>
<tr><td>1</td><td>ASCII (valid at non-LFN cfg.)</td></tr>
<tr><td>437</td><td>U.S.</td></tr>
<tr><td>720</td><td>Arabic</td></tr>
<tr><td>737</td><td>Greek</td></tr>
<tr><td>771</td><td>KBL</td></tr>
<tr><td>775</td><td>Baltic</td></tr>
<tr><td>850</td><td>Latin 1</td></tr>
<tr><td>852</td><td>Latin 2</td></tr>
<tr><td>855</td><td>Cyrillic</td></tr>
<tr><td>857</td><td>Turkish</td></tr>
<tr><td>860</td><td>Portuguese</td></tr>
<tr><td>861</td><td>Icelandic</td></tr>
<tr><td>862</td><td>Hebrew</td></tr>
<tr><td>863</td><td>Canadian French</td></tr>
<tr><td>864</td><td>Arabic</td></tr>
<tr><td>865</td><td>Nordic</td></tr>
<tr><td>866</td><td>Russian</td></tr>
<tr><td>869</td><td>Greek 2</td></tr>
<tr><td>932</td><td>Japanese (DBCS)</td></tr>
<tr><td>936</td><td>Simplified Chinese (DBCS)</td></tr>
<tr><td>949</td><td>Korean (DBCS)</td></tr>
<tr><td>950</td><td>Traditional Chinese (DBCS)</td></tr>
</table>
<h4 id="use_lfn">_USE_LFN</h4>
<p>This option switches the support for long file name (LFN). When enable the LFN, Unicode support functions <tt>option/unicode.c</tt> need to be added to the project. The working buffer occupies <tt>(_MAX_LFN + 1) * 2</tt> bytes and additional 608 bytes when exFAT enabled. When use stack for the working buffer, take care on stack overflow. When use heap memory for the working buffer, memory management functions, <tt>ff_memalloc</tt> and <tt>ff_memfree</tt>, need to be added to the project.</p>
<table class="lst1">
<tr><th>Value</th><th>Description</th></tr>
<tr><td>0</td><td>Disable LFN. Only 8.3 format can be used.</td></tr>
<tr><td>1</td><td>Enable LFN with static working buffer on the BSS. Always NOT thread-safe.</td></tr>
<tr><td>2</td><td>Enable LFN with dynamic working buffer on the STACK.</td></tr>
<tr><td>3</td><td>Enable LFN with dynamic working buffer on the HEAP.</td></tr>
</table>
<h4 id="max_lfn">_MAX_LFN</h4>
<p>This option defines the size of LFN working buffer from 12 to 255 in unit of character. This option has no effect when LFN is disabled.</p>
<h4 id="lfn_unicode">_LFN_UNICODE</h4>
<p>ANSI/OEM (0) or Unicode (1). This option switches character encoding on the API. To use Unicode (UTF16) string for the path name, enable LFN and set this option to 1. This option also affects behavior of string I/O functions. When LFN is disabled, this option must be 0. For more information, read <a href="filename.html#uni">here</a>.</p>
<h4 id="strf_encode">_STRF_ENCODE</h4>
<p>When Unicode API is selected by setting <tt>_LFN_UNICODE</tt> 1, this option defines the assumption of character encoding on the file to be read/written via string I/O functions, <tt>f_gets</tt>, <tt>f_putc</tt>, <tt>f_puts</tt> and <tt>f_printf</tt>. This option has no effect when <tt>_LFN_UNICODE = 0</tt>.</p>
<table class="lst1">
<tr><th>Value</th><th>Description</th></tr>
<tr><td>0</td><td>ANSI/OEM</td></tr>
<tr><td>1</td><td>UTF-16LE</td></tr>
<tr><td>2</td><td>UTF-16BE</td></tr>
<tr><td>3</td><td>UTF-8</td></tr>
</table>
<h4 id="fs_rpath">_FS_RPATH</h4>
<p>This option configures relative path function. For more information, read <a href="filename.html#nam">here</a>.</p>
<table class="lst1">
<tr><th>Value</th><th>Description</th></tr>
<tr><td>0</td><td>Disable relative path function and remove related functions.</td></tr>
<tr><td>1</td><td>Enable relative path function. <tt>f_chdir</tt> and <tt>f_chdrive</tt> function is available.</td></tr>
<tr><td>2</td><td><tt>f_getcwd</tt> function is available in addition to 1</td></tr>
</table>
</div>
<div class="para doc" id="volume">
<h3>Volume/Drive Configurations</h3>
<h4 id="volumes">_VOLUMES</h4>
<p>This option configures number of volumes (logical drives, from 1 to 10) to be used.</p>
<h4 id="str_volume_id">_STR_VOLUME_ID</h4>
<p>Disable (0) or Enable (1). This option switches the support for string volume ID. When enabled, also pre-defined strings in <tt>_VOLUME_STRS</tt> can be used as drive identifier in the path name.</p>
<h4 id="volume_strs">_VOLUME_STRS</h4>
<p>This option defines the drive ID strings for each logical drives. Number of items must not be less than <tt>_VOLUMES</tt>. Valid characters for the drive ID string are: A-Z and 0-9.</p>
<h4 id="multi_partition">_MULTI_PARTITION</h4>
<p>Disable (0) or Enable (1). This option switches multi-partition function. By default (0), each logical drive number is bound to the same physical drive number and only an FAT volume in the physical drive is mounted. When enabled, each logical drive is bound to the partition on the physical drive listed in the user defined partition resolution table <tt>VolToPart[]</tt>. Also <tt>f_fdisk</tt> funciton will be available. For more information, read <a href="filename.html#vol">here</a>.</p>
<h4 id="max_ss">_MIN_SS, _MAX_SS</h4>
<p>This set of options defines the size of sector on low level disk I/O interface, <tt>disk_read</tt> and <tt>disk_write</tt> function. Valid values are 512, 1024, 2048 and 4096. <tt>_MIN_SS</tt> defines minimum sector size and <tt>_MAX_SS</tt> defines the maximum sector size. Always set both 512 for any type of memory card and harddisk. But a larger value may be required for on-board flash memory and some type of optical media. When <tt>_MAX_SS &gt; _MIN_SS</tt>, FatFs is configured to variable sector size and <tt>GET_SECTOR_SIZE</tt> command must be implemented to the <tt>disk_ioctl</tt> function.</p>
<h4 id="use_trim">_USE_TRIM</h4>
<p>Disable (0) or Enable (1). This option switches ATA-TRIM function. To enable Trim function, also <tt>CTRL_TRIM</tt> command should be implemented to the <tt>disk_ioctl</tt> function.</p>
<h4 id="fs_nofsinfo">_FS_NOFSINFO</h4>
<p>0 to 3. If you need to know correct free space on the FAT32 volume, set bit 0 of this option, and <tt>f_getfree</tt> function at first time after volume mount will force a full FAT scan. Bit 1 controls the use of last allocated cluster number.</p>
<table class="lst1">
<tr><th>Value</th><th>Description</th></tr>
<tr><td>bit0=0</td><td>Use free cluster count in the FSINFO if available.</td></tr>
<tr><td>bit0=1</td><td>Do not trust free cluster count in the FSINFO.</td></tr>
<tr><td>bit1=0</td><td>Use last allocated cluster number in the FSINFO to find a free cluster if available.</td></tr>
<tr><td>bit1=1</td><td>Do not trust last allocated cluster number in the FSINFO.</td></tr>
</table>
</div>
<div class="para doc" id="system">
<h3>System Configurations</h3>
<h4 id="fs_tiny">_FS_TINY</h4>
<p>Normal (0) or Tiny (1). At the tiny configuration, size of the file object <tt>FIL</tt> is reduced <tt>_MAX_SS</tt> bytes. Instead of private data buffer eliminated from the file object, common sector buffer in the file system object <tt>FATFS</tt> is used for the file data transfer.</p>
<h4 id="fs_exfat">_FS_EXFAT</h4>
<p>This option switches support for the exFAT file system in addition to the FAT file system, Enabled(1) or Disabled(1). To enable the exFAT, also LFN must be enabled. When enable exFAT, configureing <tt>_LFN_UNICODE = 1</tt> and <tt>_MAX_LFN = 255</tt> is recommended for full-featured exFAT function. Note that enabling exFAT discards C89 compatibility due to need for 64-bit integer type.</p>
<h4 id="fs_nortc">_FS_NORTC</h4>
<p>Use RTC (0) or Do not use RTC (1). This option controls timestamp function. If the system does not have an RTC function or valid timestamp is not needed, set <tt>_FS_NORTC</tt> to 1 to disable the timestamp function. Any object modified by FatFs will have a fixed timestamp value defined by <tt>_NORTC_MON</tt>, <tt>_NORTC_MDAY</tt> and <tt>_NORTC_YEAR</tt>. To use the timestamp function, set <tt>_FS_NORTC = 0</tt> and add <tt>get_fattime</tt> function to the project to get the current time form real-time clock. This option has no effect at read-only configuration.</p>
<h4 id="nortc_time">_NORTC_MON, _NORTC_MDAY, _NORTC_YEAR</h4>
<p>This set of options defines default timestamp to be used at no RTC systems. This option has no effect at read-only configuration or <tt>_FS_NORTC = 0</tt>.</p>
<h4 id="fs_lock">_FS_LOCK</h4>
<p>This option switches file lock function to control duplicated file open and illegal operations to open objects. Note that the file lock function is independent of re-entrancy. This option must be 0 at read-only configuration.</p>
<table class="lst1">
<tr><th>Value</th><th>Description</th></tr>
<tr><td>0</td><td>Disable file lock function. To avoid volume corruption, application program should avoid illegal open, remove and rename to the open objects.</td></tr>
<tr><td>&gt;0</td><td>Enable file lock function. The value defines how many files/sub-directories can be opened simultaneously under file lock control. Illigal operations to the open object will be rejected with <tt>FR_LOCKED</tt>.</td></tr>
</table>
<h4 id="fs_reentrant">_FS_REENTRANT</h4>
<p>Disable (0) or Enable (1). This option switches the re-entrancy (thread safe) of the FatFs module itself. Note that file/directory access to the different volume is always re-entrant and it can work simultaneously regardless of this option but volume control functions, <tt>f_mount</tt>, <tt>f_mkfs</tt> and <tt>f_fdisk</tt>, are always not re-entrant. Only file/directory access to the same volume, in other words, exclusive use of each file system object, is under control of this function. To enable this function, also user provided synchronization handlers, <tt>ff_req_grant</tt>, <tt>ff_rel_grant</tt>, <tt>ff_del_syncobj</tt> and <tt>ff_cre_syncobj</tt>, need to be added to the project. Sample code is available in <tt>option/syscall.c</tt>.</p>
<h4 id="fs_timeout">_FS_TIMEOUT</h4>
<p>Number of time ticks to abort the file function with <tt>FR_TIMEOUT</tt> when wait time is too long. This option has no effect when <tt>_FS_REENTRANT = 0</tt>.</p>
<h4 id="sync_t">_SYNC_t</h4>
<p>This option defines O/S dependent sync object type. e.g. <tt>HANDLE</tt>, <tt>ID</tt>, <tt>OS_EVENT*</tt>, <tt>SemaphoreHandle_t</tt> and etc. A header file for O/S definitions needs to be included somewhere in the scope of <tt>ff.c</tt>. This option has no effect when <tt>_FS_REENTRANT = 0</tt>.</p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>
+5 -5
View File
@@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>disk_initialize</h2> <h2>disk_initialize</h2>
<p>The disk_initialize function initializes the disk drive.</p> <p>The disk_initialize function initializes the storage device.</p>
<pre> <pre>
DSTATUS disk_initialize ( DSTATUS disk_initialize (
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] Physical drive number */</span> BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] Physical drive number */</span>
@@ -25,20 +25,20 @@ DSTATUS disk_initialize (
<h4>Parameter</h4> <h4>Parameter</h4>
<dl class="par"> <dl class="par">
<dt>pdrv</dt> <dt>pdrv</dt>
<dd>Specifies the physical drive number to initialize.</dd> <dd>Physical drive number to identify the target device. Always zero at single drive system.</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>Return Values</h4> <h4>Return Values</h4>
<p>This function returns a disk status as the result. For details of the disk status, refer to the <a href="dstat.html">disk_status()</a> function.</p> <p>This function returns the current drive status flags as the result. For details of the drive status, refer to the <a href="dstat.html">disk_status</a> function.</p>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>This function initializes a physical drive and put it ready to generic read/write data. When the function succeeded, <tt>STA_NOINIT</tt> flag in the return value is cleared.</p> <p>This function initializes the storage device and put it ready to generic read/write. When the function succeeded, <tt>STA_NOINIT</tt> flag in the return value is cleared.</p>
<p><em>Application program MUST NOT call this function while FatFs is in use, or FAT structure on the volume can be corrapted. To re-initialize the file system, use <tt>f_mount()</tt> function instead.</em> This function is called on volume mount process by FatFs module to manage the media change.</p> <p><em>Remarks: This function needs to be under control of FatFs module. Application program MUST NOT call this function, or FAT structure on the volume can be broken. To re-initialize the file system, use <tt>f_mount</tt> function instead.</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>
+44 -13
View File
@@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>disk_ioctl</h2> <h2>disk_ioctl</h2>
<p>The disk_ioctl function cntrols device specific features and miscellaneous functions other than generic read/write.</p> <p>The disk_ioctl function controls device specific features and miscellaneous functions other than generic read/write.</p>
<pre> <pre>
DRESULT disk_ioctl ( DRESULT disk_ioctl (
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Drive number */</span> BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Drive number */</span>
@@ -27,11 +27,11 @@ DRESULT disk_ioctl (
<h4>Parameters</h4> <h4>Parameters</h4>
<dl class="par"> <dl class="par">
<dt>pdrv</dt> <dt>pdrv</dt>
<dd>Specifies the drive number (0-9).</dd> <dd>Physical drive number to identify the target device.</dd>
<dt>cmd</dt> <dt>cmd</dt>
<dd>Specifies the command code.</dd> <dd>Command code.</dd>
<dt>buff</dt> <dt>buff</dt>
<dd>Pointer to the parameter buffer depends on the command code. Set NULL if not used.</dd> <dd>Pointer to the parameter depends on the command code. Do not care if no parameter to be passed.</dd>
</dl> </dl>
</div> </div>
@@ -42,28 +42,59 @@ DRESULT disk_ioctl (
<dt>RES_OK (0)</dt> <dt>RES_OK (0)</dt>
<dd>The function succeeded.</dd> <dd>The function succeeded.</dd>
<dt>RES_ERROR</dt> <dt>RES_ERROR</dt>
<dd>Any error occured.</dd> <dd>An error occured.</dd>
<dt>RES_PARERR</dt> <dt>RES_PARERR</dt>
<dd>Invalid command code or parameter.</dd> <dd>The command code or parameter is invalid.</dd>
<dt>RES_NOTRDY</dt> <dt>RES_NOTRDY</dt>
<dd>The disk drive has not been initialized.</dd> <dd>The device has not been initialized.</dd>
</dl> </dl>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The FatFs module uses only device independent commands described below. Any device dependent functions and user defined functions are not used.</p> <p>The FatFs module requires only five device independent commands described below.</p>
<table class="lst"> <table class="lst">
<caption>Standard ioctl command used by FatFs</caption>
<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, the dirty sectors must be written back immediately. This command is not used at read-only configuration.</td></tr> <tr><td>CTRL_SYNC</td><td>Make sure that the device has finished pending write process. If the disk I/O module has a write back cache, the dirty buffers must be written back to the media immediately. Nothing to do for this command if each write operation to the media is completed within the <tt>disk_write</tt> function.</td></tr>
<tr><td>GET_SECTOR_COUNT</td><td>Returns number of available sectors on the drive into the <tt>DWORD</tt> variable pointed by <tt class="arg">buff</tt>. This command is used by only <tt>f_mkfs()</tt> and <tt>f_fdisk()</tt> function to determine the volume/partition size to be created.</td></tr> <tr><td>GET_SECTOR_COUNT</td><td>Returns number of available sectors on the drive into the <tt>DWORD</tt> variable pointed by <tt class="arg">buff</tt>. This command is used by only <tt>f_mkfs</tt> and <tt>f_fdisk</tt> function to determine the volume/partition size to be created. Required at <tt>_USE_MKFS == 1</tt> or <tt>_MULTI_PARTITION == 1</tt>.</td></tr>
<tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the media into the <tt>WORD</tt> variable pointed by <tt class="arg">buff</tt>. Valid return values of this command are 512, 1024, 2048 or 4096. This command is never used at fixed sector size configuration, <tt>_MAX_SS == _MIN_SS</tt>, and it must work at that sector size.</td></tr> <tr><td>GET_SECTOR_SIZE</td><td>Returns sector size of the media into the <tt>WORD</tt> variable pointed by <tt class="arg">buff</tt>. Valid return values of this command are 512, 1024, 2048 and 4096. This command is required only at variable sector size configuration, <tt>_MAX_SS &gt; _MIN_SS</tt>. At fixed sector size configuration, <tt>_MAX_SS == _MIN_SS</tt>, this command is not used and the device must work at that sector size.</td></tr>
<tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the flash memory in unit of sector into the <tt>DWORD</tt> variable pointed by <tt class="arg">buff</tt>. The allowable value is from 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or disk devices. This command is used by only <tt>f_mkfs()</tt> function and it attempts to align data area to the erase block boundary.</td></tr> <tr><td>GET_BLOCK_SIZE</td><td>Returns erase block size of the flash memory media in unit of sector into the <tt>DWORD</tt> variable pointed by <tt class="arg">buff</tt>. The allowable value is from 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or non flash memory media. This command is used by only <tt>f_mkfs</tt> function and it attempts to align data area to the erase block boundary. Required at <tt>_USE_MKFS == 1</tt>.</td></tr>
<tr><td>CTRL_ERASE_SECTOR</td><td>Erases a part of the flash memory specified by a <tt>DWORD</tt> array {&lt;start sector&gt;, &lt;end sector&gt;} pointed by <tt class="arg">buff</tt>. This is similar command to Trim command of ATA command set. When this feature is not supported or not a flash memory media, this command has no effect and can be ignored. The FatFs does not check the result code and the file function is not affected even if the sectors ware not erased well. This command is called on removing a cluster chain when <tt>_USE_ERASE</tt> is 1.</td></tr> <tr><td>CTRL_TRIM</td><td>Informs the device the data on the block of sectors that specified by <tt>DWORD</tt> array {&lt;start sector&gt;, &lt;end sector&gt;} pointed by <tt class="arg">buff</tt> is no longer needed and it may be erased. This is an identical command to Trim of ATA device. Nothing to do for this command if this funcion is not supported or not a flash memory device. The FatFs does not check the result code and the file function is not affected even if the sector block was not erased well. This command is called on remove a cluster chain and in the <tt>f_mkfs</tt> function. Required at <tt>_USE_TRIM == 1</tt>.</td></tr>
</table>
<p>FatFs never uses any device dependent command nor user defined command. Following table shows an example of non-standard commands usable for some applications.</p>
<table class="lst">
<caption>Example of optional ioctl command</caption>
<tr><th>Command</th><th>Description</th></tr>
<tr><td>CTRL_FORMAT</td><td>Create a physical format on the media. If <tt class="arg">buff</tt> is not null, it is pointer to the call-back function for progress notification.</td></tr>
<tr><td>CTRL_POWER_IDLE</td><td>Put the device idle state. <tt>STA_NOINIT</tt> in status flag may not be set if the device goes active state by generic read/write function.</td></tr>
<tr><td>CTRL_POWER_OFF</td><td>Put the device off state. Shut-down the power to the device and deinitialize the device interface if needed. <tt>STA_NOINIT</tt> in status flag must be set. The device goes active state by <tt>disk_initialize</tt> function.</td></tr>
<tr><td>CTRL_LOCK</td><td>Lock media eject mechanism.</td></tr>
<tr><td>CTRL_UNLOCK</td><td>Unlock media eject mechanism.</td></tr>
<tr><td>CTRL_EJECT</td><td>Eject media cartridge. <tt>STA_NOINIT</tt> and <tt>STA_NODISK</tt> in status flag are set after the function succeeded.</td></tr>
<tr><td>MMC_GET_TYPE</td><td>Get card type. The type flags, bit0:MMCv3, bit1:SDv1, bit2:SDv2+ and bit3:LBA, is stored to a BYTE variable pointed by <tt class="arg">buff</tt>. (MMC/SDC specific command)</td></tr>
<tr><td>MMC_GET_CSD</td><td>Get CSD register into a 16-byte buffer pointed by <tt class="arg">buff</tt>. (MMC/SDC specific command)</td></tr>
<tr><td>MMC_GET_CID</td><td>Get CID register into a 16-byte buffer pointed by <tt class="arg">buff</tt>. (MMC/SDC specific command)</td></tr>
<tr><td>MMC_GET_OCR</td><td>Get OCR register into a 4-byte buffer pointed by <tt class="arg">buff</tt>. (MMC/SDC specific command)</td></tr>
<tr><td>MMC_GET_SDSTAT</td><td>Get SDSTATUS register into a 64-byte buffer pointed by <tt class="arg">buff</tt>. (SDC specific command)</td></tr>
<tr><td>ATA_GET_REV</td><td>Get the revision string into a 16-byte buffer pointed by <tt class="arg">buff</tt>. (ATA/CFC specific command)</td></tr>
<tr><td>ATA_GET_MODEL</td><td>Get the model string into a 40-byte buffer pointed by <tt class="arg">buff</tt>. (ATA/CFC specific command)</td></tr>
<tr><td>ATA_GET_SN</td><td>Get the serial number string into a 20-byte buffer pointed by <tt class="arg">buff</tt>. (ATA/CFC specific command)</td></tr>
<tr><td>ISDIO_READ</td><td>Read a block of iSDIO registers specified by command structure pointed by <tt class="arg">buff</tt>. (FlashAir specific command)</td></tr>
<tr><td>ISDIO_WRITE</td><td>Write a block of data to iSDIO registers specified by command structure pointed by <tt class="arg">buff</tt>. (FlashAir specific command)</td></tr>
<tr><td>ISDIO_MRITE</td><td>Change bits in an iSDIO register specified by command structure pointed by <tt class="arg">buff</tt>. (FlashAir specific command)</td></tr>
</table> </table>
</div> </div>
<div class="para comp">
<h4>QuickInfo</h4>
<p>The disk_ioctl function is not needed when <tt>_FS_READONLY == 1</tt> and <tt>_MAX_SS == _MIN_SS</tt>.</p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p> <p class="foot"><a href="../00index_e.html">Return</a></p>
</body> </body>
</html> </html>
+12 -10
View File
@@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>disk_read</h2> <h2>disk_read</h2>
<p>The disk_read function reads sector(s) from the disk drive.</p> <p>The disk_read function reads sector(s) from the storage device.</p>
<pre> <pre>
DRESULT disk_read ( DRESULT disk_read (
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Physical drive number */</span> BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] Physical drive number */</span>
@@ -28,13 +28,13 @@ DRESULT disk_read (
<h4>Parameters</h4> <h4>Parameters</h4>
<dl class="par"> <dl class="par">
<dt>pdrv</dt> <dt>pdrv</dt>
<dd>Specifies the physical drive number.</dd> <dd>Physical drive number to identify the target device.</dd>
<dt>buff</dt> <dt>buff</dt>
<dd>Pointer to the <em>byte array</em> to store the read data. The size of buffer must be in sector size * sector count.</dd> <dd>Pointer to the <em>byte array</em> to store the read data.</dd>
<dt>sector</dt> <dt>sector</dt>
<dd>Specifies the start sector number in logical block address (LBA).</dd> <dd>Start sector number in 32-bit LBA.</dd>
<dt>count</dt> <dt>count</dt>
<dd>Specifies number of sectors to read. FatFs specifis with 1 to 128. Generally, a multiple sector transfer request must not be split into single sector transactions to the device, or you may not get good read performance.</dd> <dd>Number of sectors to read.</dd>
</dl> </dl>
</div> </div>
@@ -49,19 +49,21 @@ DRESULT disk_read (
<dt>RES_PARERR</dt> <dt>RES_PARERR</dt>
<dd>Invalid parameter.</dd> <dd>Invalid parameter.</dd>
<dt>RES_NOTRDY</dt> <dt>RES_NOTRDY</dt>
<dd>The disk drive has not been initialized.</dd> <dd>The device has not been initialized.</dd>
</dl> </dl>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The memory address specified by <tt class="arg">buff</tt> is not that always aligned to word boundary because the type of argument is defined as <tt>BYTE*</tt>. The misaligned read/write request can occure at <a href="appnote.html#fs1">direct transfer</a>. If the bus architecture, especially DMA controller, does not allow misaligned memory access, it should be solved in this function. There are some workarounds described below to avoid this issue.</p> <p>The data read/write operation to the storage devices is done in unit of <em>sector</em>. FatFs supports the sector size in range of from 512 to 4096 bytes. When FatFs is configured to fixed sector size (<tt>_MIN_SS == MAX_SS</tt>, this will be the most case), the read/write function must work at that sector size. When FatFs is configured to variable sector size (<tt>_MIN_SS != MAX_SS</tt>), sector size is inquired with <tt>disk_ioctl</tt> function following <tt>disk_initialize</tt> function.</p>
<p>The memory address specified by <tt class="arg">buff</tt> is not that always aligned to word boundary because the argument is defined as <tt>BYTE*</tt>. The unaligned read/write request can occure at <a href="appnote.html#fs1">direct transfer</a>. If the bus architecture, especially DMA controller, does not allow unaligned memory access, it should be solved in this function. There are some workarounds described below to avoid this issue.</p>
<ul> <ul>
<li>Convert word transfer to byte transfer in this function. - Recommended.</li> <li>Convert word transfer to byte transfer in this function if needed. - Recommended.</li>
<li>For <tt>f_read()</tt>, avoid long read request that includes a whole of sector. - Direct transfer will never occure.</li> <li>On the <tt>f_read</tt> calls, avoid long read request that includes a whole of sector. - Any direct transfer never occures.</li>
<li>For <tt>f_read(fp, buff, btr, &amp;br)</tt>, make sure that <tt>(((UINT)buff &amp; 3) == (f_tell(fp) &amp; 3))</tt> is true. - Word aligned direct transfer is guaranteed.</li> <li>On the <tt>f_read</tt> calls, make sure that <tt>(((UINT)data &amp; 3) == (f_tell(fp) &amp; 3))</tt> is true. - Word alignment of <tt>buff</tt> is guaranteed.</li>
</ul> </ul>
<p>Generally, a multiple sector transfer request must not be split into single sector transactions to the storage device, or you will not get good read throughput.</p>
</div> </div>
+7 -7
View File
@@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>disk_status</h2> <h2>disk_status</h2>
<p>The disk_status function returns the current disk status.</p> <p>The disk_status function returns the current drive status.</p>
<pre> <pre>
DSTATUS disk_status ( DSTATUS disk_status (
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] Physical drive number */</span> BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] Physical drive number */</span>
@@ -25,21 +25,21 @@ DSTATUS disk_status (
<h4>Parameter</h4> <h4>Parameter</h4>
<dl class="par"> <dl class="par">
<dt>pdrv</dt> <dt>pdrv</dt>
<dd>Specifies the physical drive number to be confirmed.</dd> <dd>Physical drive number to identify the target device. Always zero at single drive system.</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>Return Values</h4> <h4>Return Values</h4>
<p>The disk status is returned in combination of following flags. FatFs refers only <tt>STA_NOINIT</tt> and <tt>STA_PROTECTED</tt>.</p> <p>The current drive status is returned in combination of status flags described below. FatFs refers only <tt>STA_NOINIT</tt> and <tt>STA_PROTECT</tt>.</p>
<dl class="ret"> <dl class="ret">
<dt>STA_NOINIT</dt> <dt>STA_NOINIT</dt>
<dd>Indicates that the disk drive is not initialized. This flag is set on system reset, media removal or failure of <tt>disk_initialize()</tt> function. It is cleared on <tt>disk_initialize()</tt> function succeeded. Media change that occurs asynchronously must be captured and reflect it to the status flags, or auto-mount feature will not work correctly. When media change detection feature is not supported, application program needs to de-initialize the file system object with <tt>f_mount()</tt> function after the media change.</dd> <dd>Indicates that the device is not initialized and not ready to work. This flag is set on system reset, media removal or failure of <tt>disk_initialize</tt> function. It is cleared on <tt>disk_initialize</tt> function succeeded. Any media change that occurs asynchronously must be captured and reflect it to the status flags, or auto-mount function will not work correctly. If the system does not support media change detection, application program needs to force de-initialize the file system object and re-mount the volume with <tt>f_mount</tt> function after each media change.</dd>
<dt>STA_NODISK</dt> <dt>STA_NODISK</dt>
<dd>Indicates that no medium in the drive. This is always cleared on fixed disk drive. Note that FatFs does not refer this flag.</dd> <dd>Indicates that no medium in the drive. This is always cleared at fixed disk drive. Note that FatFs does not refer this flag.</dd>
<dt>STA_PROTECTED</dt> <dt>STA_PROTECT</dt>
<dd>Indicates that the medium is write protected. This is always cleared on the drive that does not support write protect notch. Not valid while no medium in the drive.</dd> <dd>Indicates that the medium is write protected. This is always cleared at the drives without write protect function. Not valid if no medium in the drive.</dd>
</dl> </dl>
</div> </div>
+18 -10
View File
@@ -13,12 +13,12 @@
<div class="para func"> <div class="para func">
<h2>disk_write</h2> <h2>disk_write</h2>
<p>The disk_write writes sector(s) to the disk.</p> <p>The disk_write writes sector(s) to the storage device.</p>
<pre> <pre>
DRESULT disk_write ( DRESULT disk_write (
BYTE <span class="arg">drv</span>, <span class="c">/* [IN] Physical drive number */</span> BYTE <span class="arg">drv</span>, <span class="c">/* [IN] Physical drive number */</span>
const BYTE* <span class="arg">buff</span>, <span class="c">/* [IN] Write data (may be non aligned) */</span> const BYTE* <span class="arg">buff</span>, <span class="c">/* [IN] Pointer to the data to be written */</span>
DWORD <span class="arg">sector</span>, <span class="c">/* [IN] Sector number to write */</span> DWORD <span class="arg">sector</span>, <span class="c">/* [IN] Sector number to write from */</span>
UINT <span class="arg">count</span> <span class="c">/* [IN] Number of sectors to write */</span> UINT <span class="arg">count</span> <span class="c">/* [IN] Number of sectors to write */</span>
); );
</pre> </pre>
@@ -28,13 +28,13 @@ DRESULT disk_write (
<h4>Parameters</h4> <h4>Parameters</h4>
<dl class="par"> <dl class="par">
<dt>pdrv</dt> <dt>pdrv</dt>
<dd>Specifies the physical drive number.</dd> <dd>Physical drive number to identify the target device.</dd>
<dt>buff</dt> <dt>buff</dt>
<dd>Pointer to the <em>byte array</em> to be written.</dd> <dd>Pointer to the <em>byte array</em> to be written. The size of data to be written is sector size * <tt class="arg">count</tt> bytes.</dd>
<dt>sector</dt> <dt>sector</dt>
<dd>Specifies the start sector number in logical block address (LBA).</dd> <dd>Start sector number in 32-bit LBA.</dd>
<dt>count</dt> <dt>count</dt>
<dd>Specifies the number of sectors to write. FatFs specifis 1 to 128. Generally, a multiple sector transfer request must not be split into single sector transactions to the device, or you will never get good write performance.</dd> <dd>Number of sectors to write.</dd>
</dl> </dl>
</div> </div>
@@ -51,15 +51,23 @@ DRESULT disk_write (
<dt>RES_PARERR</dt> <dt>RES_PARERR</dt>
<dd>Invalid parameter.</dd> <dd>Invalid parameter.</dd>
<dt>RES_NOTRDY</dt> <dt>RES_NOTRDY</dt>
<dd>The disk drive has not been initialized.</dd> <dd>The device has not been initialized.</dd>
</dl> </dl>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>This function is not required in read only configuration. The specified memory address is not that always aligned to word boundary because the type of pointer is defined as <tt>BYTE</tt>. For more information, read <a href="dread.html">description in disk_read function</a>.</p> <p>The specified memory address is not that always aligned to word boundary because the type of pointer is defined as <tt>BYTE*</tt>. For more information, refer to the description of <a href="dread.html"><tt>disk_read</tt></a> function.</p>
<p><em>Application program MUST NOT call this function while FatFs is in use, or FAT structure on the volume can be corrapted.</em></p> <p>Generally, a multiple sector transfer request must not be split into single sector transactions to the storage device, or you will never get good write throughput.</p>
<p>FatFs expects delayed write function of the disk control layer. The write operation to the media does not need to be completed when return from this function by what write operation is in progress or data is only stored into the write-back cache. But write data on the <tt class="arg">buff</tt> is invalid after return from this function. The write completion request is done by <tt>CTRL_SYNC</tt> command of <tt><a href="dioctl.html">disk_ioctl</a></tt> function. Therefore, if a delayed write function is implemented, the write throughput will be improved.</p>
<p><em>Remarks: Application program MUST NOT call this function, or FAT structure on the volume can be collapsed.</em></p>
</div>
<div class="para comp">
<h4>QuickInfo</h4>
<p>This function is not needed when <tt>_FS_READONLY == 1</tt>.</p>
</div> </div>
+3 -3
View File
@@ -33,15 +33,15 @@ int f_eof (
<div class="para ret"> <div class="para ret">
<h4>Return Values</h4> <h4>Return Values</h4>
<p>The <tt>f_eof()</tt> function returns a non-zero value if the read/write pointer has reached end of the file; otherwise it returns a zero.</p> <p>The <tt>f_eof</tt> function returns a non-zero value if the read/write pointer has reached end of the file; otherwise it returns a zero.</p>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>In this revision, this function is implemented as a macro.</p> <p>In this revision, this function is implemented as a macro. It does not have any validation and mutual exclusion.</p>
<pre> <pre>
<span class="k">#define</span> f_eof(fp) (((fp)->fptr) == ((fp)->fsize) ? 1 : 0) <span class="k">#define</span> f_eof(fp) ((int)((fp)->fptr == (fp)->fsize))
</pre> </pre>
</div> </div>
+2 -2
View File
@@ -39,9 +39,9 @@ int f_error (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>In this revision, this function is implemented as a macro.</p> <p>In this revision, this function is implemented as a macro. It does not have any validation and mutual exclusion.</p>
<pre> <pre>
<span class="k">#define</span> f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0) <span class="k">#define</span> f_error(fp) ((fp)->err)
</pre> </pre>
</div> </div>
+115
View File
@@ -0,0 +1,115 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/lseek.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_expand</title>
</head>
<body>
<div class="para func">
<h2>f_expand</h2>
<p>The f_expand function prepare or allocates a contiguous data area to the file.</p>
<pre>
FRESULT f_expand (
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] File object */</span>
FSIZE_t <span class="arg">fsz</span>, <span class="c">/* [IN] File size expanded to */</span>
BYTE <span class="arg">opt</span> <span class="c">/* [IN] Operation mode */</span>
);
</pre>
</div>
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>fp</dt>
<dd>Pointer to the open file object.</dd>
<dt>fsz</dt>
<dd>Number of bytes in size to prepare or be allocated to the file. The data type <tt>FSIZE_t</tt> is an alias of either <tt>DWORD</tt>(32-bit) or <tt>QWORD</tt>(64-bit) depends on the configuration option <tt>_FS_EXFAT</tt>.</dd>
<dt>opt</dt>
<dd>Operation mode. Prepare only (0) or Allocate now (1).</dd>
</dl>
</div>
<div class="para ret">
<h4>Return Values</h4>
<p>
<a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#dn">FR_DENIED</a>,
<a href="rc.html#tm">FR_TIMEOUT</a>
</p>
</div>
<div class="para desc">
<h4>Description</h4>
<p>The <tt>f_expand</tt> function prepare or allocates a contiguous data area to the file. When <tt class="arg">opt</tt> is 1, the function allocates a contiguous data area to the file. Unlike file expansion of file by <tt>f_lseek</tt> function, the file must be truncated prior to use this function and read/write pointer of the file stays at top of the file after the function. The file content allocated with this function is undefined. The function can be failed with <tt>FR_DENIED</tt> due to some reasons below.</p>
<ul>
<li>No free contiguous space for the file was found.</li>
<li>Size of the file was not zero on expand.</li>
<li>The file has been opened in read-only mode.</li>
<li>Not allowable file size. (&gt;= 4GiB on FAT volume)</li>
</ul>
<p>When <tt class="arg">opt</tt> is 0, the function finds a contiguous data area and set it as suggested allocation point instead of allocating it to the file. The next cluster allocation is started at top of the contiguous data area. Thus the write file is guaranteed be contiguous and no allocation delay at least until the size reaches that size unless any other operation to the volume with changes of FAT is performed.</p>
<p>The contiguous file would have an advantage at time-critical read/write operations. It reduces some overheads in the file system and the storage media caused by random access due to fragmented file data. Especially at the exFAT volume, any FAT access for the contiguous file is completely eliminated and storage media will be accessed sequentially.</p>
<p>Also the contiguous file data can be accessed directory via low-level disk functions but it is not recommended in consideration for future compatibility.</p>
</div>
<div class="para comp">
<h4>QuickInfo</h4>
<p>Available when <tt>_USE_EXPAND == 1</tt> and <tt>_FS_READONLY == 0</tt>.</p>
</div>
<div class="para use">
<h4>Example</h4>
<pre>
<span class="c">/* Creating a contiguous file */</span>
<span class="c">/* Create a new file */</span>
res = f_open(fp = malloc(sizeof (FIL)), "file.dat", FA_WRITE|FA_CREATE_ALWAYS);
if (res) { <span class="c">/* Check if the file has been opened */</span>
free(fp);
...
}
<span class="c">/* Alloacte a 100 MiB of contiguous area to the file */</span>
res = f_expand(fp, 104857600, 1);
if (res) { <span class="c">/* Check if the file has been expanded */</span>
free(fp);
...
}
<span class="c">/* Now you have a contiguous file accessible with fp */</span>
</pre>
<pre>
<span class="c">/* Accessing the file data directly via low-level disk functions */</span>
<span class="c">/* Get physical location of the file data */</span>
drv = fp-&gt;obj.fs-&gt;drv;
sect = fp-&gt;obj.fs-&gt;database + fp-&gt;obj.fs-&gt;csize * (fp-&gt;obj.sclust - 2);
<span class="c">/* Write 2048 sectors from top of the file at a time */</span>
res = disk_write(drv, buffer, sect, 2048);
</pre>
</div>
<div class="para ref">
<h4>See Also</h4>
<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>
+10 -4
View File
@@ -22,14 +22,14 @@ DWORD get_fattime (void);
<div class="para ret"> <div class="para ret">
<h4>Return Value</h4> <h4>Return Value</h4>
<p>Currnet time is returned with packed into a <tt>DWORD</tt> value. The bit field is as follows:</p> <p>Currnet local time is returned with packed into a <tt>DWORD</tt> value. The bit field is as follows:</p>
<dl class="ret"> <dl class="ret">
<dt>bit31:25</dt> <dt>bit31:25</dt>
<dd>Year from 1980 (0..127)</dd> <dd>Year origin from the 1980 (0..127)</dd>
<dt>bit24:21</dt> <dt>bit24:21</dt>
<dd>Month (1..12)</dd> <dd>Month (1..12)</dd>
<dt>bit20:16</dt> <dt>bit20:16</dt>
<dd>Day in month(1..31)</dd> <dd>Day of the month(1..31)</dd>
<dt>bit15:11</dt> <dt>bit15:11</dt>
<dd>Hour (0..23)</dd> <dd>Hour (0..23)</dd>
<dt>bit10:5</dt> <dt>bit10:5</dt>
@@ -42,7 +42,13 @@ DWORD get_fattime (void);
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>get_fattime()</tt> function must return any valid time even if the system does not support a real time clock. If a zero is returned, the file will not have a valid time. This fucntion is not required in read only configuration.</p> <p>The <tt>get_fattime</tt> function shall return any valid time even if the system does not support a real time clock. If a zero is returned, the file will not have a valid timestamp.</p>
</div>
<div class="para comp">
<h4>QuickInfo</h4>
<p>This function is not needed when <tt>_FS_READONLY == 1</tt> or <tt>_FS_NORTC == 1</tt>.</p>
</div> </div>
+2 -2
View File
@@ -48,7 +48,7 @@ FRESULT f_fdisk (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_fdisk()</tt> function creates a partition table into the MBR of the physical drive. The partitioning rule is in generic FDISK format, so that it can create upto four primary partitions. Extended partition is not supported. The <tt class="arg">part[]</tt> array with four items specifies how to divide the physical drive. The first item specifies the size of first primary partition and fourth item specifies the fourth primary partition. If the value is less than or equal to 100, it means percentage of the partition in the entire disk space. If it is larger than 100, it means partition size in unit of sector.</p> <p>The <tt>f_fdisk</tt> function creates a partition table into the MBR of the physical drive. The partitioning rule is in generic FDISK format, so that it can create upto four primary partitions. Logical volumes in the extended partition is not supported. The <tt class="arg">part[]</tt> with four items specifies how to divide the physical drive. The first item specifies the size of first primary partition and fourth item specifies the fourth primary partition. If the value is less than or equal to 100, it specifies percentage of the partition in the entire disk space. If it is larger than 100, it specifies the partition size in unit of sector.</p>
</div> </div>
<div class="para comp"> <div class="para comp">
@@ -80,7 +80,7 @@ FRESULT f_fdisk (
f_mkfs("0:", 0, 0); <span class="c">/* Create FAT volume on the logical drive 0. 2nd argument is ignored. */</span> f_mkfs("0:", 0, 0); <span class="c">/* Create FAT volume on the logical drive 0. 2nd argument is ignored. */</span>
f_mount(0, "0:", 0); <span class="c">/* Unregister work area from the logical drive 0 */</span> f_mount(0, "0:", 0); <span class="c">/* Unregister work area from the logical drive 0 */</span>
f_mount(&amp;fs, "1:", 0); <span class="c">/* Give a work area to the logical drive 1 */</span> f_mount(&amp;fs, "1:", 0); <span class="c">/* Register a work area to the logical drive 1 */</span>
f_mkfs("1:", 0, 0); <span class="c">/* Create FAT volume on the logical drive 1. 2nd argument is ignored. */</span> f_mkfs("1:", 0, 0); <span class="c">/* Create FAT volume on the logical drive 1. 2nd argument is ignored. */</span>
f_mount(0, "1:", 0); <span class="c">/* Unregister work area from the logical drive 1 */</span> f_mount(0, "1:", 0); <span class="c">/* Unregister work area from the logical drive 1 */</span>
+27 -20
View File
@@ -12,16 +12,16 @@
<body> <body>
<h1>Path Names</h1> <h1>Path Names</h1>
<div class="para" id="nam"> <div class="para doc" id="nam">
<h3>Format of the path names</h3> <h3>Format of the path names</h3>
<p>The format of path name on the FatFs module is similer to the filename specs of DOS/Windos as follows:</p> <p>The format of path name on the FatFs module is similer to the filename specs of DOS/Windos as follows:</p>
<pre>"[drive#:][/]directory/file"</pre> <pre>"[<em>drive</em>:][/]<em>directory</em>/<em>file</em>"</pre>
<p>The FatFs module supports long file name (LFN) and 8.3 format file name (SFN). The LFN can be used when LFN feature is enabled (<tt>_USE_LFN &gt; 0</tt>). The sub directories are separated with a \ or / in the same way as DOS/Windows API. Duplicated separators are skipped and ignored. Only a difference is that the logical drive is specified in a numeral with a colon. When the drive number is omitted, it is assumed as <em>default drive</em> (drive 0 or current drive).</p> <p>The FatFs module supports long file name (LFN) and 8.3 format file name (SFN). The LFN can be used when (<tt><a href="config.html#use_lfn">_USE_LFN</a> != 0</tt>). The sub directories are separated with a \ or / in the same way as DOS/Windows API. Duplicated separators are skipped and ignored. Only a difference is that the logical drive is specified in a numeral with a colon. When drive number is omitted, the drive number is assumed as <em>default drive</em> (drive 0 or current drive).</p>
<p>Control characters (<tt>'\0'</tt> to <tt>'\x1F'</tt>) are recognized as end of the path name. Leading/embedded spaces in the path name are valid as a part of the name at LFN configuration but they are recognized as end of the path name at non-LFN configuration. Trailing spaces and dots are ignored.</p> <p>Control characters (<tt>'\0'</tt> to <tt>'\x1F'</tt>) are recognized as end of the path name. Leading/embedded spaces in the path name are valid as a part of the name at LFN configuration but the space is recognized as end of the path name at non-LFN configuration. Trailing spaces and dots are ignored at both configurations.</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><a href="config.html#fs_rpath">_FS_RPATH</a> == 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 (<tt>".", ".."</tt>) are not allowed. Heading separator is ignored and it can be exist or omitted. The default drive is fixed to drive 0.</p>
<p>When relative path feature is enabled (<tt>_FS_RPATH == 1</tt>), specified path is followed from the root directory if a heading separator is exist. If not, it is followed from the current directory set with <a href="chdir.html">f_chdir</a> function. Dot names are also allowed for the path name. The default drive is the current drive set with <a href="chdrive.html">f_chdrive</a> function.</p> <p>When relative path is enabled (<tt>_FS_RPATH &gt;= 1</tt>), specified path is followed from the root directory if a heading separator is exist. If not, it is followed from the current directory of the drive set by <a href="chdir.html">f_chdir</a> function. Dot names are also allowed for the path names. The default drive is the current drive set by <a href="chdrive.html">f_chdrive</a> function.</p>
<table class="lst2"> <table class="lst2">
<tr><td>Path name</td><td>_FS_RPATH == 0</td><td>_FS_RPATH == 1</td></tr> <tr><td>Path name</td><td>_FS_RPATH == 0</td><td>_FS_RPATH &gt;= 1</td></tr>
<tr class="lst3"><td>file.txt</td><td>A file in the root directory of the drive 0</td><td>A file in the current directory of the current drive</td></tr> <tr class="lst3"><td>file.txt</td><td>A file in the root directory of the drive 0</td><td>A file in the current directory of the current drive</td></tr>
<tr><td>/file.txt</td><td>A file in the root directory of the drive 0</td><td>A file in the root directory of the current drive</td></tr> <tr><td>/file.txt</td><td>A file in the root directory of the drive 0</td><td>A file in the root directory of the current drive</td></tr>
<tr><td></td><td>The root directory of the drive 0</td><td>The current directory of the current drive</td></tr> <tr><td></td><td>The root directory of the drive 0</td><td>The current directory of the current drive</td></tr>
@@ -31,17 +31,24 @@
<tr><td>2:file.txt</td><td>A file in the root directory of the drive 2</td><td>A file in the current directory of the drive 2</td></tr> <tr><td>2:file.txt</td><td>A file in the root directory of the drive 2</td><td>A file in the current directory of the drive 2</td></tr>
<tr><td>../file.txt</td><td>Invalid name</td><td>A file in the parent directory</td></tr> <tr><td>../file.txt</td><td>Invalid name</td><td>A file in the parent directory</td></tr>
<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>The root directory (sticks the top level)</td></tr> <tr><td>/..</td><td>Invalid name</td><td>The root directory (sticks the top level)</td></tr>
</table> </table>
<p>When option <tt>_STR_VOLUME_ID</tt> is specified, also pre-defined strings can be used as drive identifier in the path name instead of a numeral.</p> <p>When option <tt><a href="config.html#str_volume_id">_STR_VOLUME_ID</a></tt> is specified, also pre-defined strings can be used as drive identifier in the path name instead of a numeral. e.g. <tt>"sd:file1.txt"</tt> or <tt>"ram:swapfile.dat"</tt>.</p>
<p><em>Remark: In this revision, R0.12, double dot name <tt>".."</tt> cannot follow the parent directory on the exFAT volume. It will work as <tt>"."</tt> and stay there.</em></p>
</div> </div>
<p><br></p> <div class="para doc" id="case">
<div class="para" id="uni"> <h3>Legal Characters and Case Sensitivity</h3>
<p>On the FAT file system, legal characters for file name are, <tt>0-9 A-Z ! # $ % &amp; ' ( ) - @ ^ _ ` { } ~</tt> and extended characters (<tt>\x80</tt>-<tt>\xFF</tt>). Under LFN supported system, also white space and <tt>+ , ; = [ ]</tt> are legal for the file name and the white spaces and periods can be placed anywhere in the name except for end of the name string.</p>
<p>FAT file system is case-insensitive to the object names on the volume. All object names are compared in case-insensitive. For example, these three names, <tt>file.txt</tt>, <tt>File.Txt</tt> and <tt>FILE.TXT</tt>, are identical. This is applied to also extended charactres. When an object is created on the FAT volume, upper converted name is recorded to the SFN entry, and the raw name is recorded to the LFN entry.</p>
<p>As for the DBCS language MS-DOS, it was case-sensitive to the extended characters. To follow this specification, FatFs works with case-sensitive to the extended characters at only non-LFN with DBCS configuration (DOS/DBCS specs). But at LFN configuration, FatFs works with case-insensitive to all characters (WindowsNT specs). This can cause a problem on compatibility with Windows system when an object with extended characters is created on the volume at non-LFN and DBCS configuration; therfore the object names with DBCS extended characters should not be used on the FAT volume shared by those systems.</p>
</div>
<div class="para doc" id="uni">
<h3>Unicode API</h3> <h3>Unicode API</h3>
<p>The path names are input/output in either ANSI/OEM code (SBCS/DBCS) or Unicode depends on the configuration options. The type of arguments which specify the file names are defined as <tt>TCHAR</tt>. It is an alias of <tt>char</tt> in default. The code set used to the file name string is ANSI/OEM specifid by <tt>_CODE_PAGE</tt>. When <tt>_LFN_UNICODE</tt> is set to 1, the type of the <tt>TCHAR</tt> is switched to <tt>WCHAR</tt> to support Unicode (UTF-16 encoding). In this case, the LFN feature is fully supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name. It also affects data types and encoding of the string I/O functions. To define literal strings, <tt>_T(s)</tt> and <tt>_TEXT(s)</tt> macro are available to select either ANSI/OEM or Unicode automatically. The code shown below is an example to define the literal strings.</p> <p>The path names are input/output in either ANSI/OEM code or Unicode depends on the configuration options. The type of arguments which specify the path names are defined as <tt>TCHAR</tt>. It is an alias of <tt>char</tt> by default. The code set used to the path name string is ANSI/OEM specifid by <tt><a href="config.html#code_page">_CODE_PAGE</a></tt>. When <tt><a href="config.html#lfn_unicode">_LFN_UNICODE</a></tt> is set to 1, the type of the <tt>TCHAR</tt> is switched to <tt>WCHAR</tt> to support Unicode (UTF-16 encoding). In this case, the full-featured LFN specification is 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> <pre>
f_open(fp, "filename.txt", FA_READ); <span class="c">/* ANSI/OEM string */</span> f_open(fp, "filename.txt", FA_READ); <span class="c">/* ANSI/OEM string */</span>
f_open(fp, L"filename.txt", FA_READ); <span class="c">/* Unicode string */</span> f_open(fp, L"filename.txt", FA_READ); <span class="c">/* Unicode string */</span>
@@ -49,11 +56,10 @@
</pre> </pre>
</div> </div>
<p><br></p> <div class="para doc" id="vol">
<div class="para" id="vol">
<h3>Volume Management</h3> <h3>Volume Management</h3>
<p>The FatFs module needs dynamic work area called <em>file system object</em> for each volume (logical drive). It is registered to the FatFs module by <tt>f_mount()</tt> function. By default, each logical drive is bound to the physical drive with the same drive number and an FAT volume on the drive is serched by auto detect feature. It loads boot sectors and checks it if it is an FAT boot sector in order of sector 0 as SFD format, 1st partition, 2nd partition, 3rd partition and 4th partition as FDISK format.</p> <p>The FatFs module needs dynamic work area called <em>file system object</em> for each volume (logical drive). It is registered to the FatFs module by <tt>f_mount</tt> function. By default, each logical drive is bound to the physical drive with the same drive number and an FAT volume on the drive is serched by volume mount process. It loads boot sectors and checks it if it is an FAT boot sector in order of sector 0 as SFD format, 1st partition, 2nd partition, 3rd partition and 4th partition as FDISK format.</p>
<p>When <tt>_MULTI_PARTITION == 1</tt> is specified by configuration option, each individual logical drive is bound to the partition on the physical drive specified by volume management table. The volume management table must be defined by user to resolve relationship between logical drives and partitions. Following code is an example of a volume management table.</p> <p>When <tt><a href="config.html#multi_partition">_MULTI_PARTITION</a> == 1</tt> is specified by configuration option, each individual logical drive is bound to the partition on the physical drive specified by volume management table. The volume management table must be defined by user to resolve the relationship between logical drives and partitions. Following code is an example of a volume management table.</p>
<pre> <pre>
Example: Logical drive 0-2 are tied to three pri-partitions on the physical drive 0 (fixed disk) Example: Logical drive 0-2 are tied to three pri-partitions on the physical drive 0 (fixed disk)
Logical drive 3 is tied to an FAT volume on the physical drive 1 (removable disk) Logical drive 3 is tied to an FAT volume on the physical drive 1 (removable disk)
@@ -64,15 +70,16 @@ PARTITION VolToPart[] = {
{0, 3}, <span class="c">/* Logical drive 2 ==> Physical drive 0, 3rd partition */</span> {0, 3}, <span class="c">/* Logical drive 2 ==> Physical drive 0, 3rd partition */</span>
{1, 0} <span class="c">/* Logical drive 3 ==> Physical drive 1 (auto detection) */</span> {1, 0} <span class="c">/* Logical drive 3 ==> Physical drive 1 (auto detection) */</span>
}; };
<img src="../img/f7.png" width="828" height="288" alt="relationship between logical drive and physical drive">
</pre> </pre>
<p>There are some considerations on using <tt>_MULTI_PARTITION</tt> configuration.</p> <div><img src="../img/f7.png" width="828" height="288" alt="relationship between logical drive and physical drive"></div>
<p>There are some considerations on using multi-partition configuration.</p>
<ul> <ul>
<li>Only four primary partitions can be specified. Logical partition is not supported.</li>
<li>The physical drive that has two or more mounted partitions must be non-removable. Media change while a system operation is prohibited.</li> <li>The physical drive that has two or more mounted partitions must be non-removable. Media change while a system operation is prohibited.</li>
<li>Only four primary partitions can be specified. Extended partition is not supported.</li>
<li>Windows does not support multiple volumes on the removable storage. Only first parition will be mounted.</li>
</ul> </ul>
</div> </div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body> </body>
</html> </html>
+110
View File
@@ -0,0 +1,110 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/findfirst.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_findfirst</title>
</head>
<body>
<div class="para func">
<h2>f_findfirst</h2>
<p>The f_findfirst function searches a directroy for an item.</p>
<pre>
FRESULT f_findfirst (
DIR* <span class="arg">dp</span>, <span class="c">/* [OUT] Poninter to the directory object */</span>
FILINFO* <span class="arg">fno</span>, <span class="c">/* [OUT] Pointer to the file information structure */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Pointer to the directory name to be opened */</span>
const TCHAR* <span class="arg">pattern</span> <span class="c">/* [IN] Pointer to the matching pattern string */</span>
);
</pre>
</div>
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>dp</dt>
<dd>Pointer to the blank directory object.</dd>
<dt>fno</dt>
<dd>Pointer to the file information structure to store the information about the found item.</dd>
<dt>path</dt>
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">directory name</a> to be opened.</dd>
<dt>pattern</dt>
<dd>Pointer to the nul-terminated string that specifies the name matching pattern to be searched for. It is referred by also subsequent <tt>f_findnext</tt> function, so that the string must be valid while the successive function calls.</dd>
</dl>
</div>
<div class="para ret">
<h4>Return Values</h4>
<p>
<a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#np">FR_NO_PATH</a>,
<a href="rc.html#in">FR_INVALID_NAME</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
<a href="rc.html#ne">FR_NOT_ENABLED</a>,
<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
<a href="rc.html#tm">FR_TIMEOUT</a>,
<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>,
<a href="rc.html#tf">FR_TOO_MANY_OPEN_FILES</a>
</p>
</div>
<div class="para desc">
<h4>Description</h4>
<p>After the directory specified by <tt class="arg">path</tt> could be opened, it starts to search the directory for the items with a name specified by <tt class="arg">pattern</tt>. If found, the information about the object is stored into the file information structure. For more information about file information structure, refer to <a href="readdir.html"><tt>f_readdir</tt></a> function.</p>
<p>The matching pattern can contain wildcard characters (<tt>?</tt> and <tt>*</tt>). A <tt>?</tt> matches an any character and an <tt>*</tt> matches an any string in length of zero or longer. When support of long file name is enabled, only <tt>fname[]</tt> is tested at <tt>_USE_FIND == 1</tt> and also <tt>altname[]</tt> is tested at <tt>_USE_FIND == 2</tt>. In this revision, there are some differences listed below between FatFs and standard systems in matching condition.</p>
<ul>
<li><tt>"*.*"</tt> never matches any name without extension while it matches any names at the standard systems.</li>
<li>Any patterns terminated with a period never matches any name while it matches any names without extensiton at the standard systems.</li>
<li><a href="filename.html#case">DBCS extended characters</a> are compared in case-sensitive at LFN and non-Unicode configuration.</li>
</ul>
</div>
<div class="para comp">
<h4>QuickInfo</h4>
<p>This is a wrapper function of <a href="opendir.html"><tt>f_opendir</tt></a> and <a href="readdir.html"><tt>f_readdir</tt></a> function. Available when <tt>_USE_FIND &lt;= 1</tt> and <tt>_FS_MINIMIZE &lt;= 1</tt>.</p>
</div>
<div class="para use">
<h4>Examples</h4>
<pre>
<span class="c">/* Search a directory for objects and display it */</span>
void find_image (void)
{
FRESULT fr; <span class="c">/* Return value */</span>
DIR dj; <span class="c">/* Directory search object */</span>
FILINFO fno; <span class="c">/* File information */</span>
fr = f_findfirst(&amp;dj, &amp;fno, "", "dsc*.jpg"); <span class="c">/* Start to search for photo files */</span>
while (fr == FR_OK &amp;&amp; fno.fname[0]) { <span class="c">/* Repeat while an item is found */</span>
printf("%s\n", fno.fname); <span class="c">/* Display the object name */</span>
fr = f_findnext(&amp;dj, &amp;fno); <span class="c">/* Search for next item */</span>
}
f_closedir(&amp;dj);
}
</pre>
</div>
<div class="para ref">
<h4>See Also</h4>
<p><tt><a href="findnext.html">f_findnext</a>, <a href="closedir.html">f_closedir</a>, <a href="sdir.html">DIR</a>, <a href="sfileinfo.html">FILINFO</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>
+69
View File
@@ -0,0 +1,69 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_e.html">
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/findnext.html">
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_findnext</title>
</head>
<body>
<div class="para func">
<h2>f_findnext</h2>
<p>The f_findnext function searches for a next matched object</p>
<pre>
FRESULT f_findnext (
DIR* <span class="arg">dp</span>, <span class="c">/* [IN] Poninter to the directory object */</span>
FILINFO* <span class="arg">fno</span> <span class="c">/* [OUT] Pointer to the file information structure */</span>
);
</pre>
</div>
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>dp</dt>
<dd>Pointer to the valid directory object created by <tt>f_findfirst</tt> function.</dd>
<dt>fno</dt>
<dd>Pointer to the file information structure to store the information about the found directory item.</dd>
</dl>
</div>
<div class="para ret">
<h4>Return Values</h4>
<p>
<a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#tm">FR_TIMEOUT</a>,
<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
</p>
</div>
<div class="para desc">
<h4>Description</h4>
<p>It continues the search from a previous call to the <tt>f_findfirst</tt> or <tt>f_findnext</tt> function. If found, the information about the object is stored into the file information structure. If no item to be read, a null string will be returned into <tt>fno-&gt;fname[]</tt>.</p>
</div>
<div class="para comp">
<h4>QuickInfo</h4>
<p>This is a wrapper function of <a href="readdir.html"><tt>f_readdir</tt></a> function. Available when <tt>_USE_FIND == 1</tt> and <tt>_FS_MINIMIZE &lt;= 1</tt>.</p>
</div>
<div class="para ref">
<h4>See Also</h4>
<p><tt><a href="findfirst.html">f_findfirst</a>, <a href="closedir.html">f_closedir</a>, <a href="sdir.html">DIR</a>, <a href="sfileinfo.html">FILINFO</a></tt></p>
</div>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body>
</html>
+2 -3
View File
@@ -45,7 +45,6 @@ FRESULT f_forward (
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>, <a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>, <a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#tm">FR_TIMEOUT</a> <a href="rc.html#tm">FR_TIMEOUT</a>
</p> </p>
@@ -54,7 +53,7 @@ FRESULT f_forward (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_forward()</tt> function reads the data from the file and forward it to the outgoing stream without data buffer. This is suitable for small memory system because it does not require any data buffer at application module. The file pointer of the file object increases in number of bytes forwarded. In case of <tt class="arg">*bf</tt> is less than <tt class="arg">btf</tt> without error, it means the requested bytes could not be transferred due to end of file or stream goes busy during data transfer.</p> <p>The <tt>f_forward</tt> function reads the data from the file and forward it to the outgoing stream without data buffer. This is suitable for small memory system because it does not require any data buffer at application module. The file pointer of the file object increases in number of bytes forwarded. In case of <tt class="arg">*bf</tt> is less than <tt class="arg">btf</tt> without error, it means the requested bytes could not be transferred due to end of file or stream goes busy during data transfer.</p>
</div> </div>
@@ -113,7 +112,7 @@ FRESULT play_file (
if (rc) return rc; if (rc) return rc;
<span class="c">/* Repeat until the file pointer reaches end of the file */</span> <span class="c">/* 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; !f_eof(&amp;fil)) {
<span class="c">/* any other processes... */</span> <span class="c">/* any other processes... */</span>
+4 -3
View File
@@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>f_getcwd</h2> <h2>f_getcwd</h2>
<p>The f_getcwd function retrieves the current directory.</p> <p>The f_getcwd function retrieves the current directory and current drive.</p>
<pre> <pre>
FRESULT f_getcwd ( FRESULT f_getcwd (
TCHAR* <span class="arg">buff</span>, <span class="c">/* [OUT] Buffer to return path name */</span> TCHAR* <span class="arg">buff</span>, <span class="c">/* [OUT] Buffer to return path name */</span>
@@ -28,7 +28,7 @@ FRESULT f_getcwd (
<dt>buff</dt> <dt>buff</dt>
<dd>Pointer to the buffer to receive the current directory string.</dd> <dd>Pointer to the buffer to receive the current directory string.</dd>
<dt>len</dt> <dt>len</dt>
<dd>Size of the buffer in unit of TCHAR.</dd> <dd>Size of the buffer in unit of <tt>TCHAR</tt>.</dd>
</dl> </dl>
</div> </div>
@@ -50,7 +50,8 @@ FRESULT f_getcwd (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_getcwd()</tt> function retrieves full path name of the current directory of the current drive. When <tt>_VOLUMES</tt> is larger than 1, a logical drive number is added to top of the path name.</p> <p>The <tt>f_getcwd</tt> function retrieves full path name of the current directory of the current drive. When <tt>_VOLUMES</tt> is larger than 1, a logical drive number is added to top of the path name.</p>
<p><em>Note: In this revision, R0.12, this function cannot retrieve the current directory path on the exFAT volume. It always returns the root directory path.</em></p>
</div> </div>
+3 -3
View File
@@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>f_getfree</h2> <h2>f_getfree</h2>
<p>The f_getfree function gets number of the free clusters.</p> <p>The f_getfree function gets number of the free clusters on the volume.</p>
<pre> <pre>
FRESULT f_getfree ( FRESULT f_getfree (
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Logical drive number */</span> const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Logical drive number */</span>
@@ -27,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">logical drive</a>. A null-string means the default drive.</dd> <dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. A null-string means the default drive.</dd>
<dt>nclst</dt> <dt>nclst</dt>
<dd>Pointer to the <tt>DWORD</tt> variable to store number of free clusters.</dd> <dd>Pointer to the <tt>DWORD</tt> variable to store number of free clusters.</dd>
<dt>fatfs</dt> <dt>fatfs</dt>
@@ -53,7 +53,7 @@ FRESULT f_getfree (
<div class="para desc"> <div class="para desc">
<h4>Descriptions</h4> <h4>Descriptions</h4>
<p>The <tt>f_getfree()</tt> function gets number of free clusters on the volume. The member <tt>csize</tt> in the file system object indicates number of sectors per cluster, so that the free space in unit of sector can be calcurated with this information. When FSINFO structure on the FAT32 volume is not in sync, this function can return an incorrect free cluster count. To avoid this problem, FatFs can be forced full FAT scan by <tt>_FS_NOFSINFO</tt> option.</p> <p>The <tt>f_getfree</tt> function gets number of free clusters on the volume. The member <tt>csize</tt> in the file system object indicates number of sectors per cluster, so that the free space in unit of sector can be calcurated with this information. When FSINFO structure on the FAT32 volume is not in sync, this function can return an incorrect free cluster count. To avoid this problem, FatFs can be forced full FAT scan by <tt><a href="config.html#fs_nofsinfo">_FS_NOFSINFO</a></tt> option.</p>
</div> </div>
+6 -6
View File
@@ -17,8 +17,8 @@
<pre> <pre>
FRESULT f_getlabel ( FRESULT f_getlabel (
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Drive number */</span> const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Drive number */</span>
TCHAR* <span class="arg">buff</span>, <span class="c">/* [OUT] Volume label */</span> TCHAR* <span class="arg">label</span>, <span class="c">/* [OUT] Volume label */</span>
DWORD* <span class="arg">sn</span> <span class="c">/* [OUT] Volume serial number */</span> DWORD* <span class="arg">vsn</span> <span class="c">/* [OUT] Volume serial number */</span>
); );
</pre> </pre>
</div> </div>
@@ -28,9 +28,9 @@ FRESULT f_getlabel (
<dl class="par"> <dl class="par">
<dt>path</dt> <dt>path</dt>
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. Null-string specifies the default drive.</dd> <dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. Null-string specifies the default drive.</dd>
<dt>buff</dt> <dt>label</dt>
<dd>Pointer to the buffer to store the volume label. The buffer size must be at least 12 items. If the volume has no label, a null-string will be returned. Set null pointer if this information is not needed.</dd> <dd>Pointer to the buffer to store the volume label. The buffer size must be at least 24 items at <tt>_LFN_UNICODE == 0</tt>, 12 items at <tt>_LFN_UNICODE == 1</tt>. If the volume has no label, a null-string will be returned. Set null pointer if this information is not needed.</dd>
<dt>sn</dt> <dt>vsn</dt>
<dd>Pointer to the <tt>DWORD</tt> variable to store the volume serial number. Set null pointer if this information is not needed.</dd> <dd>Pointer to the <tt>DWORD</tt> variable to store the volume serial number. Set null pointer if this information is not needed.</dd>
</dl> </dl>
</div> </div>
@@ -60,7 +60,7 @@ FRESULT f_getlabel (
<div class="para use"> <div class="para use">
<h4>Example</h4> <h4>Example</h4>
<pre> <pre>
char str[12]; char str[24];
<span class="c">/* Get volume label of the default drive */</span> <span class="c">/* Get volume label of the default drive */</span>
f_getlabel("", str, 0); f_getlabel("", str, 0);
+3 -3
View File
@@ -44,14 +44,14 @@ TCHAR* f_gets (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_gets()</tt> function is a wrapper function of <a href="read.html"><tt>f_read()</tt></a> function. The read operation continues until a <tt>'\n'</tt> is stored, reached end of the file or the buffer is filled with <tt>len - 1</tt> characters. The read string is terminated with a <tt>'\0'</tt>. When no character to read or any error occured during read operation, it returns a null pointer. The status of EOF and error can be examined with <tt>f_eof()</tt> and <tt>f_error()</tt> macros.</p> <p>The read operation continues until a <tt>'\n'</tt> is stored, reached end of the file or the buffer is filled with <tt>len - 1</tt> characters. The read string is terminated with a <tt>'\0'</tt>. When no character to read or any error occured during read operation, it returns a null pointer. The status of EOF and error can be examined with <tt>f_eof</tt> and <tt>f_error</tt> function.</p>
<p>When FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), data types on the srting fuctions, <tt>f_putc()</tt>, <tt>f_puts()</tt>, <tt>f_printf()</tt> and <tt>f_gets()</tt>, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by <tt>_STRF_ENCODE</tt> option.</p> <p>When FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), data types on the srting fuctions, <tt>f_putc</tt>, <tt>f_puts</tt>, <tt>f_printf</tt> and <tt>f_gets</tt>, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by <tt>_STRF_ENCODE</tt> option.</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>QuickInfo</h4> <h4>QuickInfo</h4>
<p>Available when <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\r'</tt>s contained in the file are stripped out.</p> <p>This is a wrapper function of <a href="read.html"><tt>f_read</tt></a> function. Available when <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\r'</tt>s contained in the file are stripped out.</p>
</div> </div>
+13 -12
View File
@@ -18,7 +18,7 @@
<pre> <pre>
FRESULT f_lseek ( FRESULT f_lseek (
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] File object */</span> FIL* <span class="arg">fp</span>, <span class="c">/* [IN] File object */</span>
DWORD <span class="arg">ofs</span> <span class="c">/* [IN] File read/write pointer */</span> FSIZE_t <span class="arg">ofs</span> <span class="c">/* [IN] File read/write pointer */</span>
); );
</pre> </pre>
</div> </div>
@@ -29,7 +29,7 @@ FRESULT f_lseek (
<dt>fp</dt> <dt>fp</dt>
<dd>Pointer to the open file object.</dd> <dd>Pointer to the open file object.</dd>
<dt>ofs</dt> <dt>ofs</dt>
<dd>Byte offset from top of the file.</dd> <dd>Byte offset from top of the file. The data type <tt>FSIZE_t</tt> is an alias of either <tt>DWORD</tt>(32-bit) or <tt>QWORD</tt>(64-bit) depends on the configuration option <tt>_FS_EXFAT</tt>.</dd>
</dl> </dl>
</div> </div>
@@ -40,7 +40,6 @@ FRESULT f_lseek (
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>, <a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>, <a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#tm">FR_TIMEOUT</a> <a href="rc.html#tm">FR_TIMEOUT</a>
</p> </p>
@@ -49,19 +48,19 @@ FRESULT f_lseek (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_lseek()</tt> function moves the file read/write pointer of an open file. The offset can be specified in only origin from top of the file. When an offset beyond the file size is specified in write mode, the file size is expanded to the specified offset. The file data in the expanded area is undefined because no data is written to the file. This is suitable to pre-allocate a cluster chain quickly, for fast write operation. After the <tt>f_lseek()</tt> function succeeded, the current read/write pointer should be checked in order to make sure the read/write pointer has been moved correctry. In case of the current read/write pointer is not the expected value, either of followings has been occured.</p> <p>The <tt>f_lseek</tt> function moves the file read/write pointer of an open file. The offset can be specified in only origin from top of the file. When an offset beyond the file size is specified at write mode, the file size is expanded to the specified offset. The file data in the expanded area is undefined because no data is written to the file. This is suitable to pre-allocate a cluster chain quickly, for fast write operation. When a contiguous data area needs to be allocated to the file, use <tt>f_expand</tt> function instead. After the <tt>f_lseek</tt> function succeeded, the current read/write pointer should be checked in order to make sure the read/write pointer has been moved correctry. In case of the read/write pointer is not the expected value, either of followings has been occured.</p>
<ul> <ul>
<li>End of file. The specified <tt class="arg">ofs</tt> was clipped at end of the file because the file has been opened in read-only mode.</li> <li>End of file. The specified <tt class="arg">ofs</tt> was clipped at end of the file because the file has been opened in read-only mode.</li>
<li>Disk full. There is insufficient free space on the volume to expand the file.</li> <li>Disk full. There is no free space on the volume to expand the file.</li>
</ul> </ul>
<p>Fast seek feature is enabled when <tt>_USE_FASTSEEK</tt> is set to 1 and the member <tt>cltbl</tt> in the file object is not NULL. This feature enables fast backward/long seek operations without FAT access by using cluster link map table (CLMT). It is also applied to <tt>f_read()/f_write()</tt> function. In this mode, the file cannot be expanded by <tt>f_write()/f_lseek()</tt> function.</p> <p>The fast seek function enables fast backward/long seek operations without FAT access by using an on-memory CLMT (cluster link map table). It is applied to <tt>f_read</tt> and <tt>f_write</tt> function as well, however, the file size cannot be expanded by <tt>f_write</tt>, <tt>f_lseek</tt> function while the file is in fast seek mode.</p>
<p>The CLMT must be created in the user defined <tt>DWORD</tt> array prior to use the fast seek feature. To create the CLMT, set address of the <tt>DWORD</tt> array to the member <tt>cltbl</tt> in the file object, set the array size in unit of items into the first item and call the <tt>f_lseek()</tt> function with <tt class="arg">ofs</tt><tt> = CREATE_LINKMAP</tt>. After the function succeeded and CLMT is created, no FAT access is occured in subsequent <tt>f_read()/f_write()/f_lseek()</tt> function to the file. If the function failed with <tt>FR_NOT_ENOUGH_CORE</tt>, the given array size is insufficient for the file and number of items required is returned into the first item of the array. The required array size is (number of fragments + 1) * 2 items. For example, when the file is fragmented in 5, 12 items will be required for the CLMT.</p> <p>The fast seek function is enabled when the member <tt>cltbl</tt> in the file object is not NULL. The CLMT must be created into the <tt>DWORD</tt> array prior to use the fast seek function. To create the CLMT, set address of the <tt>DWORD</tt> array to the member <tt>cltbl</tt> in the open file object, set the size of array in unit of items to the first item and call the <tt>f_lseek</tt> function with <tt class="arg">ofs</tt><tt> = CREATE_LINKMAP</tt>. After the function succeeded and CLMT is created, no FAT access is occured in subsequent <tt>f_read</tt>, <tt>f_write</tt>, <tt>f_lseek</tt> function to the file. The number of items used or required is returned into the first item of the array. The number of items to be used is (number of the file fragments + 1) * 2. For example, when the file is fragmented in 5, 12 items in the array will be used. If the function failed with <tt>FR_NOT_ENOUGH_CORE</tt>, the given array size is insufficient for the file.</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>QuickInfo</h4> <h4>QuickInfo</h4>
<p>Available when <tt>_FS_MINIMIZE &lt;= 2</tt>.</p> <p>Available when <tt>_FS_MINIMIZE &lt;= 2</tt>. To use fast seek function, <tt>_USE_FASTSEEK</tt> needs to be set 1.</p>
</div> </div>
@@ -94,7 +93,7 @@ FRESULT f_lseek (
if (res || f_tell(fp) != PRE_SIZE) ... <span class="c">/* Check if the file has been expanded */</span> if (res || f_tell(fp) != PRE_SIZE) ... <span class="c">/* Check if the file has been expanded */</span>
res = f_lseek(fp, DATA_START); <span class="c">/* Record data stream WITHOUT cluster allocation delay */</span> res = f_lseek(fp, DATA_START); <span class="c">/* Record data stream WITHOUT cluster allocation delay */</span>
... <span class="c">/* DATA_START and write block size should be aligned to sector boundary */</span> ... <span class="c">/* Write operation should be aligned to sector boundary to optimize the write throughput */</span>
res = f_truncate(fp); <span class="c">/* Truncate unused area */</span> res = f_truncate(fp); <span class="c">/* Truncate unused area */</span>
res = f_lseek(fp, 0); <span class="c">/* Put file header */</span> res = f_lseek(fp, 0); <span class="c">/* Put file header */</span>
@@ -103,13 +102,15 @@ FRESULT f_lseek (
res = f_close(fp); res = f_close(fp);
</pre> </pre>
<pre> <pre>
<span class="c">/* Using fast seek feature */</span> <span class="c">/* Using fast seek function */</span>
DWORD clmt[SZ_TBL]; <span class="c">/* Cluster link map table buffer */</span> DWORD clmt[SZ_TBL]; <span class="c">/* Cluster link map table buffer */</span>
res = f_open(fp, fname, FA_READ | FA_WRITE); <span class="c">/* Open a file */</span>
res = f_lseek(fp, ofs1); <span class="c">/* This is normal seek (cltbl is nulled on file open) */</span> res = f_lseek(fp, ofs1); <span class="c">/* This is normal seek (cltbl is nulled on file open) */</span>
fp-&gt;cltbl = clmt; <span class="c">/* Enable fast seek feature (cltbl != NULL) */</span> fp-&gt;cltbl = clmt; <span class="c">/* Enable fast seek function (cltbl != NULL) */</span>
clmt[0] = SZ_TBL; <span class="c">/* Set table size */</span> clmt[0] = SZ_TBL; <span class="c">/* Set table size */</span>
res = f_lseek(fp, CREATE_LINKMAP); <span class="c">/* Create CLMT */</span> res = f_lseek(fp, CREATE_LINKMAP); <span class="c">/* Create CLMT */</span>
... ...
@@ -121,7 +122,7 @@ FRESULT f_lseek (
<div class="para ref"> <div class="para ref">
<h4>See Also</h4> <h4>See Also</h4>
<p><tt><a href="open.html">f_open</a>, <a href="truncate.html">f_truncate</a>, <a href="sfile.html">FIL</a></tt></p> <p><tt><a href="open.html">f_open</a>, <a href="truncate.html">f_truncate</a>, <a href="expand.html">f_expand</a>, <a href="sfile.html">FIL</a></tt></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>
+1 -1
View File
@@ -53,7 +53,7 @@ FRESULT f_mkdir (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>This function creates a new directory.</p> <p>This function creates a new directory. To remove a directory, use <a href="unlink.html"><tt>f_unlink</tt></a> function.</p>
</div> </div>
+44 -9
View File
@@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>f_mkfs</h2> <h2>f_mkfs</h2>
<p>The f_mkfs fucntion creates an FAT file system on the logical drive.</p> <p>The f_mkfs fucntion creates an FAT volume on the logical drive.</p>
<pre> <pre>
FRESULT f_mkfs ( FRESULT f_mkfs (
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Logical drive number */</span> const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Logical drive number */</span>
@@ -27,11 +27,11 @@ FRESULT f_mkfs (
<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">logical drive</a> to be formatted. If there is no drive number, it means the default drive.</dd> <dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a> to be formatted. If there is no drive number, it means the default drive.</dd>
<dt>sfd</dt> <dt>sfd</dt>
<dd>Specifies partitioning rule (FDISK(0) or SFD(1)). This argument will be ignored on some case.</dd> <dd>Specifies partitioning rule, FDISK format (0) or SFD format (1). This argument will be ignored on some case.</dd>
<dt>au</dt> <dt>au</dt>
<dd>Specifies size of the allocation unit (cluter) in unit of byte. The value must be sector size * n (n is 1 to 128 and power of 2). When a zero is given, the cluster size is determined depends on the volume size.</dd> <dd>Specifies size of the allocation unit (cluter) in number of bytes or sectors. When the value is from 1 to 128, it specifies it in number of sectors. When the value is <tt>&gt;= _MIN_SS</tt>, it specifies it in number of bytes. If any invalid value, zero or not power of 2, is given, the cluster size is automatically determined depends on the volume size.</dd>
</dl> </dl>
</div> </div>
@@ -51,11 +51,11 @@ FRESULT f_mkfs (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_mkfs()</tt> function creates an FAT volume on the logical drive. When FDISK format is specified, a primary partition occupies the entire disk space is created and then an FAT volume is created on the partition. When SFD format is specified, the FAT volume starts from the first sector of the physical drive.</p> <p>The <tt>f_mkfs</tt> function creates an FAT volume on the specified logical drive. When FDISK format is specified, a primary partition occupies entire space of the physical drive and then an FAT volume is created on the partition. When SFD format is specified, the FAT volume starts from the first sector of the physical drive.</p>
<p>If the logical drive has been bound to any partition (1-4) by multiple partition feature (<tt>_MULTI_PARTITION</tt>), the FAT volume is created into the specified partition. In this case, the second argument <tt class="arg">sfd</tt> is ignored. The physical drive must have been partitioned with <tt>f_fdisk()</tt> function or any other partitioning tool prior to use this function.</p> <p>There are two partitioning rules, FDISK and SFD. The FDISK partitioning is usually used for harddisk, MMC, SDC, CFC and U Disk. It can divide a physical drive into one or more partitions with a partition table on the MBR. However Windows does not support multiple partition on the removable drive. The SFD is non-partitioned method. The FAT volume starts from the first sector on the physical drive without partition table. It is usually used for floppy disk, Microdrive, optical disk and any type of super-floppy media.</p>
<p>Note that there are two partitioning rules, FDISK and SFD. The FDISK partitioning is usually used for harddisk, MMC, SDC, CFC and U Disk. It can divide a physical drive into one or more partitions with a partition table on the MBR. However Windows does not support multiple partition on the removable media. The SFD is non-partitioned method. The FAT volume starts from the first sector on the physical drive without partition table. It is usually used for floppy disk, Microdrive, optical disk and super-floppy media.</p> <p>If the logical drive to be formatted is bound to the specific partition (1-4) by support of multiple partition, <tt><a href="config.html#multi_partition">_MULTI_PARTITION</a></tt>, the FAT volume is created into the partition. In this case, the second argument <tt class="arg">sfd</tt> has no effect. The physical drive must have been partitioned with <tt>f_fdisk</tt> function or any other partitioning tools prior to create the FAT volume with this function.</p>
<p>The FAT sub-type, FAT12/FAT16/FAT32, is determined by number of clusters on the volume and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the volume size and the specified cluster size. The cluster size affects performance of the file system and large cluster increases the performance.</p> <p>The FAT sub-type, FAT12/FAT16/FAT32, is determined by only number of clusters on the volume, 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 read/write throughput and space usage efficiency. Larger cluster size increases the read/write throughput and decreases the space usage efficiency of the volume. In case of the number of clusters comes on the FAT sub-type boundaries, the function can fail with <tt>FR_MKFS_ABORTED</tt>.</p>
<p>When the number of clusters gets near the FAT sub-type boundaries, the function can fail with <tt>FR_MKFS_ABORTED</tt>.</p> <p><em>Remark: Creating exFAT volume is not supported at current revision, R0.12.</em></p>
</div> </div>
<div class="para comp"> <div class="para comp">
@@ -63,6 +63,41 @@ FRESULT f_mkfs (
<p>Available when <tt>_FS_READOLNY == 0</tt> and <tt>_USE_MKFS == 1</tt>.</p> <p>Available when <tt>_FS_READOLNY == 0</tt> and <tt>_USE_MKFS == 1</tt>.</p>
</div> </div>
<div class="para use">
<h4>Example</h4>
<pre>
<span class="c">/* Format default drive and create a file */</span>
int main (void)
{
FATFS fs; <span class="c">/* File system object (volume work area) */</span>
FIL fil; <span class="c">/* File object */</span>
FRESULT res; <span class="c">/* API result code */</span>
UINT bw; <span class="c">/* Bytes written */</span>
<span class="c">/* Register work area (do not care about error) */</span>
f_mount(&amp;fs, "", 0);
<span class="c">/* Create FAT volume with default cluster size */</span>
res = f_mkfs("", 0, 0);
if (res) ...
<span class="c">/* Create a file as new */</span>
res = f_open(&amp;fil, "hello.txt", FA_CREATE_NEW | FA_WRITE);
if (res) ...
<span class="c">/* Write a message */</span>
f_write(&amp;fil, "Hello, World!\r\n", 15, &amp;bw);
if (bw != 15) ...
<span class="c">/* Close the file */</span>
f_close(&amp;fil);
<span class="c">/* Unregister work area */</span>
f_mount(0, "", 0);
</pre>
</div>
<div class="para ref"> <div class="para ref">
<h4>See Also</h4> <h4>See Also</h4>
<p><tt><a href="filename.html#vol">Volume management</a>, <a href="fdisk.html">f_fdisk</a></tt></p> <p><tt><a href="filename.html#vol">Volume management</a>, <a href="fdisk.html">f_fdisk</a></tt></p>
+15 -15
View File
@@ -13,10 +13,10 @@
<div class="para func"> <div class="para func">
<h2>f_mount</h2> <h2>f_mount</h2>
<p>The f_mount fucntion registers/unregisters file system object (work area) to the FatFs module.</p> <p>The f_mount fucntion registers/unregisters file system object to the FatFs module.</p>
<pre> <pre>
FRESULT f_mount ( FRESULT f_mount (
FATFS* <span class="arg">fatfs</span>, <span class="c">/* [IN] File system object */</span> FATFS* <span class="arg">fs</span>, <span class="c">/* [IN] File system object */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Logical drive number */</span> const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Logical drive number */</span>
BYTE <span class="arg">opt</span> <span class="c">/* [IN] Initialization option */</span> BYTE <span class="arg">opt</span> <span class="c">/* [IN] Initialization option */</span>
); );
@@ -26,12 +26,12 @@ FRESULT f_mount (
<div class="para arg"> <div class="para arg">
<h4>Parameters</h4> <h4>Parameters</h4>
<dl class="par"> <dl class="par">
<dt>fatfs</dt> <dt>fs</dt>
<dd>Pointer to the file system object to be registered. Null pointer unregisters the registered file system object.</dd> <dd>Pointer to the file system object to be registered and cleared. Null pointer unregisters the registered file system object.</dd>
<dt>path</dt> <dt>path</dt>
<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. If there is no drive number, it means the default drive.</dd> <dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. The string without drive number means the default drive.</dd>
<dt>opt</dt> <dt>opt</dt>
<dd>Initialization option. 0: Do not mount now (to be mounted later), 1: Force mounted the volume to check if the volume is available.</dd> <dd>Initialization option. 0: Do not mount now (to be mounted later), 1: Force mounted the volume to check if the volume is ready to work.</dd>
</dl> </dl>
</div> </div>
@@ -49,21 +49,21 @@ FRESULT f_mount (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_mount()</tt> function registers/unregisters a file system object used for the logical drive to the FatFs module as follows:</p> <p>The <tt>f_mount</tt> function registers/unregisters a file system object used for the volume (logical drive) to the FatFs module as follows:</p>
<ol> <ol>
<li>Determines the logical drive which specified by <tt class="arg">path</tt>.</li> <li>Determines the logical drive which specified by <tt class="arg">path</tt>.</li>
<li>Clears and unregisters the regsitered work area of the drive.</li> <li>Clears and unregisters the regsitered work area of the drive if exist.</li>
<li>Clears and registers the work area to the drive if <tt class="arg">fatfs</tt> is not NULL.</li> <li>Clears and registers the new work area to the drive if <tt class="arg">fs</tt> is not NULL.</li>
<li>Performs volume mount process to the drive if forced mount is specified.</li> <li>Performs volume mount process to the drive if forced mount is specified.</li>
</ol> </ol>
<p>The file system object is the work area needed for each logical drive. It must be given to the logical drive with this function prior to use any other file functions. To unregister a work area, specify a NULL to the <tt class="arg">fatfs</tt>, and then the work area can be discarded. </p> <p>The file system object is the work area needed for each logical drive. It must be given to the logical drive with this function prior to use any other file functions except for <tt>f_fdisk</tt> function to the logical drive. To unregister the work area, specify a NULL to the <tt class="arg">fs</tt>, and then the work area can be discarded.</p>
<p>If forced mount is not specified, this function always succeeds regardless of the physical drive status due to delayed mount feature. It only clears (de-initializes) the given work area and registers its address to the internal table. No activity of the physical drive in this function. It can also be used to force de-initialized the registered work area of a logical drive. The volume mount processes, initialize the corresponding physical drive, find the FAT volume in it and initialize the work area, is performed in the subsequent file access functions when either or both of following condition is true.</p> <p>If forced mounting is not specified, this function always succeeds regardless of the physical drive status due to delayed mount feature. It only clears (de-initializes) the given work area and registers its address to the internal table. There is no activity of the physical drive in this function. It can also be used to force de-initialized the registered work area of a logical drive. The volume mount processes, initialize the corresponding physical drive, find the FAT volume in it and initialize the work area, is performed in the subsequent file access functions when either or both of following condition is true.</p>
<ul> <ul>
<li>File system object is not initialized. It is cleared by <tt>f_mount()</tt>.</li> <li>File system object is not initialized. It is de-initialized by <tt>f_mount</tt> function.</li>
<li>Physical drive is not initialized. It is de-initialized by system reset or media change.</li> <li>Physical drive is not initialized. It is de-initialized by system reset or media removal.</li>
</ul> </ul>
<p>If the function with forced mount failed, it means that the file system object is registered but the volume is currently not available. Mount process will also be attempted in subsequent file access functions.</p> <p>If the function with forced mounting failed, it means that the file system object has been registered successfully but the volume is currently not ready to work. The volume mount process will also be attempted at subsequent file access functions.</p>
<p>If implementation of the disk I/O layer lacks media change detection, application program needs to perform a <tt>f_mount()</tt> after media change to force cleared the file system object.</p> <p>If implementation of the disk I/O layer lacks media change detection, application program needs to perform a <tt>f_mount</tt> function after each media change to force cleared the file system object.</p>
</div> </div>
+13 -13
View File
@@ -27,18 +27,18 @@ FRESULT f_open (
<h4>Parameters</h4> <h4>Parameters</h4>
<dl class="par"> <dl class="par">
<dt>fp</dt> <dt>fp</dt>
<dd>Pointer to the blank file object structure to be created.</dd> <dd>Pointer to the blank file object structure.</dd>
<dt>path</dt> <dt>path</dt>
<dd>Pointer to a null-terminated string that specifies the <a href="filename.html">file name</a> to create or open.</dd> <dd>Pointer to the null-terminated string that specifies the <a href="filename.html">file name</a> to open or create.</dd>
<dt>mode</dt> <dt>mode</dt>
<dd>Mode flags that specifies the type of access and open method for the file. It is specified by a combination of following flags.<br> <dd>Mode flags that specifies the type of access and open method for the file. It is specified by a combination of following flags.<br>
<table class="lst"> <table class="lst">
<tr><th>Value</th><th>Description</th></tr> <tr><th>Value</th><th>Description</th></tr>
<tr><td>FA_READ</td><td>Specifies read access to the object. Data can be read from the file. Combine with <tt>FA_WRITE</tt> 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.</tr>
<tr><td>FA_WRITE</td><td>Specifies write access to the object. Data can be written to the file. Combine with <tt>FA_READ</tt> 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. Combine with <tt>FA_READ</tt> 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.<br> <tr><td>FA_OPEN_ALWAYS</td><td>Opens the file if it is existing. If not, a new file will be created.<br>
To append data to the file, use <a href="lseek.html"><tt>f_lseek()</tt></a> function after file open in this method.</td></tr> To append data to the file, use <a href="lseek.html"><tt>f_lseek</tt></a> function after the file open in this method.</td></tr>
<tr><td>FA_CREATE_NEW</td><td>Creates a new file. The function fails with <tt>FR_EXIST</tt> if the file is existing.</td></tr> <tr><td>FA_CREATE_NEW</td><td>Creates a new file. The function fails with <tt>FR_EXIST</tt> if the file is existing.</td></tr>
<tr><td>FA_CREATE_ALWAYS</td><td>Creates a new file. If the file is existing, it will be truncated and overwritten.</td></tr> <tr><td>FA_CREATE_ALWAYS</td><td>Creates a new file. If the file is existing, it will be truncated and overwritten.</td></tr>
</table> </table>
@@ -74,9 +74,9 @@ To append data to the file, use <a href="lseek.html"><tt>f_lseek()</tt></a> func
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>After <tt>f_open()</tt> function succeeded, the file object is valid. The file object is used for subsequent read/write functions to identify the file. To close an open file, use <a href="close.html"><tt>f_close()</tt></a> function. If the file is modified and not closed properly, the file data will be collapted.</p> <p>Before using any file function, a work area (file system object) must be registered to the logical drive with <a href="mount.html"><tt>f_mount</tt></a> function. All API functions except for <a href="fdisk.html"><tt>f_fdisk</tt></a> function can work after this procedure.</p>
<p>If duplicated file open is needed, read <a href="appnote.html#dup">here</a> carefully. However duplicated open of a file with write mode flag is always prohibited.</p> <p>After <tt>f_open</tt> function succeeded, the file object is valid. The file object is used for subsequent operations to the file to identify the file. Open file must be closed prior to power down, media removal or re-mount, or the file can be collapsed. To close an open file, use <a href="close.html"><tt>f_close</tt></a> function.</p>
<p>Before using any file function, a work area (file system object) must be registered to the logical drive with <a href="mount.html"><tt>f_mount()</tt></a> function. All API functions except for <a href="fdisk.html"><tt>f_fdisk()</tt></a> function can work after this procedure.</p> <p>If duplicated file open is needed, read <a href="appnote.html#dup">here</a> carefully. However duplicated open of a file with any write mode flag is always prohibited.</p>
</div> </div>
@@ -104,15 +104,15 @@ int main (void)
f_mount(&amp;FatFs, "", 0); f_mount(&amp;FatFs, "", 0);
<span class="c">/* Open a text file */</span> <span class="c">/* Open a text file */</span>
fr = f_open(&fil, "message.txt", FA_READ); fr = f_open(&amp;fil, "message.txt", FA_READ);
if (fr) return (int)fr; if (fr) return (int)fr;
<span class="c">/* Read all lines and display it */</span> <span class="c">/* Read all lines and display it */</span>
while (f_gets(line, sizeof line, &fil)) while (f_gets(line, sizeof line, &amp;fil))
printf(line); printf(line);
<span class="c">/* Close the file */</span> <span class="c">/* Close the file */</span>
f_close(&fil); f_close(&amp;fil);
return 0; return 0;
} }
@@ -134,11 +134,11 @@ int main (void)
f_mount(&amp;fs[1], "1:", 0); f_mount(&amp;fs[1], "1:", 0);
<span class="c">/* Open source file on the drive 1 */</span> <span class="c">/* Open source file on the drive 1 */</span>
fr = f_open(&amp;fsrc, "1:file.bin", FA_OPEN_EXISTING | FA_READ); fr = f_open(&amp;fsrc, "1:file.bin", FA_READ);
if (fr) return (int)fr; if (fr) return (int)fr;
<span class="c">/* Create destination file on the drive 0 */</span> <span class="c">/* Create destination file on the drive 0 */</span>
fr = f_open(&amp;fdst, "0:file.bin", FA_CREATE_ALWAYS | FA_WRITE); fr = f_open(&amp;fdst, "0:file.bin", FA_WRITE | FA_CREATE_ALWAYS);
if (fr) return (int)fr; if (fr) return (int)fr;
<span class="c">/* Copy source to destination */</span> <span class="c">/* Copy source to destination */</span>
+2 -2
View File
@@ -28,7 +28,7 @@ FRESULT f_opendir (
<dt>dp</dt> <dt>dp</dt>
<dd>Pointer to the blank directory object to create a new one.</dd> <dd>Pointer to the blank directory object to create a new one.</dd>
<dt>path</dt> <dt>path</dt>
<dd>Pinter to the null-terminated string that specifies the <a href="filename.html">directory name</a> to be opened.</dd> <dd>Pointer to the null-terminated string that specifies the <a href="filename.html">directory name</a> to be opened.</dd>
</dl> </dl>
</div> </div>
@@ -55,7 +55,7 @@ FRESULT f_opendir (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_opendir()</tt> function opens an exsisting directory and creates the directory object for subsequent calls.</p> <p>The <tt>f_opendir</tt> function opens an exsisting directory and creates a directory object for subsequent <tt>f_readdir</tt> function.</p>
</div> </div>
+13 -10
View File
@@ -29,9 +29,9 @@ int f_printf (
<dt>fp</dt> <dt>fp</dt>
<dd>Pointer to the open file object structure.</dd> <dd>Pointer to the open file object structure.</dd>
<dt>fmt</dt> <dt>fmt</dt>
<dd>Pointer to the null terminated format string.</dd> <dd>Pointer to the null terminated format string. The terminator charactor will not be written.</dd>
<dt>...</dt> <dt>...</dt>
<dd>Optional arguments.</dd> <dd>Optional arguments...</dd>
</dl> </dl>
</div> </div>
@@ -45,7 +45,7 @@ int f_printf (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_printf()</tt> is a wrapper function of <a href="write.html"><tt>f_write()</tt></a>. The format control directive is a sub-set of standard library shown as follos:</p> <p>The format control directive is a sub-set of standard library shown as follos:</p>
<ul> <ul>
<li>Type: <tt>c C s S d D u U x X b B</tt></li> <li>Type: <tt>c C s S d D u U x X b B</tt></li>
<li>Size: <tt>l L</tt></li> <li>Size: <tt>l L</tt></li>
@@ -56,8 +56,8 @@ int f_printf (
<div class="para comp"> <div class="para comp">
<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>This is a wrapper function of <a href="write.html"><tt>f_write</tt></a> function. 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 FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), data types on the srting fuctions, <tt>f_putc()</tt>, <tt>f_puts()</tt>, <tt>f_printf()</tt> and <tt>f_gets()</tt>, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by <tt>_STRF_ENCODE</tt> option.</p> <p>When FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), data types on the srting fuctions, <tt>f_putc</tt>, <tt>f_puts</tt>, <tt>f_printf</tt> and <tt>f_gets</tt> function, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by <tt>_STRF_ENCODE</tt> option.</p>
</div> </div>
@@ -66,14 +66,17 @@ int f_printf (
<pre> <pre>
f_printf(&amp;fil, "%d", 1234); <span class="c">/* "1234" */</span> f_printf(&amp;fil, "%d", 1234); <span class="c">/* "1234" */</span>
f_printf(&amp;fil, "%6d,%3d%%", -200, 5); <span class="c">/* " -200, 5%" */</span> f_printf(&amp;fil, "%6d,%3d%%", -200, 5); <span class="c">/* " -200, 5%" */</span>
f_printf(&amp;fil, "%-6u", 100); <span class="c">/* "100 " */</span> f_printf(&amp;fil, "%ld", 12345L); <span class="c">/* "12345" */</span>
f_printf(&amp;fil, "%ld", 12345678L); <span class="c">/* "12345678" */</span> f_printf(&amp;fil, "%06d", 25); <span class="c">/* "000025" */</span>
f_printf(&amp;fil, "%04x", 0xAB); <span class="c">/* "00ab" */</span> f_printf(&amp;fil, "%06d", -25); <span class="c">/* "000-25" */</span>
f_printf(&amp;fil, "%-6d", 25); <span class="c">/* "25 " */</span>
f_printf(&amp;fil, "%u", -1); <span class="c">/* "65535" or "4294967295" */</span>
f_printf(&amp;fil, "%04x", 0xAB3); <span class="c">/* "0ab3" */</span>
f_printf(&amp;fil, "%08LX", 0x123ABCL); <span class="c">/* "00123ABC" */</span> f_printf(&amp;fil, "%08LX", 0x123ABCL); <span class="c">/* "00123ABC" */</span>
f_printf(&amp;fil, "%016b", 0x550F); <span class="c">/* "0101010100001111" */</span> f_printf(&amp;fil, "%016b", 0x550F); <span class="c">/* "0101010100001111" */</span>
f_printf(&amp;fil, "%s", "String"); <span class="c">/* "String" */</span> f_printf(&amp;fil, "%s", "String"); <span class="c">/* "String" */</span>
f_printf(&amp;fil, "%5s", "abc"); <span class="c">/* " abc" */</span> f_printf(&amp;fil, "%8s", "abc"); <span class="c">/* " abc" */</span>
f_printf(&amp;fil, "%-5s", "abc"); <span class="c">/* "abc " */</span> f_printf(&amp;fil, "%-8s", "abc"); <span class="c">/* "abc " */</span>
f_printf(&amp;fil, "%c", 'a'); <span class="c">/* "a" */</span> f_printf(&amp;fil, "%c", 'a'); <span class="c">/* "a" */</span>
f_printf(&amp;fil, "%f", 10.0); <span class="c">/* f_printf lacks floating point support */</span> f_printf(&amp;fil, "%f", 10.0); <span class="c">/* f_printf lacks floating point support */</span>
</pre> </pre>
+2 -8
View File
@@ -36,19 +36,13 @@ int f_putc (
<div class="para ret"> <div class="para ret">
<h4>Return Values</h4> <h4>Return Values</h4>
<p>When the character was written successfuly, it returns number of characters written. When the function failed due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p> <p>When the character was written successfuly, it returns number of characters written. When the function failed due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
<p>When FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), character encoding on the string fuctions, <tt>f_putc()</tt>, <tt>f_puts()</tt>, <tt>f_printf()</tt> and <tt>f_gets()</tt>, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by <tt>_STRF_ENCODE</tt> option.</p> <p>When FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), character encoding on the string fuctions, <tt>f_putc</tt>, <tt>f_puts</tt>, <tt>f_printf</tt> and <tt>f_gets</tt> function, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by <tt>_STRF_ENCODE</tt> option.</p>
</div>
<div class="para desc">
<h4>Description</h4>
<p>The <tt>f_putc()</tt> function is a wrapper function of <a href="write.html"><tt>f_write()</tt></a> function.</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<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, a <tt>'\n'</tt> is converted to <tt>"\r\n"</tt>.</p> <p>This is a wrapper function of <a href="write.html"><tt>f_write</tt></a> function. Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, a <tt>'\n'</tt> is converted to <tt>'\r'+'\n'</tt>.</p>
</div> </div>
+3 -9
View File
@@ -26,7 +26,7 @@ int f_puts (
<h4>Parameters</h4> <h4>Parameters</h4>
<dl class="par"> <dl class="par">
<dt>str</dt> <dt>str</dt>
<dd>Pointer to the null terminated string to be written. The null character will not be written.</dd> <dd>Pointer to the null terminated string to be written. The terminator character will not be written.</dd>
<dt>fp</dt> <dt>fp</dt>
<dd>Pointer to the open file object structure.</dd> <dd>Pointer to the open file object structure.</dd>
</dl> </dl>
@@ -36,19 +36,13 @@ int f_puts (
<div class="para ret"> <div class="para ret">
<h4>Return Value</h4> <h4>Return Value</h4>
<p>When the function succeeded, it returns number of characters written. When the write operation is aborted due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p> <p>When the function succeeded, it returns number of characters written. When the write operation is aborted due to disk full or any error, an <tt>EOF (-1)</tt> will be returned.</p>
<p>When FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), character encoding on the srting fuctions, <tt>f_putc()</tt>, <tt>f_puts()</tt>, <tt>f_printf()</tt> and <tt>f_gets()</tt>, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by <tt>_STRF_ENCODE</tt> option.</p> <p>When FatFs is configured to Unicode API (<tt>_LFN_UNICODE == 1</tt>), character encoding on the srting fuctions, <tt>f_putc</tt>, <tt>f_puts</tt>, <tt>f_printf</tt> and <tt>f_gets</tt> function, is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by <tt>_STRF_ENCODE</tt> option.</p>
</div>
<div class="para desc">
<h4>Description</h4>
<p>The <tt>f_puts()</tt> function is a wrapper function of <a href="write.html"><tt>f_write()</tt></a> function.</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<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 string are converted to <tt>"\r\n"</tt>.</p> <p>This is a wrapper function of <a href="write.html"><tt>f_write</tt></a> function. Available when <tt>_FS_READONLY == 0</tt> and <tt>_USE_STRFUNC</tt> is 1 or 2. When it is set to 2, <tt>'\n'</tt>s contained in the string are converted to <tt>'\r'+'\n'</tt>.</p>
</div> </div>
+44 -17
View File
@@ -14,26 +14,34 @@
<p>On the FatFs API, most of file functions return common result code as enum type <tt>FRESULT</tt>. When a function succeeded, it returns zero, otherwise returns non-zero value that indicates type of error.</p> <p>On the FatFs API, most of file functions return common result code as enum type <tt>FRESULT</tt>. When a function succeeded, it returns zero, otherwise returns non-zero value that indicates type of error.</p>
<dl class="ret"> <dl class="ret">
<dt id="ok">FR_OK (0)</dt> <dt id="ok">FR_OK (0)</dt>
<dd>The function succeeded.</dd> <dd>The function succeeded.</dd>
<dt id="de">FR_DISK_ERR</dt> <dt id="de">FR_DISK_ERR</dt>
<dd>An unrecoverable hard error occured in the lower layer, <tt>disk_read()</tt>, <tt>disk_write()</tt> or <tt>disk_ioctl()</tt> function.</dd> <dd>An unrecoverable hard error occured in the lower layer, <tt>disk_read</tt>, <tt>disk_write</tt> or <tt>disk_ioctl</tt> function.<br>Note that if once this error occured at any operation to an open file, the file object is aborted and all operations to the file except for close will be rejected.</dd>
<dt id="ie">FR_INT_ERR</dt> <dt id="ie">FR_INT_ERR</dt>
<dd>Assertion failed. An insanity is detected in the internal process. One of the following possibilities are suspected. <dd>Assertion failed. An insanity is detected in the internal process. One of the following possibilities is suspected.
<ul> <ul>
<li>Work area (file system object, file object or etc...) has been broken by stack overflow or any other tasks. This is the reason in most case.</li>
<li>There is any error of the FAT structure on the volume.</li> <li>There is any error of the FAT structure on the volume.</li>
<li>Work area (file system object, file object or etc...) is broken by stack overflow or any other application. This is the reason in most case.</li>
<li>An <tt>FR_DISK_ERR</tt> has occured on the file object.</li>
</ul> </ul>
Note that if once this error occured at any operation to an open file, the file object is aborted and all operations to the file except for close will be rejected.
</dd> </dd>
<dt id="nr">FR_NOT_READY</dt> <dt id="nr">FR_NOT_READY</dt>
<dd>The disk drive cannot work due to incorrect medium removal or <tt>disk_initialize()</tt> function failed.</dd> <dd>The storage device cannot work due to a failure of <a href="dinit.html"><tt>disk_initialize</tt></a> function due to no medium or any other reason.</dd>
<dt id="nf">FR_NO_FILE</dt> <dt id="nf">FR_NO_FILE</dt>
<dd>Could not find the file.</dd> <dd>Could not find the file.</dd>
<dt id="np">FR_NO_PATH</dt> <dt id="np">FR_NO_PATH</dt>
<dd>Could not find the path.</dd> <dd>Could not find the path.</dd>
<dt id="in">FR_INVALID_NAME</dt> <dt id="in">FR_INVALID_NAME</dt>
<dd>The given string is invalid as the <a href="filename.html">path name</a>.</dd> <dd>The given string is invalid as the <a href="filename.html">path name</a>.</dd>
<dt id="dn">FR_DENIED</dt> <dt id="dn">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> <ul>
@@ -43,45 +51,64 @@
<li>Reading the file opened without <tt>FA_READ</tt> flag.</li> <li>Reading the file opened without <tt>FA_READ</tt> flag.</li>
<li>Any modification to the file opened without <tt>FA_WRITE</tt> flag.</li> <li>Any modification to the file opened without <tt>FA_WRITE</tt> flag.</li>
<li>Could not create the file or directory due to the directory table is full.</li> <li>Could not create the file or directory due to the directory table is full.</li>
<li>Could not create the directory due to the volume is full.</li> <li>Could not allocate a contiguous area to the file.</li>
</ul> </ul>
</dd> </dd>
<dt id="ex">FR_EXIST</dt> <dt id="ex">FR_EXIST</dt>
<dd>Name collision. Any object that has the same name is already existing.</dd> <dd>Name collision. Any object that has the same name is already existing.</dd>
<dt id="io">FR_INVALID_OBJECT</dt> <dt id="io">FR_INVALID_OBJECT</dt>
<dd>The file/directory object structure is invalid or a null pointer is given. All open objects of the logical drive are invalidated by the voulme mount process.</dd> <dd>The file/directory object is invalid or a null pointer is given. There are some reasons as follows:
<ul>
<li>It has been closed, it is not opened or it can be collapsed.</li>
<li>It has been invalidated by a voulme mount process. All open objects of the volume are invalidated as well.</li>
<li>The corresponding physical drive is not ready due to a media removal.</li>
</ul>
</dd>
<dt id="wp">FR_WRITE_PROTECTED</dt> <dt id="wp">FR_WRITE_PROTECTED</dt>
<dd>Any write mode action against the write-protected media.</dd> <dd>Any write mode operation against the write-protected media.</dd>
<dt id="id">FR_INVALID_DRIVE</dt> <dt id="id">FR_INVALID_DRIVE</dt>
<dd>Invalid drive number is specified in the path name. A null pointer is given as the path name. (Related option: <tt>_VOLUMES</tt>)</dd> <dd>Invalid drive number is specified in the path name. A null pointer is given as the path name. (Related option: <tt><a href="config.html#volumes">_VOLUMES</a></tt>)</dd>
<dt id="ne">FR_NOT_ENABLED</dt> <dt id="ne">FR_NOT_ENABLED</dt>
<dd>Work area for the logical drive has not been registered by <tt>f_mount()</tt> function.</dd> <dd>Work area for the logical drive has not been registered by <tt>f_mount</tt> function.</dd>
<dt id="ns">FR_NO_FILESYSTEM</dt> <dt id="ns">FR_NO_FILESYSTEM</dt>
<dd>There is no valid FAT volume on the drive.</dd> <dd>There is no valid FAT volume on the drive.</dd>
<dt id="ma">FR_MKFS_ABORTED</dt> <dt id="ma">FR_MKFS_ABORTED</dt>
<dd>The <tt>f_mkfs()</tt> function aborted before start in format due to a reason as follows: <dd>The <tt>f_mkfs</tt> function aborted before start in format due to a reason as follows:
<ul> <ul>
<li>The disk/partition size is too small.</li> <li>The disk/partition size is too small.</li>
<li>Not allowable cluster size for this disk. This can occure when number of clusters gets near the boundaries of FAT sub-types.</li> <li>Not allowable cluster size for this disk. This can occure when number of clusters gets near the boundaries of FAT sub-types.</li>
<li>There is no partition related to the logical drive. (Related option: <tt>_MULTI_PARTITION</tt>)</li> <li>There is no partition related to the logical drive. (Related option: <tt><a href="config.html#multi_partition">_MULTI_PARTITION</a></tt>)</li>
</ul> </ul>
</dd> </dd>
<dt id="tm">FR_TIMEOUT</dt> <dt id="tm">FR_TIMEOUT</dt>
<dd>The function was canceled due to a timeout of <a href="appnote.html#reentrant">thread-safe control</a>. (Related option: <tt>_TIMEOUT</tt>)</dd> <dd>The function was canceled due to a timeout of <a href="appnote.html#reentrant">thread-safe control</a>. (Related option: <tt><a href="config.html#timeout">_TIMEOUT</a></tt>)</dd>
<dt id="lo">FR_LOCKED</dt> <dt id="lo">FR_LOCKED</dt>
<dd>The function was rejected by <a href="appnote.html#dup">file sharing control</a>. (Related option: <tt>_FS_LOCK</tt>)</dd> <dd>The operation to the object was rejected by <a href="appnote.html#dup">file sharing control</a>. (Related option: <tt><a href="config.html#fs_lock">_FS_LOCK</a></tt>)</dd>
<dt id="nc">FR_NOT_ENOUGH_CORE</dt> <dt id="nc">FR_NOT_ENOUGH_CORE</dt>
<dd>Not enough memory for the operation. There is one of the following reasons: <dd>Not enough memory for the operation. There is one of the following reasons:
<ul> <ul>
<li>Could not allocate a memory for LFN working buffer. (Related option: <tt>_USE_LFN</tt>)</li> <li>Could not allocate a memory for LFN working buffer. (Related option: <tt><a href="config.html#use_lfn">_USE_LFN</a></tt>)</li>
<li>Size of the given CLMT buffer is insufficient for the file fragments.</li> <li>Size of the given buffer is insufficient for the size required.</li>
</ul> </ul>
</dd> </dd>
<dt id="tf">FR_TOO_MANY_OPEN_FILES</dt> <dt id="tf">FR_TOO_MANY_OPEN_FILES</dt>
<dd>Number of open objects has been reached maximum value and no more object can be opened. (Related option: <tt>_FS_LOCK</tt>)</dd> <dd>Number of open objects has been reached maximum value and no more object can be opened. (Related option: <tt><a href="config.html#fs_lock">_FS_LOCK</a></tt>)</dd>
<dt id="ip">FR_INVALID_PARAMETER</dt> <dt id="ip">FR_INVALID_PARAMETER</dt>
<dd>The given parameter is invalid or there is any inconsistent.</dd> <dd>The given parameter is invalid or there is any inconsistent.</dd>
</dl> </dl>
<p class="foot"><a href="../00index_e.html">Return</a></p>
</body> </body>
</html> </html>
+2 -3
View File
@@ -34,7 +34,7 @@ FRESULT f_read (
<dt>btr</dt> <dt>btr</dt>
<dd>Number of bytes to read in range of <tt>UINT</tt> type.</dd> <dd>Number of bytes to read in range of <tt>UINT</tt> type.</dd>
<dt>br</dt> <dt>br</dt>
<dd>Pointer to the <tt>UINT</tt> variable to return number of bytes read. The value is always valid after the function call regardless of the result.</dd> <dd>Pointer to the <tt>UINT</tt> variable to return number of bytes read. The value is always valid after the function call regardless of the result code.</dd>
</dl> </dl>
</div> </div>
@@ -45,7 +45,6 @@ FRESULT f_read (
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>, <a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>, <a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#tm">FR_TIMEOUT</a> <a href="rc.html#tm">FR_TIMEOUT</a>
</p> </p>
@@ -54,7 +53,7 @@ FRESULT f_read (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The file read/write pointer of the file object advances number of bytes read. After the function succeeded, <tt class="arg">*br</tt> should be checked to detect the end of file. In case of <tt class="arg">*br</tt> is less than <tt class="arg">btr</tt>, it means the read/write pointer reached end of the file during read operation.</p> <p>The function starts to read data from the file at the position pointed by the read/write pointer. The read/write pointer advances as number of bytes read. After the function succeeded, <tt class="arg">*br</tt> should be checked to detect end of the file. In case of <tt class="arg">*br</tt> is less than <tt class="arg">btr</tt>, it means the read/write pointer reached end of the file during read operation.</p>
</div> </div>
+32 -29
View File
@@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>f_readdir</h2> <h2>f_readdir</h2>
<p>The f_readdir function reads directory entries.</p> <p>The f_readdir function reads an item of the directory.</p>
<pre> <pre>
FRESULT f_readdir ( FRESULT f_readdir (
DIR* <span class="arg">dp</span>, <span class="c">/* [IN] Directory object */</span> DIR* <span class="arg">dp</span>, <span class="c">/* [IN] Directory object */</span>
@@ -26,9 +26,9 @@ FRESULT f_readdir (
<h4>Parameters</h4> <h4>Parameters</h4>
<dl class="par"> <dl class="par">
<dt>dp</dt> <dt>dp</dt>
<dd>Pointer to the open directory object.</dd> <dd>Pointer to the open directory object or null pointer.</dd>
<dt>fno</dt> <dt>fno</dt>
<dd>Pointer to the file information structure to store the read item.</dd> <dd>Pointer to the <a href="sfileinfo.html">file information structure</a> to store the information about read item.</dd>
</dl> </dl>
</div> </div>
@@ -39,7 +39,6 @@ FRESULT f_readdir (
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>, <a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>, <a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#tm">FR_TIMEOUT</a>, <a href="rc.html#tm">FR_TIMEOUT</a>,
<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a> <a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
@@ -49,14 +48,14 @@ FRESULT f_readdir (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_readdir()</tt> function reads directory items, file and directory, in sequence. All items in the directory can be read by calling <tt>f_readdir()</tt> function repeatedly. When relative path feature is enabled (<tt>_FS_RPATH &gt;= 1</tt>), dot entries ("." and "..") are not filtered out and they will appear in the read items. When all directory items have been read and no item to read, a null string is returned into the <tt>fname[]</tt> without any error. When a null pointer is given to the <tt class="arg">fno</tt>, the read index of the directory object is rewinded.</p> <p>The <tt>f_readdir</tt> function reads a directory item, informations about the object. All items in the directory can be read in sequence by <tt>f_readdir</tt> function calls. Dot entries (<tt>"."</tt> and <tt>".."</tt>) in the sub-directory are filtered out and they will never appear in the read items. When all directory items have been read and no item to read, a nul string is stored into the <tt>fno-&gt;fname[]</tt> without any error. When a null pointer is given to the <tt class="arg">fno</tt>, the read index of the directory object is rewinded.</p>
<p>When LFN feature is enabled, <tt>lfname</tt> and <tt>lfsize</tt> in the file information structure must be initialized with valid value prior to use it. The <tt>lfname</tt> is a pointer to the LFN read buffer. The <tt>lfsize</tt> is size of the LFN read buffer in unit of <tt>TCHAR</tt>. If the LFN is not needed, set a null pointer to the <tt>lfname</tt> and the LFN is not returned. A null string will be returned into the LFN read buffer in case of following conditions.</p> <p>When support of long file name (LFN) is enabled, a member <tt>altname[]</tt> is defined in the file information structure to store the short file name of the object. In case of any condition listed below, short file name is stored into the <tt>fname[]</tt> and <tt>altname[]</tt> has a null string.</p>
<ul> <ul>
<li>The directory item has no LFN information.</li> <li>The item has no long file name. (Not the case at exFAT volume)</li>
<li>Either the size of read buffer or LFN working buffer is insufficient for the LFN.</li> <li>Setting of <tt>_MAX_LFN</tt> is insufficient for the long file name. (Not the case at <tt>_MAX_LFN == 255</tt>)</li>
<li>The LFN contains any Unicode charactrer that cannot be converted to OEM code. (not the case at Unicode API cfg.)</li> <li>The long file name contains any character not allowed in ANSI/OEM code. (Not the case at <tt>_LFN_UNICODE == 1</tt>)</li>
</ul> </ul>
<p>When the directory item has no LFN information, lower case characters can be contained in the <tt>fname[]</tt>.</p> <p>There is a problem on reading directory of exFAT volume. The exFAT does not support short file name. This means no name can be returned on the condition avobe. If it is the case, a "?" is returned as file name to indicate that the object is not accessible. To avoid this problem, configure FatFs <tt>_LFN_UNICODE = 1</tt> and <tt>_MAX_LFN = 255</tt> to support the full feature of LFN specification.</p>
</div> </div>
@@ -70,40 +69,27 @@ FRESULT f_readdir (
<h4>Sample Code</h4> <h4>Sample Code</h4>
<pre> <pre>
FRESULT scan_files ( FRESULT scan_files (
char* path <span class="c">/* Start node to be scanned (also used as work area) */</span> char* path <span class="c">/* Start node to be scanned (***also used as work area***) */</span>
) )
{ {
FRESULT res; FRESULT res;
FILINFO fno;
DIR dir; DIR dir;
int i; UINT i;
char *fn; <span class="c">/* This function is assuming non-Unicode cfg. */</span> static FILINFO fno;
<span class="k">#if</span> _USE_LFN
static char lfn[_MAX_LFN + 1]; <span class="c">/* Buffer to store the LFN */</span>
fno.lfname = lfn;
fno.lfsize = sizeof lfn;
<span class="k">#endif</span>
res = f_opendir(&amp;dir, path); <span class="c">/* Open the directory */</span> res = f_opendir(&amp;dir, path); <span class="c">/* Open the directory */</span>
if (res == FR_OK) { if (res == FR_OK) {
i = strlen(path);
for (;;) { for (;;) {
res = f_readdir(&amp;dir, &amp;fno); <span class="c">/* Read a directory item */</span> res = f_readdir(&amp;dir, &amp;fno); <span class="c">/* Read a directory item */</span>
if (res != FR_OK || fno.fname[0] == 0) break; <span class="c">/* Break on error or end of dir */</span> if (res != FR_OK || fno.fname[0] == 0) break; <span class="c">/* Break on error or end of dir */</span>
if (fno.fname[0] == '.') continue; <span class="c">/* Ignore dot entry */</span>
<span class="k">#if</span> _USE_LFN
fn = *fno.lfname ? fno.lfname : fno.fname;
<span class="k">#else</span>
fn = fno.fname;
<span class="k">#endif</span>
if (fno.fattrib &amp; AM_DIR) { <span class="c">/* It is a directory */</span> if (fno.fattrib &amp; AM_DIR) { <span class="c">/* It is a directory */</span>
sprintf(&amp;path[i], "/%s", fn); sprintf(&amp;path[i = strlen(path)], "/%s", fno.fname);
res = scan_files(path); res = scan_files(path); <span class="c">/* Enter the directory */</span>
if (res != FR_OK) break; if (res != FR_OK) break;
path[i] = 0; path[i] = 0;
} else { <span class="c">/* It is a file. */</span> } else { <span class="c">/* It is a file. */</span>
printf("%s/%s\n", path, fn); printf("%s/%s\n", path, fno.fname);
} }
} }
f_closedir(&amp;dir) f_closedir(&amp;dir)
@@ -111,6 +97,23 @@ FRESULT scan_files (
return res; return res;
} }
int main (void)
{
FATFS fs;
FRESULT res;
char buff[256];
res = f_mount(&fs, "", 1);
if (res == FR_OK) {
strcpy(buff, "/");
res = scan_files(buff);
}
return res;
}
</pre> </pre>
</div> </div>
+9 -6
View File
@@ -26,9 +26,9 @@ FRESULT f_rename (
<h4>Parameters</h4> <h4>Parameters</h4>
<dl class="par"> <dl class="par">
<dt>old_name</dt> <dt>old_name</dt>
<dd>Pointer to a null-terminated string that specifies an existing <a href="filename.html">file or sub-directory</a> to be renamed.</dd> <dd>Pointer to a null-terminated string that specifies the existing <a href="filename.html">file or sub-directory</a> to be renamed.</dd>
<dt>new_name</dt> <dt>new_name</dt>
<dd>Pointer to a null-terminated string that specifies the new object name. The drive number specified in this string is ignored and one determined by <tt class="arg">old_name</tt> is used instead.</dd> <dd>Pointer to a null-terminated string that specifies the new object name. Any drive number may be specified in this string but it is ignored and assumed as the same drive of the <tt class="arg">old_name</tt>.</dd>
</dl> </dl>
</div> </div>
@@ -58,7 +58,7 @@ FRESULT f_rename (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>Renames a file or sub-directory and can also move it to other directory within the same logical drive. <em>Do not rename open objects</em> or directry table can be collapted.</p> <p>Renames a file or sub-directory and can also move it to other directory in the same logical drive. The object to be renamed must not be an open object, or <em>the FAT volume can be collapsed</em>. Such the wrong operation can be rejected safely when <a href="appnote.html#dup">file lock feature</a> is enabled.</p>
</div> </div>
@@ -71,11 +71,14 @@ FRESULT f_rename (
<div class="para use"> <div class="para use">
<h4>Example</h4> <h4>Example</h4>
<pre> <pre>
<span class="c">/* Rename an object */</span> <span class="c">/* Rename an object in the default drive */</span>
f_rename("oldname.txt", "newname.txt"); f_rename("oldname.txt", "newname.txt");
<span class="c">/* Rename and move an object to other directory */</span> <span class="c">/* Rename an object in the drive 2 */</span>
f_rename("oldname.txt", "dir1/newname.txt"); f_rename("2:oldname.txt", "newname.txt");
<span class="c">/* Rename an object and move it to other directory */</span>
f_rename("log.txt", "old/log0001.txt");
</pre> </pre>
</div> </div>
+9 -11
View File
@@ -13,23 +13,21 @@
<div class="para"> <div class="para">
<h2>DIR</h2> <h2>DIR</h2>
<p>The <tt>DIR</tt> structure is used for the work area to read a directory by <tt>f_oepndir()/f_readdir()</tt> function. Application program must not modify any member in this structure.</p> <p>The <tt>DIR</tt> structure is used for the work area to read a directory by <tt>f_oepndir</tt>, <tt>f_readdir</tt>, <tt>f_findfirst</tt> and <tt>f_findnext</tt> function. Application program must not modify any member in this structure, or any data on the FAT volume can be collapsed.</p>
<pre> <pre>
<span class="k">typedef</span> <span class="k">struct</span> { <span class="k">typedef</span> <span class="k">struct</span> {
FATFS* fs; <span class="c">/* Pointer to the owner file system object */</span> _FDID obj; <span class="c">/* Owner file sytem object and object identifier */</span>
WORD id; <span class="c">/* Owner file system mount ID */</span> DWORD dptr; <span class="c">/* Current read/write offset */</span>
WORD index; <span class="c">/* Index of directory entry to start to search next */</span>
DWORD sclust; <span class="c">/* Table start cluster (0:Root directory) */</span>
DWORD clust; <span class="c">/* Current cluster */</span> DWORD clust; <span class="c">/* Current cluster */</span>
DWORD sect; <span class="c">/* Current sector */</span> DWORD sect; <span class="c">/* Current sector */</span>
BYTE* dir; <span class="c">/* Pointer to the current SFN entry in the win[] */</span> BYTE* dir; <span class="c">/* Pointer to the current SFN entry in the win[] */</span>
BYTE* fn; <span class="c">/* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */</span> BYTE* fn; <span class="c">/* Pointer to the SFN buffer (in/out) {file[8],ext[3],status[1]} */</span>
<span class="k">#if</span> _FS_LOCK
UINT lockid; <span class="c">/* Sub-directory lock ID (0:Root directory) */</span>
<span class="k">#endif</span>
<span class="k">#if</span> _USE_LFN <span class="k">#if</span> _USE_LFN
WCHAR* lfn; <span class="c">/* Pointer to the LFN working buffer */</span> DWORD blk_ofs; <span class="c">/* Offset of the entry block (0xFFFFFFFF:Invalid) */</span>
WORD lfn_idx; <span class="c">/* Index of top of last matched LFN entris (0xFFFF:No LFN) */</span> WCHAR* lfn; <span class="c">/* Pointer to the LFN working buffer (in/out) */</span>
<span class="k">#endif</span>
<span class="k">#if</span> _USE_FIND
const TCHAR* pat; <span class="c">/* Ponter to the matching pattern */</span>
<span class="k">#endif</span> <span class="k">#endif</span>
} DIR; } DIR;
</pre> </pre>
+8 -6
View File
@@ -16,7 +16,7 @@
<p>The f_setlabel function sets/removes the label of a volume.</p> <p>The f_setlabel function sets/removes the label of a volume.</p>
<pre> <pre>
FRESULT f_setlabel ( FRESULT f_setlabel (
const TCHAR* <span class="arg">name</span> <span class="c">/* [IN] Volume label to be set */</span> const TCHAR* <span class="arg">label</span> <span class="c">/* [IN] Volume label to be set */</span>
); );
</pre> </pre>
</div> </div>
@@ -24,7 +24,7 @@ FRESULT f_setlabel (
<div class="para arg"> <div class="para arg">
<h4>Parameters</h4> <h4>Parameters</h4>
<dl class="par"> <dl class="par">
<dt>name</dt> <dt>label</dt>
<dd>Pointer to the null-terminated string that specifies the volume label to be set.</dd> <dd>Pointer to the null-terminated string that specifies the volume label to be set.</dd>
</dl> </dl>
</div> </div>
@@ -49,12 +49,14 @@ FRESULT f_setlabel (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>When the string has a drive number, the volume label will be set to the volume specified by the drive number. If the volume label is a null-string, the volume label on the volume will be removed. The format of the volume label is similar to the SFN but there are some differences shown below:</p> <p>When the string has a drive number, the volume label will be set to the volume specified by the drive number. If not, the volume label will be set to the default drive. If length of the given volume label is zero, the volume label on the volume will be removed. The format of the volume label on the FAT volume is similar to the file name but there are some differences shown below:</p>
<ul> <ul>
<li>11 bytes or less in length as local character code.</li> <li>Spaces can be contained anywhere in the volume label. Trailing spaces are truncated off at FAT volume.</li>
<li>Cannot contain period.</li> <li>Period is not allowed.</li>
<li>Can contain spaces anywhere in the name.</li> <li>Up to 11 bytes long as conversion of OEM code page at FAT volume.</li>
<li>Up to 11 characters long at exFAT volume. Case information is preserved.</li>
</ul> </ul>
<p>Remark: The standard system (Windows) has a problem at handling of the volume label with a heading <tt>\xE5</tt> on the FAT volume. To avoid this problem, this function rejects such volume label as invalid name.</p>
</div> </div>
<div class="para comp"> <div class="para comp">
+21 -13
View File
@@ -13,37 +13,45 @@
<div class="para"> <div class="para">
<h2>FATFS</h2> <h2>FATFS</h2>
<p>The <tt>FATFS</tt> structure (file system object) holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with <tt>f_mount()</tt> function. Initialization is done on first API call after <tt>f_mount()</tt> function or media change. Application program must not modify any member in this structure.</p> <p>The <tt>FATFS</tt> structure (file system object) holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with <tt>f_mount</tt> function. Initialization is done on first API call after <tt>f_mount</tt> function or media change. Application program must not modify any member in this structure, or any data on the FAT volume can be collapsed.</p>
<pre> <pre>
<span class="k">typedef</span> <span class="k">struct</span> { <span class="k">typedef</span> <span class="k">struct</span> {
BYTE fs_type; <span class="c">/* FAT sub-type (0:Not mounted) */</span> BYTE fs_type; <span class="c">/* File system type (0, FS_FAT12, FS_FAT16, FS_FAT32 or FS_EXFAT) */</span>
BYTE drv; <span class="c">/* Physical drive number */</span> BYTE drv; <span class="c">/* Physical drive number */</span>
BYTE csize; <span class="c">/* Sectors per cluster (1,2,4,...,128) */</span>
BYTE n_fats; <span class="c">/* Number of FAT copies (1,2) */</span> BYTE n_fats; <span class="c">/* Number of FAT copies (1,2) */</span>
BYTE wflag; <span class="c">/* win[] flag (b0:win[] is dirty) */</span> BYTE wflag; <span class="c">/* win[] flag (b0:win[] is dirty) */</span>
BYTE fsi_flag; <span class="c">/* FSINFO flags (b7:Disabled, b0:Dirty) */</span> BYTE fsi_flag; <span class="c">/* FSINFO flags (b7:Disabled, b0:Dirty) */</span>
WORD id; <span class="c">/* File system mount ID */</span> WORD id; <span class="c">/* File system mount ID */</span>
WORD n_rootdir; <span class="c">/* Number of root directory entries (FAT12/16) */</span> WORD n_rootdir; <span class="c">/* Number of root directory entries (FAT12/16) */</span>
<span class="k">#if</span> _MAX_SS != 512 WORD csize; <span class="c">/* Sectors per cluster */</span>
<span class="k">#if</span> _MAX_SS != _MIN_SS
WORD ssize; <span class="c">/* Sector size (512,1024,2048 or 4096) */</span> WORD ssize; <span class="c">/* Sector size (512,1024,2048 or 4096) */</span>
<span class="k">#endif</span> <span class="k">#endif</span>
<span class="k">#if _FS_EXFAT</span>
BYTE* dirbuf; <span class="c">/* Directory entry block scratchpad buffer */</span>
<span class="k">#endif</span>
<span class="k">#if</span> _FS_REENTRANT <span class="k">#if</span> _FS_REENTRANT
_SYNC_t sobj; <span class="c">/* Identifier of sync object */</span> _SYNC_t sobj; <span class="c">/* Identifier of sync object */</span>
<span class="k">#endif</span> <span class="k">#endif</span>
<span class="k">#if</span> !_FS_READONLY <span class="k">#if</span> !_FS_READONLY
DWORD last_clust; <span class="c">/* FSINFO: Last allocated cluster */</span> DWORD last_clust; <span class="c">/* FSINFO: Last allocated cluster (0xFFFFFFFF if invalid) */</span>
DWORD free_clust; <span class="c">/* FSINFO: Number of free clusters */</span> DWORD free_clust; <span class="c">/* FSINFO: Number of free clusters (0xFFFFFFFF if invalid) */</span>
<span class="k">#endif</span> <span class="k">#endif</span>
<span class="k">#if</span> _FS_RPATH <span class="k">#if</span> _FS_RPATH
DWORD cdir; <span class="c">/* Current directory start cluster (0:root) */</span> DWORD cdir; <span class="c">/* Cluster number of current directory (0:root) */</span>
<span class="k">#if _FS_EXFAT</span>
DWORD cdc_scl; <span class="c">/* Containing directory start cluster (invalid when cdir is 0) */</span>
DWORD cdc_size; <span class="c">/* b31-b8:Size of containing directory, b7-b0: Chain status */</span>
DWORD cdc_ofs; <span class="c">/* Offset in the containing directory (invalid when cdir is 0) */</span>
<span class="k">#endif</span> <span class="k">#endif</span>
DWORD n_fatent; <span class="c">/* Number of FAT entries (== Number of clusters + 2) */</span> <span class="k">#endif</span>
DWORD n_fatent; <span class="c">/* Number of FAT entries (Number of clusters + 2) */</span>
DWORD fsize; <span class="c">/* Sectors per FAT */</span> DWORD fsize; <span class="c">/* Sectors per FAT */</span>
DWORD volbase; <span class="c">/* Volume start sector */</span> DWORD volbase; <span class="c">/* Volume base LBA */</span>
DWORD fatbase; <span class="c">/* FAT area start sector */</span> DWORD fatbase; <span class="c">/* FAT base LBA */</span>
DWORD dirbase; <span class="c">/* Root directory area start sector (FAT32: Cluster#) */</span> DWORD dirbase; <span class="c">/* Root directory base (LBA|Cluster) */</span>
DWORD database; <span class="c">/* Data area start sector */</span> DWORD database; <span class="c">/* Data base LBA */</span>
DWORD winsect; <span class="c">/* Current sector appearing in the win[] */</span> DWORD winsect; <span class="c">/* Sector LBA appearing in the win[] */</span>
BYTE win[_MAX_SS]; <span class="c">/* Disk access window for directory, FAT (and file data at tiny cfg) */</span> BYTE win[_MAX_SS]; <span class="c">/* Disk access window for directory, FAT (and file data at tiny cfg) */</span>
} FATFS; } FATFS;
</pre> </pre>
+8 -14
View File
@@ -13,31 +13,25 @@
<div class="para"> <div class="para">
<h2>FIL</h2> <h2>FIL</h2>
<p>The <tt>FIL</tt> structure (file object) holds state of an open file. It is created by <tt>f_open()</tt> function and discarded by <tt>f_close()</tt> function. Application program must not modify any member in this structure except for <tt>cltbl</tt>. Note that a sector buffer is defined in this structure at non-tiny configuration, so that the <tt>FIL</tt> structures should not be defined as auto variable.</p> <p>The <tt>FIL</tt> structure (file object) holds the state of an open file. It is created by <tt>f_open</tt> function and discarded by <tt>f_close</tt> function. Application program must not modify any member in this structure except for <tt>cltbl</tt>, or any data on the FAT volume can be collapsed. Note that a sector buffer is defined in this structure at non-tiny configuration (<tt>_FS_TINY == 0</tt>), so that the <tt>FIL</tt> structures at that configuration should not be defined as auto variable.</p>
<pre> <pre>
<span class="k">typedef</span> <span class="k">struct</span> { <span class="k">typedef</span> <span class="k">struct</span> {
FATFS* fs; <span class="c">/* Pointer to the owner file system object */</span> _FDID obj; <span class="c">/* Owner file sytem object and object identifier */</span>
WORD id; <span class="c">/* Owner file system mount ID */</span>
BYTE flag; <span class="c">/* File object status flags */</span> BYTE flag; <span class="c">/* File object status flags */</span>
BYTE err; <span class="c">/* Abort flag (error code) */</span> BYTE err; <span class="c">/* Abort flag (error code) */</span>
DWORD fptr; <span class="c">/* File read/write pointer (Byte offset origin from top of the file) */</span> FSIZE_t fptr; <span class="c">/* File read/write pointer (Byte offset origin from top of the file) */</span>
DWORD fsize; <span class="c">/* File size in unit of byte */</span> DWORD clust; <span class="c">/* Current cluster of fptr (One cluster behind if fptr is on the cluster boundary. Invalid if fptr == 0.) */</span>
DWORD sclust; <span class="c">/* File start cluster */</span> DWORD sect; <span class="c">/* Current data sector (Can be invalid if fptr is on the cluster boundary.)*/</span>
DWORD clust; <span class="c">/* Current cluster */</span>
DWORD dsect; <span class="c">/* Current data sector */</span>
<span class="k">#if</span> !_FS_READONLY <span class="k">#if</span> !_FS_READONLY
DWORD dir_sect; <span class="c">/* Sector containing the directory entry */</span> DWORD dir_sect; <span class="c">/* Sector number containing the directory entry */</span>
BYTE* dir_ptr; <span class="c">/* Ponter to the directory entry in the window */</span> BYTE* dir_ptr; <span class="c">/* Ponter to the directory entry in the window */</span>
<span class="k">#endif</span> <span class="k">#endif</span>
<span class="k">#if</span> _USE_FASTSEEK <span class="k">#if</span> _USE_FASTSEEK
DWORD* cltbl; <span class="c">/* Pointer to the cluster link map table (Nulled on file open) */</span> DWORD* cltbl; <span class="c">/* Pointer to the cluster link map table (Nulled on file open. Set by application.) */</span>
<span class="k">#endif</span>
<span class="k">#if</span> _FS_LOCK
UINT lockid; <span class="c">/* Fle lock ID */</span>
<span class="k">#endif</span> <span class="k">#endif</span>
<span class="k">#if</span> !_FS_TINY <span class="k">#if</span> !_FS_TINY
BYTE buf[_MAX_SS]; <span class="c">/* File private data transfer buffer */</span> BYTE buf[_MAX_SS]; <span class="c">/* File private data transfer buffer (Always valid if fptr is not on the sector boundary but can be invalid if fptr is on the sector boundary.) */</span>
<span class="k">#endif</span> <span class="k">#endif</span>
} FIL; } FIL;
</pre> </pre>
+13 -14
View File
@@ -13,17 +13,18 @@
<div class="para"> <div class="para">
<h2>FILINFO</h2> <h2>FILINFO</h2>
<p>The <tt>FILINFO</tt> structure holds a file information returned by <tt>f_readdir()</tt> and <tt>f_stat()</tt> function.</p> <p>The <tt>FILINFO</tt> structure holds information about the object returned by <tt>f_readdir</tt>, <tt>f_findfirst</tt>, <tt>f_findnext</tt> and <tt>f_stat</tt> function.</p>
<pre> <pre>
<span class="k">typedef struct</span> { <span class="k">typedef struct</span> {
DWORD fsize; <span class="c">/* File size */</span> FSIZE_t fsize; <span class="c">/* File size */</span>
WORD fdate; <span class="c">/* Last modified date */</span> WORD fdate; <span class="c">/* Last modified date */</span>
WORD ftime; <span class="c">/* Last modified time */</span> WORD ftime; <span class="c">/* Last modified time */</span>
BYTE fattrib; <span class="c">/* Attribute */</span> BYTE fattrib; <span class="c">/* Attribute */</span>
TCHAR fname[13]; <span class="c">/* Short file name (8.3 format) */</span> <span class="k">#if</span> _USE_LFN != 0
<span class="k">#if</span> _USE_LFN TCHAR altname[13]; <span class="c">/* Alternative object name */</span>
TCHAR* lfname; <span class="c">/* Pointer to the LFN buffer */</span> TCHAR fname[_MAX_LFN + 1]; <span class="c">/* Primary object name */</span>
int lfsize; <span class="c">/* Size of the LFN buffer in unit of TCHAR */</span> <span class="k">#else</span>
TCHAR fname[13]; <span class="c">/* Object name */</span>
<span class="k">#endif</span> <span class="k">#endif</span>
} FILINFO; } FILINFO;
</pre> </pre>
@@ -32,9 +33,9 @@
<h4>Members</h4> <h4>Members</h4>
<dl> <dl>
<dt>fsize</dt> <dt>fsize</dt>
<dd>Indicates size of the file in unit of byte. Always zero for directories.</dd> <dd>Indicates size of the file in unit of byte. Always zero for directories. <tt>FSIZE_t</tt> is an alias of integer type either <tt>DWORD</tt>(32-bit) or <tt>QWORD</tt>(64-bit) depends on the configuration option <tt>_FS_EXFAT</tt>.</dd>
<dt>fdate</dt> <dt>fdate</dt>
<dd>Indicates the date that the file was modified or the directory was created.<br> <dd>Indicates the date when the file was modified or the directory was created.<br>
<dl> <dl>
<dt>bit15:9</dt> <dt>bit15:9</dt>
<dd>Year origin from 1980 (0..127)</dd> <dd>Year origin from 1980 (0..127)</dd>
@@ -45,7 +46,7 @@
</dl> </dl>
</dd> </dd>
<dt>ftime</dt> <dt>ftime</dt>
<dd>Indicates the time that the file was modified or the directory was created.<br> <dd>Indicates the time when the file was modified or the directory was created.<br>
<dl> <dl>
<dt>bit15:11</dt> <dt>bit15:11</dt>
<dd>Hour (0..23)</dd> <dd>Hour (0..23)</dd>
@@ -58,11 +59,9 @@
<dt>fattrib</dt> <dt>fattrib</dt>
<dd>Indicates the file/directory attribute in combination of <tt>AM_DIR</tt>, <tt>AM_RDO</tt>, <tt>AM_HID</tt>, <tt>AM_SYS</tt> and <tt>AM_ARC</tt>.</dd> <dd>Indicates the file/directory attribute in combination of <tt>AM_DIR</tt>, <tt>AM_RDO</tt>, <tt>AM_HID</tt>, <tt>AM_SYS</tt> and <tt>AM_ARC</tt>.</dd>
<dt>fname[]</dt> <dt>fname[]</dt>
<dd>Indicates the file/directory name in 8.3 format null-terminated string. It is always returnd with upper case in non-LFN configuration but it can be returned with lower case in LFN configuration.</dd> <dd>The null-terminated object name is stored. A null string is stored when no item to read and it indicates this structure is invalid.</dd>
<dt>lfname</dt> <dt>altname[]</dt>
<dd>Pointer to the LFN buffer to store the read LFN. This member must be initialized by application prior to use this structure. Not available in non-LFN configuration.</dd> <dd>Alternative object name is stored if available. This member is not available at non-LFN configuration.</dd>
<dt>lfsize</dt>
<dd>Size of the LFN buffer in unit of TCHAR. This member must be initialized by application prior to use this structure. Not available in non-LFN configuration.</dd>
</dl> </dl>
<p class="foot"><a href="../00index_e.html">Return</a></p> <p class="foot"><a href="../00index_e.html">Return</a></p>
+3 -3
View File
@@ -15,7 +15,7 @@
<h2>f_size</h2> <h2>f_size</h2>
<p>The f_size function gets the size of a file.</p> <p>The f_size function gets the size of a file.</p>
<pre> <pre>
DWORD f_size ( FSIZE_t f_size (
FIL* <span class="arg">fp</span> <span class="c">/* [IN] File object */</span> FIL* <span class="arg">fp</span> <span class="c">/* [IN] File object */</span>
); );
</pre> </pre>
@@ -39,9 +39,9 @@ DWORD f_size (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>In this revision, the <tt>f_size()</tt> function is implemented as a macro.</p> <p>In this revision, the <tt>f_size</tt> function is implemented as a macro. It does not have any validation and mutual exclusion.</p>
<pre> <pre>
<span class="k">#define</span> f_size(fp) ((fp)->fsize) <span class="k">#define</span> f_size(fp) ((fp)->obj.objsize)
</pre> </pre>
</div> </div>
+37 -1
View File
@@ -54,7 +54,7 @@ FRESULT f_stat (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_stat()</tt> function checks the existence of a file or sub-directory. If exist, the function returns with <tt>FR_OK</tt> and the information of the object is stored to the file information structure. If not exist, the function returns with <tt>FR_NO_FILE</tt>. For details, refer to the <tt>FILINFO</tt> structure and <a href="readdir.html"><tt>f_readdir()</tt></a> function.</p> <p>The <tt>f_stat</tt> function checks the existence of a file or sub-directory. If not exist, the function returns with <tt>FR_NO_FILE</tt>. If exist, the function returns with <tt>FR_OK</tt> and the informations of the object, file size, timestamp, attribute and SFN, are stored to the file information structure. For details of the file information, refer to the <tt>FILINFO</tt> structure and <a href="readdir.html"><tt>f_readdir</tt></a> function.</p>
</div> </div>
@@ -64,6 +64,42 @@ FRESULT f_stat (
</div> </div>
<div class="para use">
<h4>Example</h4>
<pre>
FRESULT fr;
FILINFO fno;
printf("Test for 'file.txt'...\n");
fr = f_stat("file.txt", &amp;fno);
switch (fr) {
case FR_OK:
printf("Size: %lu\n", fno.fsize);
printf("Timestamp: %u/%02u/%02u, %02u:%02u\n",
(fno.fdate &gt;&gt; 9) + 1980, fno.fdate &gt;&gt; 5 &amp; 15, fno.fdate &amp; 31,
fno.ftime &gt;&gt; 11, fno.ftime &gt;&gt; 5 &amp; 63);
printf("Attributes: %c%c%c%c%c\n",
(fno.fattrib &amp; AM_DIR) ? 'D' : '-',
(fno.fattrib &amp; AM_RDO) ? 'R' : '-',
(fno.fattrib &amp; AM_HID) ? 'H' : '-',
(fno.fattrib &amp; AM_SYS) ? 'S' : '-',
(fno.fattrib &amp; AM_ARC) ? 'A' : '-');
break;
case FR_NO_FILE:
printf("It is not exist.\n");
break;
default:
printf("An error occured. (%d)\n", fr);
}
</pre>
</div>
<div class="para ref"> <div class="para ref">
<h4>References</h4> <h4>References</h4>
<p><tt><a href="opendir.html">f_opendir</a>, <a href="readdir.html">f_readdir</a>, <a href="sfileinfo.html">FILINFO</a></tt></p> <p><tt><a href="opendir.html">f_opendir</a>, <a href="readdir.html">f_readdir</a>, <a href="sfileinfo.html">FILINFO</a></tt></p>
+2 -3
View File
@@ -36,7 +36,6 @@ FRESULT f_sync (
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>, <a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>, <a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#tm">FR_TIMEOUT</a> <a href="rc.html#tm">FR_TIMEOUT</a>
</p> </p>
@@ -45,8 +44,8 @@ FRESULT f_sync (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_sync()</tt> function performs the same process as <tt>f_close()</tt> function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing <tt>f_sync()</tt> function of periodic or immediataly after <tt>f_write()</tt> function can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. For more information, refer to <a href="appnote.html#critical">application note</a>.</p> <p>The <tt>f_sync</tt> function performs the same process as <tt>f_close</tt> function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing <tt>f_sync</tt> function of periodic or immediataly after <tt>f_write</tt> function can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. For more information, refer to <a href="appnote.html#critical">application note</a>.</p>
<p>However the <tt>f_sync()</tt> function immediataly before <tt>f_close()</tt> function has no advantage because it performs <tt>f_sync()</tt> function in it. In other words, the differnce between those functions is that the file object is invalidated or not.</p> <p>However there is no sense in <tt>f_sync</tt> function immediataly before <tt>f_close</tt> function because it performs <tt>f_sync</tt> function in it. In other words, the differnce between those functions is that the file object is invalidated or not.</p>
</div> </div>
+2 -2
View File
@@ -15,7 +15,7 @@
<h2>f_tell</h2> <h2>f_tell</h2>
<p>The f_tell function gets the current read/write pointer of a file.</p> <p>The f_tell function gets the current read/write pointer of a file.</p>
<pre> <pre>
DWORD f_tell ( FSIZE_t f_tell (
FIL* <span class="arg">fp</span> <span class="c">/* [IN] File object */</span> FIL* <span class="arg">fp</span> <span class="c">/* [IN] File object */</span>
); );
</pre> </pre>
@@ -39,7 +39,7 @@ DWORD f_tell (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>In this revision, the <tt>f_tell()</tt> function is implemented as a macro.</p> <p>In this revision, the <tt>f_tell</tt> function is implemented as a macro. It does not have any validation and mutual exclusion.</p>
<pre> <pre>
<span class="k">#define</span> f_tell(fp) ((fp)->fptr) <span class="k">#define</span> f_tell(fp) ((fp)->fptr)
</pre> </pre>
+1 -2
View File
@@ -36,7 +36,6 @@ FRESULT f_truncate (
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>, <a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>, <a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#tm">FR_TIMEOUT</a> <a href="rc.html#tm">FR_TIMEOUT</a>
</p> </p>
@@ -45,7 +44,7 @@ FRESULT f_truncate (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_truncate()</tt> function truncates the file size to the current file read/write pointer. This function has no effect if the file read/write pointer is already pointing end of the file.</p> <p>The <tt>f_truncate</tt> function truncates the file size to the current file read/write pointer. This function has no effect if the file read/write pointer is already pointing end of the file.</p>
</div> </div>
+4 -4
View File
@@ -25,7 +25,7 @@ FRESULT f_unlink (
<h4>Parameter</h4> <h4>Parameter</h4>
<dl class="par"> <dl class="par">
<dt>path</dt> <dt>path</dt>
<dd>Pointer to the null-terminated string that specifies an <a href="filename.html">object</a> to be removed.</dd> <dd>Pointer to a null-terminated string that specifies the <a href="filename.html">file or sub-directory</a> to be removed.</dd>
</dl> </dl>
</div> </div>
@@ -57,9 +57,9 @@ FRESULT f_unlink (
<h4>Description</h4> <h4>Description</h4>
<p> <p>
If condition of the object to be removed is applicable to the following terms, the function will be rejected.<ul> If condition of the object to be removed is applicable to the following terms, the function will be rejected.<ul>
<li>The file/sub-directory must not have read-only attribute (<tt>AM_RDO</tt>) or the function will be rejected with <tt>FR_DENIED</tt>.</li> <li>The file/sub-directory must not have read-only attribute (<tt>AM_RDO</tt>), or the function will be rejected with <tt>FR_DENIED</tt>.</li>
<li>The sub-directory must be empty and must not be current directory or the function will be rejected with <tt>FR_DENIED</tt>.</li> <li>The sub-directory must be empty and must not be current directory, or the function will be rejected with <tt>FR_DENIED</tt>.</li>
<li>The file/sub-directory must not has been opened or the <em>FAT volume can be collapted</em>. It will able to be rejected with <tt>FR_LOCKED</tt> when <a href="appnote.html#dup">file lock feature</a> is enabled.</li> <li>The file/sub-directory must not be opened, or the <em>FAT volume can be collapsed</em>. It will be rejected safely when <a href="appnote.html#dup">file lock function</a> is enabled.</li>
</ul> </ul>
</div> </div>
+2 -2
View File
@@ -55,7 +55,7 @@ FRESULT f_utime (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The <tt>f_utime()</tt> function changes the timestamp of a file or sub-directory</p> <p>The <tt>f_utime</tt> function changes the timestamp of a file or sub-directory</p>
</div> </div>
@@ -85,7 +85,7 @@ FRESULT set_timestamp (
<div class="para comp"> <div class="para comp">
<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>_USE_CHMOD == 1</tt>.</p>
</div> </div>
+2 -3
View File
@@ -34,7 +34,7 @@ FRESULT f_write (
<dt>btw</dt> <dt>btw</dt>
<dd>Specifies number of bytes to write in range of <tt>UINT</tt> type.</dd> <dd>Specifies number of bytes to write in range of <tt>UINT</tt> type.</dd>
<dt>bw</dt> <dt>bw</dt>
<dd>Pointer to the <tt>UINT</tt> variable to return the number of bytes written. The value is always valid after the function call regardless of the result.</dd> <dd>Pointer to the <tt>UINT</tt> variable to return the number of bytes written. The value is always valid after the function call regardless of the result code.</dd>
</dl> </dl>
</div> </div>
@@ -45,7 +45,6 @@ FRESULT f_write (
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>, <a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>, <a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#tm">FR_TIMEOUT</a> <a href="rc.html#tm">FR_TIMEOUT</a>
</p> </p>
@@ -54,7 +53,7 @@ FRESULT f_write (
<div class="para desc"> <div class="para desc">
<h4>Description</h4> <h4>Description</h4>
<p>The read/write pointer of the file object advances number of bytes written. After the function succeeded, <tt class="arg">*bw</tt> should be checked to detect the disk full. In case of <tt class="arg">*bw</tt> is less than <tt class="arg">btw</tt>, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.</p> <p>The function starts to write data to the file at the position pointed by the read/write pointer. The read/write pointer advances as number of bytes written. After the function succeeded, <tt class="arg">*bw</tt> should be checked to detect the disk full. In case of <tt class="arg">*bw</tt> is less than <tt class="arg">btw</tt>, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.</p>
</div> </div>
+3 -3
View File
@@ -14,7 +14,7 @@ FRESULT empty_directory (
FILINFO fno; FILINFO fno;
#if _USE_LFN #if _USE_LFN
fno.lfname = 0; /* Eliminate LFN output */ fno.lfname = 0; /* Disable LFN output */
#endif #endif
fr = f_opendir(&dir, path); fr = f_opendir(&dir, path);
if (fr == FR_OK) { if (fr == FR_OK) {
@@ -23,7 +23,7 @@ FRESULT empty_directory (
for (;;) { for (;;) {
fr = f_readdir(&dir, &fno); fr = f_readdir(&dir, &fno);
if (fr != FR_OK || !fno.fname[0]) break; if (fr != FR_OK || !fno.fname[0]) break;
if (fno.fname[0] == '.') continue; if (_FS_RPATH && fno.fname[0] == '.') continue;
j = 0; j = 0;
do do
path[i+j] = fno.fname[j]; path[i+j] = fno.fname[j];
@@ -59,7 +59,7 @@ int main (void)
if (fr) { if (fr) {
printf("Function failed. (%u)\n", fr); printf("Function failed. (%u)\n", fr);
return 1; return fr;
} else { } else {
printf("All contents in the %s are successfully removed.\n", buff); printf("All contents in the %s are successfully removed.\n", buff);
return 0; return 0;
+19 -16
View File
@@ -4,11 +4,11 @@
/ This function checks if the file is contiguous with desired size. / This function checks if the file is contiguous with desired size.
/ If not, a block of contiguous sectors is allocated to the file. / If not, a block of contiguous sectors is allocated to the file.
/ If the file has been opened without FA_WRITE flag, it only checks if / If the file has been opened without FA_WRITE flag, it only checks if
/ the file is contiguous and returns the resulut. */ / the file is contiguous and returns the resulut.
/-----------------------------------------------------------------------/
#if _FATFS != 29000 /* Check if R0.10a */ / This function can work with FatFs R0.09 - R0.11a.
#error This function may not be compatible with this revision of FatFs module. / It is incompatible with R0.12+. Use f_expand function instead.
#endif /----------------------------------------------------------------------*/
/* Declarations of FatFs internal functions accessible from applications. /* Declarations of FatFs internal functions accessible from applications.
/ This is intended to be used for disk checking/fixing or dirty hacks :-) */ / This is intended to be used for disk checking/fixing or dirty hacks :-) */
@@ -37,16 +37,20 @@ DWORD allocate_contiguous_clusters ( /* Returns the first sector in LBA (0:er
do { do {
cl = get_fat(fp->fs, ccl); /* Get the cluster status */ cl = get_fat(fp->fs, ccl); /* Get the cluster status */
if (cl + 1 < 3) return 0; /* Hard error? */ if (cl + 1 < 3) return 0; /* Hard error? */
if (cl != ccl + 1 &&; cl < fp->fs->n_fatent) break; /* Not contiguous? */ if (cl != ccl + 1 && cl < fp->fs->n_fatent) break; /* Not contiguous? */
ccl = cl; ccl = cl;
} while (++ncl < tcl); } while (++ncl < tcl);
if (ncl == tcl) /* Is the file contiguous? */ if (ncl == tcl) /* Is the file contiguous? */
return clust2sect(fp->fs, fp->sclust); /* Return file start sector */ return clust2sect(fp->fs, fp->sclust); /* File is contiguous. Return the start sector */
} }
/* File is not contiguous */
#if _FS_READONLY #if _FS_READONLY
return 0; return 0; /* Exit if in read-only cfg. */
#else #else
if (f_truncate(fp)) return 0; /* Remove the existing chain */ if (!(fp->flag & FA_WRITE)) return 0; /* Exit if the file object is for read-only */
if (f_truncate(fp)) return 0; /* Remove the non-contiguous chain */
/* Find a free contiguous area */ /* Find a free contiguous area */
ccl = cl = 2; ncl = 0; ccl = cl = 2; ncl = 0;
@@ -80,24 +84,23 @@ int main (void)
DWORD org; DWORD org;
/* Open or create a file */ /* Open or create a file to write */
f_mount(&fs, "", 0); f_mount(&fs, "", 0);
fr = f_open(&fil, "swapfile.sys", FA_READ | FA_WRITE | FA_OPEN_ALWAYS); fr = f_open(&fil, "fastrec.log", FA_READ | FA_WRITE | FA_OPEN_ALWAYS);
if (fr) return 1; if (fr) return 1;
/* Check if the file is 64MB in size and occupies a contiguous area. /* Check if the file is 256MB in size and occupies a contiguous area.
/ If not, a contiguous area will be re-allocated to the file. */ / If not, a contiguous area will be re-allocated to the file. */
org = allocate_contiguous_clusters(&fil, 0x4000000); org = allocate_contiguous_clusters(&fil, 0x10000000);
if (!org) { if (!org) {
printf("Function failed due to any error or insufficient contiguous area.\n"); printf("Function failed due to any error or insufficient contiguous area.\n");
f_close(&fil); f_close(&fil);
return 1; return 1;
} }
/* Now you can read/write the file with disk functions bypassing the file system layer. */ /* Now you can read/write the file without file system layer. */
...
dr = disk_write(fil.fs->drv, Buff, org, 1024); /* Write 512KiB from top of the file */ dr = disk_write(fil.fs->drv, Buff, org, 1024); /* Write 512KiB from top of the file */
... ...
f_close(&fil); f_close(&fil);
+4 -5
View File
@@ -48,7 +48,6 @@ int test_diskio (
DRESULT dr; DRESULT dr;
printf("test_diskio(%u, %u, 0x%08X, 0x%08X)\n", pdrv, ncyc, (UINT)buff, sz_buff); printf("test_diskio(%u, %u, 0x%08X, 0x%08X)\n", pdrv, ncyc, (UINT)buff, sz_buff);
if (sz_buff < _MAX_SS + 4) { if (sz_buff < _MAX_SS + 4) {
@@ -306,11 +305,11 @@ int main (int argc, char* argv[])
DWORD buff[512]; /* 2048 byte working buffer */ DWORD buff[512]; /* 2048 byte working buffer */
/* Check function/compatibility of the physical drive #0 */ /* Check function/compatibility of the physical drive #0 */
rc = test_diskio(0, 1, buff, sizeof buff); rc = test_diskio(0, 3, buff, sizeof buff);
if (res) { if (rc) {
printf("Sorry the function/compatibility test failed.\nFatFs will not work on this disk driver.\n"); printf("Sorry the function/compatibility test failed. (rc=%d)\nFatFs will not work on this disk driver.\n", rc);
} else { } else {
printf("Congratulations! The disk I/O layer works well.\n"); printf("Congratulations! The disk driver works well.\n");
} }
return rc; return rc;
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

+160 -158
View File
@@ -6,34 +6,33 @@
<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="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>
<body> <body>
<h1>FatFsモジュール アプリケーションノート</h1> <h1>FatFsモジュール アプリケーション ノート</h1>
<ol class="toc"> <ol class="toc">
<li><a href="#port">ポーティングの際に配慮すべきこと</a></li> <li><a href="#port">ポーティングの際に配慮すべきこと</a></li>
<li><a href="#limits">限界値</a></li> <li><a href="#limits">限界値</a></li>
<li><a href="#memory">メモリ使用量</a></li> <li><a href="#memory">メモリ使用量</a></li>
<li><a href="#reduce">モジュールサイズの縮小</a></li> <li><a href="#reduce">モジュール サイズの縮小</a></li>
<li><a href="#lfn">長いファイル名</a></li> <li><a href="#lfn">長いファイル名</a></li>
<li><a href="#jap">日本語ファイル名の大文字変換</a></li> <li><a href="#exfat">exFATファイル システム</a></li>
<li><a href="#unicode">Unicode入出力への対応</a></li> <li><a href="#unicode">Unicode入出力への対応</a></li>
<li><a href="#reentrant">リエントランシー</a></li> <li><a href="#reentrant">リエントランシー</a></li>
<li><a href="#dup">多重ファイルアクセス</a></li> <li><a href="#dup">多重ファイル アクセス</a></li>
<li><a href="#fs1">効率的なファイルアクセス</a></li> <li><a href="#fs1">効率的なファイル アクセス</a></li>
<li><a href="#fs2">フラッシュメモリの特性への配慮</a></li> <li><a href="#fs2">フラッシュ メモリの特性への配慮</a></li>
<li><a href="#critical">クリチカルセクション</a></li> <li><a href="#critical">クリチカル セクション</a></li>
<li><a href="#fs3">APIの拡張的使用例</a></li> <li><a href="#fs3">APIの拡張的使用例</a></li>
<li><a href="#license">FatFsのライセンスについて</a></li> <li><a href="#license">FatFsのライセンスについて</a></li>
</ol> </ol>
<hr>
<div class="para" id="port"> <div class="para doc" id="port">
<h3>ポーティングの際に配慮すべきこと</h3> <h3>ポーティングの際に配慮すべきこと</h3>
<h4>移植の際の前提条件</h4> <h4>ポーティングの際の前提条件</h4>
<p>FatFsモジュールは移植性に関して次の点を前提としています。</p> <p>FatFsモジュールはポータビリティに関して次の点を前提としています。</p>
<ul> <ul>
<li>処理系はANSI C準拠であること。<br> <li>処理系はANSI C準拠であること。<br>
FatFsモジュールはANSI C(C89)準拠で記述されているので、普通のCコンパイラなら特に処理系依存になる点はありません。</li> FatFsモジュールはANSI C(C89)準拠で記述されているので、普通のCコンパイラなら特に処理系依存になる点はありません。</li>
@@ -44,234 +43,237 @@ FatFsモジュールはANSI C(C89)準拠で記述されているので、普通
<h4>システム構成</h4> <h4>システム構成</h4>
<p>下に示す依存関係図は、FatFsモジュール利用の組み込みシステムにおける代表的な構成を示します。</p> <p>下に示す依存関係図は、FatFsモジュール利用の組み込みシステムにおける代表的な構成を示します。</p>
<p><img src="../img/modules.png" width="580" height="280" alt="システム構成図"></p> <p><img src="../img/modules.png" width="580" height="280" alt="システム構成図"></p>
<p>(a) FatFs用に書かれたディスク モジュールがある場合は、そのまま追加するだけです。 (b) しかし、多くの既存のディスク モジュールはそのAPIをFatFsに合わせるため、グルー関数が必要になるでしょう。</p>
<p><img src="../img/funcs.png" width="750" height="420" alt="functional diagram"></p>
<h4>ユーザの作成する関数</h4> <h4>ユーザの作成する関数</h4>
<p>必要なのは FatFsモジュールの要求するディスク関数を用意することだけで、それ以外にすることはありません。既に動作しているディスク関数があるなら、その APIを FatFsに合わせるかグルー関数つなぐだけで済みますが、無い場合はほかから移植するか最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リードオンリ構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。</p> <p>ポーティング作業は、要求されるデバイス制御関数を用意することが全てで、それ以外にすることは何もありません。既に動作しているデバイス制御モジュールがあるなら、そのAPIをFatFsに合わせるかグルー関数を介してつなぐだけで済みますが、無い場合はほかから移植するか最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード オンリ構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。</p>
<table class="lst2"> <table class="lst2">
<tr><th>ユーザ作成関数</th><th>必要となる条件</th><th>備考</th></tr> <tr><th>必要な関数</th><th>必要となる条件</th><th>備考</th></tr>
<tr><td>disk_initialize<br>disk_status<br>disk_read</td><td>常時</td><td rowspan="5">ffsample.zip (サンプル)<br>その他web上に多数</td></tr> <tr><td>disk_status<br>disk_initialize<br>disk_read</td><td>常時</td><td rowspan="5">ffsample.zip (サンプル)<br>その他web上に多数</td></tr>
<tr><td>disk_write<br>get_fattime<br>disk_ioctl (CTRL_SYNC)</td><td>_FS_READONLY == 0</td></tr> <tr><td>disk_write<br>get_fattime<br>disk_ioctl (CTRL_SYNC)</td><td>_FS_READONLY == 0</td></tr>
<tr><td>disk_ioctl (GET_SECTOR_COUNT)<br>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr> <tr><td>disk_ioctl (GET_SECTOR_COUNT)<br>disk_ioctl (GET_BLOCK_SIZE)</td><td>_USE_MKFS == 1</td></tr>
<tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS != _MIN_SS</td></tr> <tr><td>disk_ioctl (GET_SECTOR_SIZE)</td><td>_MAX_SS != _MIN_SS</td></tr>
<tr><td>disk_ioctl (CTRL_ERASE_SECTOR)</td><td>_USE_ERASE == 1</td></tr> <tr><td>disk_ioctl (CTRL_TRIM)</td><td>_USE_TRIM == 1</td></tr>
<tr><td>ff_convert<br>ff_wtoupper</td><td>_USE_LFN &gt;= 1</td><td>option/cc*.c</td></tr> <tr><td>ff_convert<br>ff_wtoupper</td><td>_USE_LFN != 0</td><td>option/unicode.cをプロジェクトに<br>加えればよい</td></tr>
<tr><td>ff_cre_syncobj<br>ff_rel_grant<br>ff_req_grant<br>ff_del_syncobj</td><td>_FS_REENTRANT == 1</td><td rowspan="2">option/syscall.c (サンプル)</td></tr> <tr><td>ff_cre_syncobj<br>ff_rel_grant<br>ff_req_grant<br>ff_del_syncobj</td><td>_FS_REENTRANT == 1</td><td rowspan="2">option/syscall.c (サンプル)</td></tr>
<tr><td>ff_mem_alloc<br>ff_mem_free</td><td>_USE_LFN == 3</td></tr> <tr><td>ff_mem_alloc<br>ff_mem_free</td><td>_USE_LFN == 3</td></tr>
</table> </table>
</div> </div>
<div class="para" id="limits"> <div class="para doc" id="limits">
<h3>限界値</h3> <h3>限界値</h3>
<ul> <ul>
<li>FATタイプ: FAT12, FAT16, FAT32。</li> <li>ファイルシステム: FAT12, FAT16, FAT32(r0.0) および exFAT(r1.0)</li>
<li>同時オープンファイル数: 無制限。(利用可能メモリによる)</li> <li>同時オープン ファイル数: 無制限。(利用可能メモリによる)</li>
<li>ボリューム数: 最大 10。</li> <li>同時マウント ボリューム数: 最大 10。</li>
<li>ファイルサイズ: FAT規格に依存。(最大 4G-1バイト)</li> <li>ファイル サイズ: 最大 4GiB-1(FATボリューム) または 事実上無制限(exFATボリューム)。</li>
<li>ボリュームサイズ: FAT規格に依存。(最大 2Tバイト(512バイト/セクタ時))</li> <li>ボリューム サイズ: 最大 2TiB (512B/セクタ時)</li>
<li>クラスタサイズ: FAT規格に依存。(最大 64Kバイト(512バイト/セクタ時))</li> <li>クラスタ サイズ: 最大 128セクタ (FATボリューム) または 32768セクタ (exFATボリューム)。</li>
<li>セクタサイズ: FAT規格に依存。(5124096バイト)</li> <li>セクタ サイズ: 512B, 1KiB, 2KiB, 4KiB。</li>
</ul> </ul>
</div> </div>
<div class="para" id="memory"> <div class="para doc" id="memory">
<h3>メモリ使用量</h3> <h3>メモリ使用量</h3>
<p>次の表にいくつかのターゲットにおけるメモリ使用量の例を示します。テスト時の構成オプションはその下の通りです。数値の単位はバイトで、<em>V</em>はボリューム数、<em>F</em>は同時オープンファイル数を示します。コンパイラの最適化オプションはコードサイズとしています。</p> <p>次の表にいくつかのターゲットにおけるメモリ使用量の例を示します。テスト時の構成オプションはその下の通りです。数値の単位はバイトで、<em>V</em>はボリューム数、<em>F</em>は同時オープン ファイル数を示します。コンパイラの最適化オプションはコード サイズとしています。</p>
<table class="lst2"> <table class="lst2">
<tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>CM3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX600</th><th>IA-32</th></tr> <tr><th></th><th>ARM7<small><br>32bit</small></th><th>ARM7<small><br>Thumb</small></th><th>CM3<small><br>Thumb-2</small></th><th>AVR</th><th>H8/300H</th><th>PIC24</th><th>RL78</th><th>V850ES</th><th>SH-2A</th><th>RX600</th><th>IA-32</th></tr>
<tr class="cal"> <td>Compiler</td><td>GCC</td><td>GCC</td><td>GCC</td><td>GCC</td><td>CH38</td><td>C30</td><td>CC78K0R</td><td>CA850</td><td>SHC</td><td>RXC</td><td>VC6</td></tr> <tr class="cal"> <td>Compiler</td><td>GCC</td><td>GCC</td><td>GCC</td><td>GCC</td><td>CH38</td><td>C30</td><td>CC78K0R</td><td>CA850</td><td>SHC</td><td>RXC</td><td>MSC</td></tr>
<tr class="cal"> <td>_WORD_ACCESS</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>0</td><td>0</td><td>1</td><td>0</td><td>1</td><td>1</td></tr>
<!-- ARM Thumb CM3 AVR H8 PIC24 RL78 V850ES SH-2A RX600 IA-32 --> <!-- ARM Thumb CM3 AVR H8 PIC24 RL78 V850ES SH-2A RX600 IA-32 -->
<tr class="lst3 ral"><td class="cal">text (Full, R/W)</td><td>10675</td><td>7171</td><td>6617</td><td>13355</td><td>10940</td><td>11722</td><td>13262</td><td>8113</td><td>9048</td><td>6032</td><td>7952</td></tr> <tr class="ral"><td class="cal">text (Full, R/W)</td><td>10.1k</td><td>6.6k</td><td>6.2k</td><td>12.1k</td><td>10.5k</td><td>11.2k</td><td>12.6k</td><td>8.5k</td><td>8.7k</td><td>6.3k</td><td>8.4k</td></tr>
<tr class="ral"> <td class="cal">text (Min, R/W)</td> <td>6727</td><td>4631</td><td>4331</td> <td>8569</td> <td>7262</td> <td>7720</td> <td>9088</td><td>5287</td><td>5800</td><td>3948</td><td>5183</td></tr> <tr class="ral"><td class="cal">text (Min, R/W)</td> <td>6.6k</td><td>4.5k</td><td>4.2k</td> <td>7.9k</td> <td>7.0k</td> <td>7.6k</td> <td>8.8k</td><td>5.9k</td><td>5.8k</td><td>4.3k</td><td>5.8k</td></tr>
<tr class="ral"> <td class="cal">text (Full, R/O)</td> <td>4731</td><td>3147</td><td>2889</td> <td>6235</td> <td>5170</td> <td>5497</td> <td>6482</td><td>3833</td><td>3972</td><td>2862</td><td>3719</td></tr> <tr class="ral"><td class="cal">text (Full, R/O)</td> <td>4.8k</td><td>3.1k</td><td>2.9k</td> <td>5.8k</td> <td>5.1k</td> <td>5.5k</td> <td>6.4k</td><td>4.1k</td><td>4.0k</td><td>3.1k</td><td>4.0k</td></tr>
<tr class="ral"> <td class="cal">text (Min, R/O)</td> <td>3559</td><td>2485</td><td>2295</td> <td>4575</td> <td>4064</td> <td>4240</td> <td>5019</td><td>2993</td><td>3104</td><td>2214</td><td>2889</td></tr> <tr class="ral"><td class="cal">text (Min, R/O)</td> <td>3.5k</td><td>2.4k</td><td>2.3k</td> <td>4.4k</td> <td>3.9k</td> <td>4.2k</td> <td>5.0k</td><td>3.3k</td><td>3.1k</td><td>2.4k</td><td>3.1k</td></tr>
<tr class="ral"> <td class="cal">bss</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td></tr> <tr class="ral"><td class="cal">bss</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*2 + 2</td><td>V*2 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td><td>V*4 + 2</td></tr>
<tr class="ral"> <td class="cal">Work area<br>(_FS_TINY == 0)</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*544</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*544</td><td>V*560<br>+ F*544</td><td>V*560<br>+ F*544</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*550</td><td>V*560<br>+ F*550</td></tr> <tr class="ral"><td class="cal">Work area<br><small>(_FS_TINY == 0)</small></td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*560<br>+ F*546</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td><td>V*564<br>+ F*552</td></tr>
<tr class="ral"> <td class="cal">Work area<br>(_FS_TINY == 1)</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*32</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*32</td><td>V*560<br>+ F*32</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td><td>V*560<br>+ F*36</td></tr> <tr class="ral"><td class="cal">Work area<br><small>(_FS_TINY == 1)</small></td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*560<br>+ F*34</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</td><td>V*564<br>+ F*40</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, <em>V</em> denotes option <tt>_VOLUMES</tt> and <em>F</em> denotes number of open files. All samples here are optimezed in code size.</p>
<pre> <pre>
FatFs R0.10a options: FatFs R0.12 options:
_FS_READONLY 0 (R/W) or 1 (R/O) _FS_READONLY 0 (R/W) or 1 (R/O)
_FS_MINIMIZE 0 (Full function) or 3 (Minimized function) _FS_MINIMIZE 0 (Full, with all basic functions) or 3 (Min, with fully minimized)
_USE_STRFUNC 0 (Disable string functions) _FS_TINY 0 (Default) or 1 (Tiny file object)
_USE_MKFS 0 (Disable f_mkfs function) And any other options are left not changed from default setting.
_USE_FORWARD 0 (Disable f_forward function)
_USE_FASTSEEK 0 (Disable fast seek feature)
_CODE_PAGE 932 (Japanese Shift-JIS)
_USE_LFN 0 (Disable LFN feature)
_MAX_SS 512 (Fixed sector size)
_FS_RPATH 0 (Disable relative path feature)
_FS_LABEL 0 (Disable volume label functions)
_VOLUMES V (Number of logical drives to be used)
_MULTI_PARTITION 0 (Single partition per drive)
_FS_REENTRANT 0 (Disable thread safe)
_FS_LOCK 0 (Disable file lock control)
</pre> </pre>
</div> </div>
<div class="para" id="reduce"> <div class="para doc" id="reduce">
<h3>モジュールサイズの縮小</h3> <h3>モジュール サイズの縮小</h3>
<p>次の表は構成オプションの設定値によりどの機能が削除されるかを示します。</p> <p>次の表は<a href="config.html">構成オプション</a>の設定値によりどの機能が削除されるかを示します。API関数の行にxが無ければその関数は使用可能です。</p>
<table class="lst2"> <table class="lst2">
<tr><td rowspan="2">Function</td><td colspan="4">_FS_MINIMIZE</td><td colspan="2">_FS_READONLY</td><td colspan="2">_USE_STRFUNC</td><td colspan="3">_FS_RPATH</td><td colspan="2">_FS_LABEL</td><td colspan="2">_USE_MKFS</td><td colspan="2">_USE_FORWARD</td><td colspan="2">_MULTI_PARTITION</td></tr> <tr><td rowspan="2">Function</td><td colspan="4">_FS_<br>MINIMIZE</td><td colspan="2">_FS_<br>READONLY</td><td colspan="2">_USE_<br>STRFUNC</td><td colspan="3">_FS_<br>RPATH</td><td colspan="2">_USE_<br>FIND</td><td colspan="2">_USE_<br>CHMOD</td><td colspan="2">_USE_<br>EXPAND</td><td colspan="2">_USE_<br>LABEL</td><td colspan="2">_USE_<br>MKFS</td><td colspan="2">_USE_<br>FORWARD</td><td colspan="2">_MULTI_<br>PARTITION</td></tr>
<tr><td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0&nbsp;&nbsp;</td><td>1/2</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0/1</td><td>2</td></tr> <tr> <td>0</td><td>1</td><td>2</td><td>3</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>2</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td><td>0</td><td>1</td></tr>
<tr class="lst3"><td>f_mount</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr class="lst3">
<tr><td>f_open</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <td>f_mount</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_close</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_open</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_read</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_close</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_write</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_read</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_sync</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_write</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_lseek</td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_sync</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_opendir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_lseek</td> <td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_closedir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_opendir</td> <td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_readdir</td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_closedir</td> <td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_stat</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_readdir</td> <td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_getfree</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_findfirst</td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_truncate</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_findnext</td> <td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_unlink</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_stat</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_mkdir</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_getfree</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_chmod</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_truncate</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_utime</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_unlink</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_rename</td><td></td><td>x</td><td>x</td><td>x</td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_mkdir</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_chdir</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_rename</td> <td> </td><td>x</td><td>x</td><td>x</td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_chdrive</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_chdir</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_getcwd</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_chdrive</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_getlabel</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_getcwd</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_setlabel</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_chmod</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_forward</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td></tr> <tr><td>f_utime</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_mkfs</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_getlabel</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_fdisk</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td>x</td><td></td></tr> <tr><td>f_setlabel</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_putc</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_expand</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_puts</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_forward</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td></tr>
<tr><td>f_printf</td><td></td><td></td><td></td><td></td><td></td><td>x</td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_mkfs</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_gets</td><td></td><td></td><td></td><td></td><td></td><td></td><td>x</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> <tr><td>f_fdisk</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td>x</td><td> </td></tr>
<tr><td>f_putc</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_puts</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_printf</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
<tr><td>f_gets</td> <td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td>x</td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td><td> </td></tr>
</table> </table>
</div> </div>
<div class="para" id="lfn"> <div class="para doc" id="lfn">
<h3>長いファイル名</h3> <h3>長いファイル名</h3>
<p>FatFsモジュールはR0.07から長いファイル名(LFN)をサポートしました。ファイルに付けられた2つの異なる名前(短いファル名と長いファイル名)は、<tt>f_readdir()</tt>を除くファイル操作関数において透過です。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>FatFsモジュールは長いファイル名(LFN)をサポートしま。ファイルに付けられた2つの異なる名前(短いファル名と長いファイル名)は、<tt>f_readdir</tt>関数を除くファイル操作関数において透過です。デフォルト構成では、LFN機能はOFFになっています。LFN機能を有効にするには、<tt><a href="config.html#use_lfn">_USE_LFN</a></tt>を1,2または3に設定し、<tt>option/unicode.c</tt>をプロジェクトに追加します。LFN機能は、加えてある程度のワーク エリア(LFN操作バッファ)を必要とします。バッファ長は使用できるメモリに応じて<tt><a href="config.html#max_lfn">_MAX_LFN</a></tt>で構成されることができます。LFNの長さは最大255文字に達するので、LFN完全対応のためには<tt>_MAX_LFN</tt>は255に設定されるべきです。与えられたファイル名に対してバッファ長が不足した場合、ファイル関数は<tt>FR_INVALID_NAME</tt>で失敗します。</p>
<p>何らかのリエントラント状態の下でLFN機能を使用する場合は、<tt>_USE_LFN</tt>は2または3に設定されなければなりません。この場合、ファイル関数はバッファをスタックやヒープに確保します。バッファ・サイズは、<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構成 at CM3</caption>
<tr><th>コードページ</th><th>コードサイズ[bytes]</th></tr> <tr><th><tt>_CODE_PAGE</tt></th><th>追加コード</th></tr>
<tr><td>SBCS</td><td>+3721</td></tr> <tr><td>SBCS</td><td>+2.8K</td></tr>
<tr><td>932(Shift-JIS)</td><td>+62609</td></tr> <tr><td>932(Shift_JIS)</td><td>+62.6k</td></tr>
<tr><td>936(GBK)</td><td>+177797</td></tr> <tr><td>936(GBK)</td><td>+177k</td></tr>
<tr><td>949(Korean)</td><td>+139857</td></tr> <tr><td>949(Korean)</td><td>+139k</td></tr>
<tr><td>950(Big5)</td><td>+111497</td></tr> <tr><td>950(Big5)</td><td>+111k</td></tr>
</table> </table>
<p>LFN機能の上手な使い方は、それを使わないということです。実際、組み込み用途ではLFN機能がどうしても必要になるということはほとんど無いはずです。LFNを有効にすると、選択されたコードページに応じてモジュールサイズが増大されます。右の表に各コードページにおけるLFNを有効にしたときのモジュールサイズの違いを示します。特に、CJK地域では数万の文字が使われていますが、不幸なことにそれは巨大なOEM-Unicode相互変換テーブルを要求し、モジュールサイズは劇的に増大されます。その結果、それらのコードページにおいてLFNを有効にしたFatFsモジュールは、AVRを含む殆どの8ビットマイコンにインプリメントされることができません。</p> <p>LFN機能の上手な使い方は、それを使わないということです。実際、組み込み用途ではLFN機能がどうしても必要になるということはほとんど無いはずです。LFNを有効にすると、選択されたコード ページに応じてモジュール サイズが増大ます。右の表に各コード ページにおけるLFNを有効にしたときのモジュール サイズの違いを示します。特に、CJK地域では数万の文字が使われていますが、不幸なことにそれは巨大なOEM-Unicode相互変換テーブルを要求し、モジュール サイズは劇的に増大ます。その結果、それらのコード ページにおいてLFNを有効にしたFatFsモジュールは、多くの8ビット マイコンにインプリメントることができません。</p>
<p>LFN機能のハードルはそれだけではありません。マイクロソフト社はFATファイルシステムについていくつかの特許を保有しています。いずれもLFN機能の実装に関するもので、その利用に対して$0.25/unitのライセンス料を要求しています。このため、商用製品でLFN機能を利用するときは、最終仕向地によってはライセンスが必要になります。最近のFAT32ドライバの多くはLFN機能を含んでいるため、それらの使用に当たってライセンスが必要になりますが、FatFsではLFN機能を構成オプションで任意にON/OFFできるため、無効にしてライセンス問題を回避することもできます。</p> <p>LFN機能のハードルはそれだけではありません。マイクロソフト社はFATファイル システムについていくつかの特許を保有しています。いずれもLFN機能の実装に関するもので、その利用に対して$0.25/unitのライセンス料を要求しています。このため、商用製品でLFN機能を利用する場合は、製品の最終仕向地によってはライセンスが必要になります。最近のFAT32ドライバの多くはLFN機能を含んでいるため、それらの使用に当たってライセンスが必要になりますが、FatFs構成オプションでLFN機能を任意にON/OFFできるため、無効にしてライセンス問題を回避することもできます。</p>
</div> </div>
<div class="para" id="jap"> <div class="para doc" id="unicode">
<h3>日本語ファイル名の大文字変換</h3>
<p>CP932(Shift_JIS)でかつ非LFN構成のときは、拡張文字の小文字(2バイト英字・キリル文字・ギリシャ文字)に対して大文字変換を行わず、小文字のままSFNエントリに記録・検索されます(日本語MSDOS仕様)。このため、非LFN構成で全角小文字を含むファイルを作成すると、NT系Windowsでそのファイルを開けなくなります。LFN構成では大文字変換を行います(NT系Windows仕様)。</p>
</div>
<div class="para" id="unicode">
<h3>Unicode入出力への対応</h3> <h3>Unicode入出力への対応</h3>
<p>FatFs API上におけるファイル名等の文字列データの入出力は、デフォルトではANSI/OEMコードで行われますが、これをUnicode(UTF-16)に切り替えることもできます(<tt>_LFN_UNICODE</tt>オプションで設定)。つまり、これはFatFsがLFN機能に完全対応していることを意味します。Unicodeのファイル名に関する詳細は、<a href="filename.html">ファイル名</a>を参照してください。</p> <p>FatFs API上におけるファイル名等の文字列データの入出力は、デフォルトではANSI/OEMコードで行われますが、これをUnicode(UTF-16)に切り替えることもできます(<tt><a href="config.html#lfn_unicode">_LFN_UNICODE</a></tt>で設定)。つまり、これはFatFsがLFN機能に完全対応していることを意味します。Unicodeのファイル名に関する詳細は、<a href="filename.html#uni">パス名のフォーマット</a>を参照してください。</p>
</div> </div>
<div class="para" id="reentrant"> <div class="para doc" id="exfat">
<h3>exFATファイル システム</h3>
<p>exFAT(Microsoft's Extended File Allocation Table)ファイル システムは、既に組み込みシステムや情報家電で広く使われているFATファイル システムを置き換える目的で開発されました。exFATは、64GiB以上のSDメモリ カードで標準ファイル システムに採用されるなど、FATに並びリムーバブル メディアの標準ファイル システムの一つとなりつつあります。</p>
<p>exFATボリュームでは、FATボリュームで制約となっていた4GiB以上のサイズのファイルを扱え、ファイル システムのオーバーヘッド(特にファイル アロケーション ディレイ)も大幅に低減され、書き込みスループットがFATより向上しています。しかし、現リビジョンのFatFsでは、実装上の理由から不連続ファイルへのサイズ拡大を伴う書き込み時のとき、スループットがFATより低下します。<tt>f_expand</tt>関数による連続領域の割り当て機能は、この問題の回避に有効かもしれません。</p>
<p>exFATはマイクロソフト社が開発したものなので、マイクロソフト社はexFATについていくつかの特許を保有しています。FatFsのexFAT機能は、それの US. Pat. App. Pub. No. 2009/0164440 A1 に基づいた実装です。このため、商用製品でexFAT機能を利用する場合、製品の最終仕向地によってはライセンスが必要になります。最近のFATドライバの多くはexFAT機能を含んでいるため、それらの使用に当たってライセンスが必要になりますが、FatFsは構成オプションでexFAT機能を任意にON/OFFできるため、無効にしてライセンス問題を回避することもできます。</p>
<p><em>exFATを有効にすると、FatFsモジュールのC89互換は失われます(64ビット整数型が必要なため)。</em></p>
</div>
<div class="para doc" id="reentrant">
<h3>リエントランシー</h3> <h3>リエントランシー</h3>
<p>互いに異なるボリュームに対するファイル操作はリエントラントで、常に同時平行に動作できます。同じボリュームに対してはデフォルトではリエントラントではありませんが、<tt>_FS_REENTRANT</tt>オプションでリエントラント(スレッド・セーフ)にすることはできます。この場合、OS依存の同期オブジェクト操作関数<tt>ff_cre_syncobj(), ff_del_syncobj(), ff_req_grant(), ff_rel_grant()</tt>もまたプロジェクトに追加されなければなりません。サンプル・コードと解説は<tt>option/syncobj.c</tt>にあります。</p> <p>互いに異なるボリュームに対するファイル操作は<tt>_USE_LFN == 1</tt>を除いて構成にかかわらずリエントラントで、常に同時平行に動作できます。</p>
<p>この場合、あるタスクがボリュームを使用中に他のタスクからそのボリュームに対するファイル関数が呼び出されると、そのアクセスは先のタスクがファイル関数を抜けるまでブロックされます。もし、待ち時間が<tt>_TIMEOUT</tt>で指定された期間を越すと、その関数<tt>FR_TIMEOUT</tt>でアボートします。いくつかのRTOSではタイムアウト機能はサポートされないかも知れません</p> <p>同じボリュームに対してはデフォルトではリエントラントではありませんが、<tt><a href="config.html#fs_reentrant">_FS_REENTRANT</a></tt>でリエントラント(スレッド セーフ)にすることはできます。この場合、OS依存の同期オブジェクト操作関数<tt>ff_cre_syncobj, ff_del_syncobj, ff_req_grant, ff_rel_grant</tt>関数もまたプロジェクトに追加されなければなりません。サンプル コードと解説は<tt>option/syncobj.c</tt>にあります</p>
<p>ひとつの例外が<tt>f_mount(), f_mkfs(), f_fdisk()</tt>にあります。これらの関数は同じボリューム(または関連する物理ドライブ)に対してリエントラントではありません。これらの関数を使用するときは、アプリケーション・レベルで排他制御しなければなりません。</p> <p>この場合、あるタスクがボリュームを使用中に他のタスクからそのボリュームに対するファイル関数が呼び出されると、そのアクセスは先のタスクがファイル関数を抜けるまでサスペンドされます。待ち時間が<tt>_TIMEOUT</tt>で指定された期間を越えた場合、その関数は<tt>FR_TIMEOUT</tt>でアボートします。いくつかのRTOSではタイムアウト機能はサポートされないかも知れません。</p>
<p>注: このセクションはFatFsモジュールそれ自体のリエントランシーについて説明しています。その下位のディスクI/Oモジュールのリエントランシーに関しては何の前提もありません。</p> <p>ひとつの例外が<tt>f_mount, f_mkfs, f_fdisk</tt>関数にあります。これらのボリューム制御関数は同じボリューム(または関連する物理ドライブ)に対してリエントラントではありません。これらの関数を使用するときは、アプリケーション レベルで排他制御しなければなりません。</p>
<p>注: このセクションはFatFsモジュールそれ自体のリエントランシーについて説明しています。<tt>_FS_REENTRANT</tt>は、各ファイル システム オブジェクトの排他制御を行うのみで、下位のディスク関数への再入を防止するものではありません。たとえば、シングル ボリューム構成では<tt>disk_status</tt>関数のみ再入される可能性があり、マルチ ボリューム構成ではどのディスク関数も再入される可能性があります。このように、複数のタスクから同時にFatFs APIを使う条件では、ディスクI/Oモジュールはスレッド セーフである必要があります。</p>
</div> </div>
<div class="para" id="dup"> <div class="para doc" id="dup">
<h3>多重ファイルアクセス</h3> <h3>多重ファイル アクセス</h3>
<p>FatFsモジュールではデフォルトでは多重アクセス制御機能をサポートしていません。ファイルに対する多重アクセスは、そのアクセスモードによって制限されます。一つのファイルに対する多重オープンは、それらが全てリードモードのときに限って許可されます。書き込みモードを含む多重オープン、また開かれているファイルに対するリネームや削除を行ってはなりません。さもないと、そのボリュームのFAT構造が破壊される可能性があります。</p> <p>FatFsモジュールではデフォルトでは多重アクセス制御機能をサポートしていません。ファイルに対する多重アクセスは、そのアクセス モードによって制限されます。一つのファイルに対する多重オープンは、それらが全てリード モードのときに限って許可されます。書き込みモードを含む多重オープン、また開かれているファイルに対するリネームや削除を行ってはなりません。さもないと、そのボリュームのFAT構造が破壊される可能性があります。</p>
<p><tt>_FS_LOCK</tt>に1以上の値(値は同時に管理できるファイル数)をセットすることで多重アクセス制御機能が有効になり、ファイル単位のアクセス制御を自動で行うこともできます。この場合、上記のルールを破ったオープン・リネーム・削除を試みると、その関数は<tt>FR_LOCKED</tt>で失敗します。また、<tt>_FS_LOCK</tt>を越える数のファイルやディレクトリを同時にオープンしようとすると、<tt>FR_TOO_MANY_OPEN_FILES</tt>で失敗します。</p> <p><tt><a href="config.html#fs_lock">_FS_LOCK</a></tt>に1以上の値(値は同時に管理できるファイル数)をセットすることで多重アクセス制御機能が有効になり、ファイル単位のアクセス制御を自動で行うこともできます。この場合、上記のルールを破ったオープン・リネーム・削除を試みると、その関数は<tt>FR_LOCKED</tt>で失敗します。また、<tt>_FS_LOCK</tt>を越える数のファイルやサブ ディレクトリを同時にオープンしようとすると、<tt>FR_TOO_MANY_OPEN_FILES</tt>で失敗します。</p>
</div> </div>
<div class="para" id="fs1"> <div class="para doc" id="fs1">
<h3>効率的なファイルアクセス</h3> <h3>効率的なファイル アクセス</h3>
<p>小規模な組込システムでのファイルの読み書きにおける効率の良いアクセスのため、アプリケーションプログラマはFatFsモジュールの中でどのような処理が行われているか考慮すべきです。ストレージ上のデータは<tt>f_read()</tt>により次のシーケンスで転送されます。</p> <p>小規模な組込システムでのファイルの読み書きにおける効率の良いアクセスのため、アプリケーション プログラマはFatFsモジュールの中でどのような処理が行われているか考慮すべきです。ストレージ上のデータは<tt>f_read</tt>関数により次のシーケンスで転送されます。</p>
<p>図1. セクタミスアラインドリード (ショート)<br> <p>図1. セクタ ミスアラインド リード (ショート)<br>
<img src="../img/f1.png" width="490" height="110" alt="fig.1"> <img src="../img/f1.png" width="490" height="110" alt="fig.1">
</p> </p>
<p>図2. セクタミスアラインドリード (ロング)<br> <p>図2. セクタ ミスアラインド リード (ロング)<br>
<img src="../img/f2.png" width="490" height="140" alt="fig.2"> <img src="../img/f2.png" width="490" height="140" alt="fig.2">
</p> </p>
<p>図3. セクタアラインドリード<br> <p>図3. セクタ アラインド リード<br>
<img src="../img/f3.png" width="490" height="119" alt="fig.3"> <img src="../img/f3.png" width="490" height="119" alt="fig.3">
</p> </p>
<p>ファイルI/Oバッファはセクタの一部のデータを読み書きするためのセクタバッファを意味します。セクタバッファは、それぞれのファイルオブジェクト内のプライベートセクタバッファまたはファイルシステムオブジェクト内の共有セクタバッファのどちらかです。バッファ構成オプションの<tt>_FS_TINY</tt>は、データ転送にどちらを使うかを決定します。タイニーバッファ(1)が選択されるとデータメモリの消費はそれぞれのファイルオブジェクトで512バイト減少されます。この場合、FatFsモジュールはファイルデータの転送とFAT/ディレクトリアクセスにファイルシステムオブジェクト内のセクタバッファだけを使用します。タイニーバッファの欠点は、セクタバッファにキャッシュされたFATデータがファイルデータの転送により失われ、クラスタ境界の毎にリロードされなければならないことです。でも、悪くない性能と少ないメモリ消費の視点から多くのアプリケーションに適するでしょう。</p> <p>ファイルI/Oバッファはセクタの一部のデータを読み書きするためのセクタ バッファを意味します。セクタ バッファは、それぞれのファイル オブジェクト内のプライベート セクタ バッファまたはファイル システム オブジェクト内の共有セクタ バッファのどちらかです。バッファ構成オプションの<tt><a href="config.html#fs_tiny">_FS_TINY</a></tt>は、データ転送にどちらを使うかを決定します。タイニー バッファ(1)が選択されるとデータ メモリの消費はそれぞれのファイル オブジェクトで<tt>_MAX_SS</tt>バイト減少されます。この場合、FatFsモジュールはファイル データの転送とFAT/ディレクトリ アクセスにファイル システム オブジェクト内のセクタ バッファだけを使用します。タイニー バッファの欠点は、セクタ バッファにキャッシュされたFATデータがファイル データの転送により失われ、クラスタ境界の毎にリロードされなければならないことです。でも、悪くない性能と少ないメモリ消費の視点から多くのアプリケーションに適するでしょう。</p>
<p>図1はセクタの一部のデータがファイルI/Oバッファを経由で転送されることを示します。図2に示される長いデータの転送では、転送データの中間の1セクタまたはそれ以上のセクタにまたがる転送データがアプリケーションバッファに直接転送されています。図3は転送データ全体がセクタ境界にアライメントされている場合を示しています。この場合、ファイルI/Oバッファは使用されません。直接転送においては最大の範囲のセクタが<tt>disk_read()</tt>で一度に読み込まれますが、クラスタ境界を越えるマルチセクタ転送はそれが隣接であっても行われません。</p> <p>図1はセクタの一部のデータがファイルI/Oバッファを経由で転送されることを示します。図2に示される長いデータの転送では、転送データの中間の1セクタまたはそれ以上のセクタにまたがる転送データがアプリケーション バッファに直接転送されています。図3は転送データ全体がセクタ境界にアライメントされている場合を示しています。この場合、ファイルI/Oバッファは使用されません。直接転送においては最大の範囲のセクタが<tt>disk_read</tt>関数で一度に読み込まれますが、クラスタ境界を越えるマルチ セクタ転送はそれが隣接であっても行われません。</p>
<p>このように、セクタにアライメントしたファイルの読み書きへの配慮はバッファ経由のデータ転送を避け、読み書き性能は改善されるでしょう。その効果に加え、タイニー構成でキャッシュされたFATデータがファイルデータの転送によりフラッシュされず、非タイニー構成と同じ性能を小さなメモリフットプリントで達成できます。</p> <p>このように、セクタにアライメントしたファイルの読み書きへの配慮はバッファ経由のデータ転送を避け、読み書き性能は改善されるでしょう。その効果に加え、タイニー構成でキャッシュされたFATデータがファイル データの転送によりフラッシュされず、非タイニー構成と同じ性能を小さなメモリ フットプリントで達成できます。</p>
</div> </div>
<div class="para" id="fs2"> <div class="para doc" id="fs2">
<h3>フラッシュメモリの特性への配慮</h3> <h3>フラッシュ メモリの特性への配慮</h3>
<p>HDDなどのディスクメディアとは異なり、SDCやCFCなどのフラッシュメモリメディアの性能を引き出すには、その特性を意識した制御が必要になります。</p> <p>HDDなどのディスク メディアとは異なり、SDCやCFCなどのフラッシュ メモリ メディアの性能を引き出すには、その特性を意識した制御が必要になります。</p>
<h4>マルチセクタ書き込み</h4> <h4>マルチ セクタ書き込み</h4>
<div class="rset"> <div class="rset">
図6. マルチ/シングルセクタライトの比較<br> 図6. マルチ/シングル セクタ ライトの比較<br>
<img src="../img/f6.png" width="630" height="148" alt="fig.6"> <img src="../img/f6.png" width="630" height="148" alt="fig.6">
</div> </div>
<p>フラッシュメモリメディアの書き込み速度はシングルセクタ書き込みの時に最も低いものになり、一回のトランザクションで転送されるセクタ数が大きくなるほど書き込み速度は向上します。この効果はバス速度が高速になるほど顕著で、10倍以上の差が現れることも珍しくありません。書き込みトランザクションの回数はまた、メディアの寿命にも影響してきます。このため、アプリケーションはなるべく大きなブロック(クラスタ・サイズまたは2の累乗セクタ境界にアライメントした)で読み書きを行う必要があります。もちろん、アプリケーションからメディアに至る全てのレイヤがマルチ・セクタ転送に対応していないと意味がありません。残念ながら、既存のオープン・ソースのドライバの多くはマルチ・セクタ転送に未対応です。なお、FatFsモジュールおよびそれ用のサンプル・ドライバはマルチ・セクタ転送に対応しています。</p> <p>フラッシュ メモリ メディアの書き込み速度はシングル セクタ書き込みの時に最も低いものになり、一回のトランザクションで転送されるセクタ数が大きくなるほど書き込み速度は向上します(図6)。この効果はバス速度が高速になるほど大きく、10倍以上の差が現れることも珍しくありません。<a href="../img/rwtest2.png">テスト結果</a>は、マルチ セクタ書き込み(W:16K, 32 sectors)がシングル セクタ書き込み(W:100, 1 sector)よりどの程度速いかを明確に示しています。大容量メディアほどシングル セクタ書き込みが遅くなる点もまた重要です。書き込みトランザクションの回数はまた、メディアの寿命にも影響してきます。つまり、同じ量のデータを書き込む場合、図6上のシングル セクタ書き込みは、図6下のマルチ セクタ書き込みに比べて16倍早くフラッシュ メモリ メディアを消耗させてしまうということです。</p>
<p>このように、アプリケーションはなるべく大きなブロック(クラスタ サイズまたは2の累乗セクタ境界にアライメントした)で読み書きを行う必要があります。もちろん、アプリケーションからメディアに至る全てのレイヤがマルチ セクタ転送に対応していないと意味がありません。残念ながら、既存のオープン ソースのドライバの多くはマルチ セクタ転送に未対応です。なお、FatFsモジュールおよびサンプル ドライバはマルチ セクタ転送に対応しています。</p>
<h4>明示的なメモリ消去</h4> <h4>明示的なメモリ消去</h4>
<p>通常のファイル消去では、記録されたデータに対して何らかの制御が行われるわけではなく、単にFAT上に未使用クラスタとして記録されているだけです。このため、ファイルが消去されたあともそれらは有効なメモリ・ブロックとしてフラッシュメモリ上に残ります。そこで、ファイルを消去するとき、占有していたデータセクタを明示的に消去(つまり未使用ブロックにする)することにより、メディア内の空きブロックを増やすことができます。これにより、次にそのブロックに書き込むときの消去動作が無くなり、書き込み性能が向上する可能性があります。また、ウェアレベリングに使えるブロックが増え、メディアの耐久性も向上するかも知れません。この機能を有効にするには、構成オプションの<tt>_USE_ERASE</tt>に1を設定します。これはフラッシュメモリ・メディアの内部動作に期待した制御なので、効果があるとは限りません。また、ファイル消去の時間が延びることも考慮に入れるべきです。</p> <p>通常のファイル消去では、記録されたデータに対して何らかの処理が行われるわけではなく、単にFAT上にその領域を未使用と記録しているだけです。このため、ファイルが消去されたあともそれらは有効なデータ ブロックとしてフラッシュ メモリ上に残ります。そこで、ファイルを消去するとき、占有していたデータ セクタを明示的に消去(つまり未使用ブロックにする)することにより、メディア内の空きブロックを増やすことができます。これにより、次にそのブロックに書き込むときの消去動作が無くなり、書き込み性能が向上する可能性があります。また、ウェアレベリングに使えるブロックが増え、メディアの耐久性も向上するかも知れません。この機能を有効にするには、<tt><a href="config.html#use_trim">_USE_TRIM</a></tt>に1を設定します。これはフラッシュ メモリ ドライブの内部動作に期待した制御なので、効果があるとは限りません。また、ファイル消去の時間が延びることも考慮に入れるべきです。</p>
</div> </div>
<div class="para" id="critical"> <div class="para doc" id="critical">
<h3>クリチカルセクション</h3> <h3>クリチカル セクション</h3>
<p>ストレージ上のFAT構造を操作している途中で、停電、不正なメディアの取り外し、回復不能なデータエラー等の障害が発生すると、処理が中途半端な状態で中断され、その結果としてFATボリュームの構造が破壊される可能性があります。次にFatFsモジュールにおけるクリチカルセクションと、その間の障害により起きうるエラーの状態を示します。</p> <p>ストレージ上のFAT構造を操作している途中で、停電、不正なメディアの取り外し、回復不能なデータ エラー等の障害が発生すると、処理が中途半端な状態で中断され、その結果としてFATボリュームの構造が破壊される可能性があります。次にFatFsモジュールにおけるクリチカル セクションと、その間の障害により起きうるエラーの状態を示します。</p>
<div class="lset"> <div class="lset">
図4. 長いクリチカルセクション<br> 図4. 長いクリチカル セクション<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">
</div> </div>
<div class="lset"> <div class="lset">
図5. 最小化したクリチカルセクション<br> 図5. 最小化したクリチカル セクション<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>赤で示したセクションを実行中に障害が発生した場合、クロスリンクが発生して操作対象のファイルディレクトリが失われる可能性があります。黄色で示したセクションを実行中に障害が発生した場合、つぎのうちいずれかまたは複数の結果が生じる可能性があります。</p> <p>赤で示したセクションを実行中に中断が発生した場合、クロス リンクが発生して操作のファイルディレクトリが失われる可能性があります。黄色で示したセクションを実行中に中断が発生した場合、のうちいずれかまたは複数の結果が生じる可能性があります。</p>
<ul> <ul>
<li>書き換え中のファイルのデータが破壊される。</li> <li>ファイルの一部を書き換え中: 書き換えが中途半端な状態となり、結果データが破壊される。</li>
<li>追記中のファイルがオープン前の状態に戻る。</li> <li>追記モードでデータ記録中: ファイルが記録開始の前の状態に戻る。</li>
<li>新規作成されたファイルが消える。</li> <li>新規作成したファイルに記録中: そのファイルが消える。</li>
<li>新規または上書きで作成されたファイルの長さがゼロになって残る。</li> <li>新規または上書きで作成したファイルに記録中: ファイルの長さがゼロになって残る。</li>
<li>ロストチェーンの発生によりボリュームの利用効率が悪化する。</li> <li>これらの障害の結果、ロスト クラスタが発生してボリュームの利用効率が悪化する。</li>
</ul> </ul>
<p>いずれも書き込み中や操作の対象でないファイルには影響はありません。これらのクリチカルセクションは、ファイルを書き込みモードで開いている時間を最小限にするか、<tt>f_sync()</tt>を適宜使用することで図5のようにリスクを最小化することができます。</p> <p>いずれの場合も操作の対象でないファイルには影響はありません。これらのクリチカル セクションは、ファイルを書き込みモードで開いている時間を最小限にするか、<tt>f_sync</tt>関数を適宜使用することで図5のようにリスクを最小化することができます。</p>
</div> </div>
<div class="para" id="fs3"> <div class="para doc" id="fs3">
<h3>APIの拡張的使用例</h3> <h3>APIの拡張的使用例</h3>
<p>FatFs APIの拡張的使用例です。有用なコードがあった場合は、随時追加していきます。。</p> <p>FatFs APIの拡張的使用例です。有用なコードがあった場合は、随時追加していきます。。</p>
<ol> <ol>
<li><a href="../img/app1.c">追記モードでのオープン/新規作成</a></li> <li><a href="../img/app1.c">追記モードでのオープン/新規作成</a></li>
<li><a href="../img/app2.c">ディレクトリを空にする</a></li> <li><a href="../img/app2.c">ディレクトリを空にする</a></li>
<li><a href="../img/app3.c">ファイルに連続領域を割り当てる</a></li> <li><a href="../img/app3.c">ファイルに連続領域を割り当てる</a>(R0.11a以前)</li>
<li><a href="../img/app4.c">ディスクI/Oモジュールの機能/互換性チェッカー</a></li> <li><a href="../img/app4.c">ディスクI/Oモジュールの機能/互換性チェッカー</a></li>
<li><a href="../img/mkfatimg.zip">FATイメージ作成ツール</a></li>
</ol> </ol>
</div> </div>
<div class="para" id="license"> <div class="para doc" id="license">
<h3>FatFsのライセンスについて</h3> <h3>FatFsのライセンスについて</h3>
<p>ソース・ファイルのヘッダにライセンス条件が記述されているので、利用の際はそれに従うこと。英語を読めない方のために以下に日本語訳を示しておきます。</p> <p>FatFsは、作者(ChaN)の個人プロジェクトとして開発されています。現在のリビジョンにおいてコントリビューターはいないため、作者の書いたソース コード以外は含まれません。ソース ファイルにライセンス条件が記述されているので、利用の際はそれに従うこと。原文は英語ですが、参考までに以下に日本語訳を示しておきます。</p>
<pre>/*----------------------------------------------------------------------------/ <pre>
/ FatFs - FAT file system module R0.10a (C)ChaN, 2014 /*----------------------------------------------------------------------------/
/ FatFs - FAT file system module R0.12 (C)ChaN, 2016
/-----------------------------------------------------------------------------/ /-----------------------------------------------------------------------------/
/ FatFsモジュールは、小規模な組み込みシステム向けの汎用FATファイルシステム・ / FatFsモジュールはフリーソフトウェアで、次に示す条件の下に公開されています。
/ モジュールです。これはフリー・ソフトウェアとして、教育・研究・開発のために
/ 以下のライセンス・ポリシーの下で公開されています。
/ /
/ Copyright (C) 2014, ChaN, all right reserved. / Copyright (C) 2016, ChaN, all right reserved.
/ /
/ * FatFsモジュールはフリー・ソフトウェアであり、また<em>無保証です</em> / 1. ソースコードで再配布するときは、その中に上記の著作権表示、この条文、および
/ * 用途に制限はありません。<em>あなたの責任の下において</em>、個人的・非営利的な / 次の免責事項を保持すること
/ ものから商用製品の開発に及ぶ目的に使用・改変・再配布することができます。
/ * ソース・コードを再配布するときは、上記の著作権表示を保持しなければなりません。
/ /
/-----------------------------------------------------------------------------/</pre> / このソフトウェアは、著作権者らおよびコントリビューターらによって<em>現状のまま</em>
<p>要するにFatFsはタダで自由に使えるということです。ソース・コードを再配布するときは、このブロックをそのまま保持しておくこと。このようにFatFsはBSDライクなライセンスとしていますが、一つ大きな違いがあります。特に組み込み用途での利用価値を高めるため、バイナリ形式(ソース・コードを含まない形式全て)での再配布については、条件は設けていません。その場合は、FatFsおよびそのライセンス文書についてはドキュメントに明記してもしなくてもかまいません。これは、一条項BSDライセンスと等価ということです。もちろんGNU GPLプロジェクトとも共存可能です。何らかの変更を加えて再配布する際は、矛盾しない他のライセンス(GNU GPLや修正BSDライセンスなど)に変更することも可能です。</p> / 提供されており、<em>いかなる保証もありません</em>
/ 著作権者もコントリビューターも、このソフトウェアの使用により発生するいかなる
/ 損害についても、<em>責任を負いません</em>
/----------------------------------------------------------------------------*/
</pre>
<p>このようにFatFsはBSDライクなライセンスとしていますが、一つ大きな違いがあります。FatFsは主に組み込み向けとして開発されたため、バイナリ形式(ソース コードを含まない形式全て)での再配布については、商用での使いやすさを考慮して配布時の条件を設けていません。つまり、バイナリ配布の場合は、FatFsおよびそのライセンス文書についてドキュメントに明記してもしなくてもかまいません。これは、一条項BSDライセンスと等価ということです。もちろん、GNU GPLなどほとんど全てのオープン ソース ライセンスの下のプロジェクトにおいて共存可能です。FatFsからフォークを作成し公開する場合は、矛盾しない他のオープン ソース ライセンス(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>
+15 -15
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/chdir.html"> <link rel="alternate" hreflang="en" title="English" href="../en/chdir.html">
@@ -13,25 +13,25 @@
<div class="para func"> <div class="para func">
<h2>f_chdir</h2> <h2>f_chdir</h2>
<p>カレントディレクトリを変更します。</p> <p>カレント ディレクトリを変更します。</p>
<pre> <pre>
FRESULT f_chdir ( FRESULT f_chdir (
const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] ディレクトリ名へのポインタ */</span> const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] ディレクトリ名へのポインタ */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<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>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p> <p>
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
@@ -49,33 +49,33 @@ FRESULT f_chdir (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>各ボリュームのカレントディレクトリを変更します。カレントディレクトリはファイル・システム・オブジェクトの初期化が行われたとき、ルートディレクトリに設定されます。カレントディレクトリは、ファイルシステムオブジェクトに保持されるため、そのボリュームを使用する全てのタスクに対して影響を与えます。</p> <p>各ボリュームのカレント ディレクトリを変更します。カレント ディレクトリは、そのボリュームのマウント動作が行われたとき、ルート ディレクトリに初期設定されます。カレント ディレクトリは、ファイル システム オブジェクトに保持されるため、そのボリュームを使用する全てのタスクに対して影響を与えます。</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p><tt>_FS_RPATH == 1</tt>のときに使用可能となります。</p> <p><tt>_FS_RPATH == 1</tt>のときに使用可能となります。</p>
</div> </div>
<div class="para exa"> <div class="para exa">
<h4>使用例</h4> <h4>使用例</h4>
<pre> <pre>
<span class="c">/* カレントドライブのカレントディレクトリを変更 (ルート下のdir1へ) */</span> <span class="c">/* カレント ドライブのカレント ディレクトリを変更 (ルート下のdir1へ) */</span>
f_chdir("/dir1"); f_chdir("/dir1");
<span class="c">/* ドライブ2のカレントディレクトリを変更 (親ディレクトリへ) */</span> <span class="c">/* ドライブ2のカレント ディレクトリを変更 (親ディレクトリへ) */</span>
f_chdir("2:.."); f_chdir("2:..");
</pre> </pre>
</div> </div>
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<p><tt><a href="chdrive.html">f_chdrive</a></tt></p> <p><tt><a href="chdrive.html">f_chdrive</a></tt></p>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+11 -11
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/chdrive.html"> <link rel="alternate" hreflang="en" title="English" href="../en/chdrive.html">
@@ -13,25 +13,25 @@
<div class="para func"> <div class="para func">
<h2>f_chdrive</h2> <h2>f_chdrive</h2>
<p>カレントドライブを変更します。</p> <p>カレント ドライブを変更します。</p>
<pre> <pre>
FRESULT f_chdrive ( FRESULT f_chdrive (
const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] 対象ドライブを指定します */</span> const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] 対象ドライブを指定します */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>path</dt> <dt>path</dt>
<dd>カレントドライブに設定する<a href="filename.html">論理ドライブ番号</a>を指定するパス名を指定します。</dd> <dd>カレント ドライブに設定する<a href="filename.html">論理ドライブ番号</a>を指定するパス名を指定します。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p> <p>
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#id">FR_INVALID_DRIVE</a> <a href="rc.html#id">FR_INVALID_DRIVE</a>
@@ -40,19 +40,19 @@ FRESULT f_chdrive (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>カレントドライブを変更します。システム起動時の初期値は0です。この設定はFatFsモジュールの静的変数に記録されるため、全てのタスクに対して影響を与えます。</p> <p>カレント ドライブを変更します。システム起動時の初期値はドライブ0です。この設定はFatFsモジュールの静的変数に記録されるため、全てのタスクに対して影響を与えます。</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p><tt>_FS_RPATH == 1</tt>で、且つ<tt>_VOLUMES &gt; 1</tt>のときに使用可能となります。</p> <p><tt>_FS_RPATH == 1</tt>で、且つ<tt>_VOLUMES &gt; 1</tt>のときに使用可能となります。</p>
</div> </div>
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<p><tt><a href="chdir.html">f_chdir</a></tt></p> <p><tt><a href="chdir.html">f_chdir</a></tt></p>
</div> </div>
+20 -20
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/chmod.html"> <link rel="alternate" hreflang="en" title="English" href="../en/chmod.html">
@@ -13,39 +13,39 @@
<div class="para func"> <div class="para func">
<h2>f_chmod</h2> <h2>f_chmod</h2>
<p>ファイルまたはサブディレクトリの属性を変更します。</p> <p>ファイルまたはサブ ディレクトリの属性を変更します。</p>
<pre> <pre>
FRESULT f_chmod ( FRESULT f_chmod (
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] オブジェクト名へのポインタ */</span> const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] オブジェクト名へのポインタ */</span>
BYTE <span class="arg">attr</span>, <span class="c">/* [IN] 設定値 */</span> BYTE <span class="arg">attr</span>, <span class="c">/* [IN] 設定値 */</span>
BYTE <span class="arg">mask</span> <span class="c">/* [IN] 変更マスク */</span> BYTE <span class="arg">mask</span> <span class="c">/* [IN] 変更マスク */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<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>attr</dt> <dt>attr</dt>
<dd>設定する属性。指定可能な属性は次の通りで、これらの組み合わせで指定します。指定されなかった属性は解除されます。<br> <dd>設定する属性。指定可能な属性は次の通りで、これらの組み合わせで指定します。指定されなかった属性は解除されます。<br>
<table class="lst"> <table class="lst">
<tr><th></th><th>意味</th></tr> <tr><th></th><th>意味</th></tr>
<tr><td>AM_RDO</td><td>リードオンリー</td></tr> <tr><td>AM_RDO</td><td>リード オンリー</td></tr>
<tr><td>AM_ARC</td><td>アーカイブ</td></tr> <tr><td>AM_ARC</td><td>アーカイブ</td></tr>
<tr><td>AM_SYS</td><td>システム</td></tr> <tr><td>AM_SYS</td><td>システム</td></tr>
<tr><td>AM_HID</td><td>ヒドゥン</td></tr> <tr><td>AM_HID</td><td>ヒドゥン</td></tr>
</table> </table>
</dd> </dd>
<dt>mask</dt> <dt>mask</dt>
<dd>変更する属性のマスク。指定した属性が設定または解除され、指定されなかった属性は状態が保持されます。<tt class="arg">attr</tt>と同じ値を使います。</dd> <dd>変更する属性のマスク。指定した属性が設定または解除され、指定されなかった属性は状態が保持されます。<tt class="arg">attr</tt>と同じ値を使います。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p> <p>
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
@@ -65,19 +65,19 @@ FRESULT f_chmod (
<div class="para comp"> <div class="para comp">
<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>
</div> </div>
<div class="para use"> <div class="para use">
<h4>使用例</h4> <h4>使用例</h4>
<pre> <pre>
<span class="c">/* リードオンリーをセット、アーカイブをクリア、その他は変更しない */</span> <span class="c">/* リードオンリーをセット、アーカイブをクリア、その他は変更しない */</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>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+13 -14
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/close.html"> <link rel="alternate" hreflang="en" title="English" href="../en/close.html">
@@ -13,30 +13,29 @@
<div class="para func"> <div class="para func">
<h2>f_close</h2> <h2>f_close</h2>
<p>ファイルを閉じます。</p> <p>ファイルを閉じます。</p>
<pre> <pre>
FRESULT f_close ( FRESULT f_close (
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイルオブジェクトへのポインタ */</span> FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル オブジェクトへのポインタ */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>fp</dt> <dt>fp</dt>
<dd>閉じようとするファイルのファイルオブジェクト構造体へのポインタを指定します。</dd> <dd>閉じようとするファイルのファイル オブジェクト構造体へのポインタを指定します。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p> <p>
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>, <a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>, <a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#tm">FR_TIMEOUT</a> <a href="rc.html#tm">FR_TIMEOUT</a>
</p> </p>
@@ -44,23 +43,23 @@ FRESULT f_close (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>ファイルを閉じます。何らかの書き込みの行われたファイルの場合、キャッシュされた状態(リード/ライトバッファ上のデータ、変更されたFATやディレクトリ項目)はディスクに書き戻されます。関数が正常終了すると、そのファイルオブジェクトは無効になり、そのメモリも解放できます。</p> <p>ファイルを閉じます。何らかの書き込みの行われたファイルの場合、キャッシュされた状態(リード/ライト バッファ上のデータ、変更されたFATやディレクトリ項目)はディスクに書き戻されます。関数が正常終了すると、そのファイル オブジェクトは無効になり、そのメモリも解放できます。</p>
<p>ファイルオブジェクトが読み出し専用モードで、<tt>_FS_LOCK</tt>オプションが選択されていない場合は、ファイルを閉じずにファイルオブジェクトを破棄することもできます。しかし、これは将来の互換性の点で推奨はされません。</p> <p>ファイル オブジェクトが読み出し専用モードで、<tt>_FS_LOCK</tt>オプションが選択されていない場合は、ファイルを閉じずにファイル オブジェクトを破棄することもできます。しかし、これは将来の互換性の点で推奨はされません。</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p>全ての構成で使用可能です。</p> <p>全ての構成で使用可能です。</p>
</div> </div>
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="write.html">f_write</a>, <a href="sync.html">f_sync</a>, <a href="sfile.html">FIL</a>, <a href="sfatfs.html">FATFS</a></tt> <tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="write.html">f_write</a>, <a href="sync.html">f_sync</a>, <a href="sfile.html">FIL</a>, <a href="sfatfs.html">FATFS</a></tt>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+13 -13
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/close.html"> <link rel="alternate" hreflang="en" title="English" href="../en/close.html">
@@ -13,25 +13,25 @@
<div class="para func"> <div class="para func">
<h2>f_closedir</h2> <h2>f_closedir</h2>
<p>ディレクトリを閉じます。</p> <p>ディレクトリを閉じます。</p>
<pre> <pre>
FRESULT f_closedir ( FRESULT f_closedir (
DIR* <span class="arg">dp</span> <span class="c">/* [IN] ディレクトリオブジェクトへのポインタ */</span> DIR* <span class="arg">dp</span> <span class="c">/* [IN] ディレクトリ オブジェクトへのポインタ */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>dp</dt> <dt>dp</dt>
<dd>閉じようとするディレクトリのディレクトリオブジェクト構造体へのポインタを指定します。</dd> <dd>閉じようとするディレクトリのディレクトリ オブジェクト構造体へのポインタを指定します。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p> <p>
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#ie">FR_INT_ERR</a>, <a href="rc.html#ie">FR_INT_ERR</a>,
@@ -42,23 +42,23 @@ FRESULT f_closedir (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>ディレクトリを閉じます。関数が正常終了すると、そのディレクトリオブジェクトは無効になり、そのメモリも解放できます。</p> <p>ディレクトリを閉じます。関数が正常終了すると、そのディレクトリ オブジェクトは無効になり、そのメモリも解放できます。</p>
<p><tt>_FS_LOCK</tt>オプションが選択されていない場合は、この処理を行わずにディレクトリオブジェクトを破棄することもできます。しかし、これは将来の互換性の点で推奨はされません。</p> <p><tt>_FS_LOCK</tt>オプションが選択されていない場合は、この処理を行わずにディレクトリ オブジェクトを破棄することもできます。しかし、これは将来の互換性の点で推奨はされません。</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p><tt>_FS_MINIMIZE &lt;= 1</tt>のとき使用可能になります。</p> <p><tt>_FS_MINIMIZE &lt;= 1</tt>のとき使用可能になります。</p>
</div> </div>
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<tt><a href="opendir.html">f_opendir</a>, <a href="readdir.html">f_readdir</a>, <a href="sdir.html">DIR</a></tt> <tt><a href="opendir.html">f_opendir</a>, <a href="readdir.html">f_readdir</a>, <a href="sdir.html">DIR</a></tt>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+209
View File
@@ -0,0 +1,209 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/config.html">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<style type="text/css" media="screen" title="ELM Default">
div.doc h3 {margin-top: 4em }
div.doc h4 {margin-top: 2em }
</style>
<title>FatFs - 構成オプション</title>
</head>
<body>
<h1>構成オプション</h1>
<p>FatFsには多くの構成オプションがあり、それぞれのプロジェクトの要求に応じて柔軟に機能を構成することができます。構成オプションは、<tt>ffconf.h</tt>に記述されます。</p>
<div class="para doc" id="func">
<h3>基本機能の設定</h3>
<h4 id="fs_readonly">_FS_READONLY</h4>
<p>0:リード/ライト or 1:リード オンリ。リード オンリ構成では、<tt>f_write</tt><tt>f_sync</tt><tt>f_unlink</tt><tt>f_mkdir</tt><tt>f_chmod</tt><tt>f_rename</tt><tt>f_truncate</tt><tt>f_getfree</tt>の基本API関数およびオプションの書き込み系API関数が削除されます。</p>
<h4 id="fs_minimize">_FS_MINIMIZE</h4>
<p>基本API関数を段階的に削除します。</p>
<table class="lst1">
<tr><th></th><th>解説</th></tr>
<tr><td>0</td><td>全ての基本API関数が利用可能。</td></tr>
<tr><td>1</td><td><tt>f_stat</tt><tt>f_getfree</tt><tt>f_unlink</tt><tt>f_mkdir</tt><tt>f_chmod</tt><tt>f_utime</tt><tt>f_truncate</tt><tt>f_rename</tt>関数が削除される。</td></tr>
<tr><td>2</td><td>1に加え、<tt>f_opendir</tt><tt>f_readdir</tt><tt>f_closedir</tt>関数が削除される。</td></tr>
<tr><td>3</td><td>2に加え、<tt>f_lseek</tt>関数が削除される。</td></tr>
</table>
<h4 id="use_strfunc">_USE_STRFUNC</h4>
<p>文字列入出力API関数<tt>f_gets</tt>, <tt>f_putc</tt>, <tt>f_puts</tt> and <tt>f_printf</tt>の構成。</p>
<table class="lst1">
<tr><th></th><th>解説</th></tr>
<tr><td>0</td><td>文字列入出力API関数を使用しない。</td></tr>
<tr><td>1</td><td>文字列入出力API関数を使用する。データのLF-CRLF変換はしない。</td></tr>
<tr><td>2</td><td>文字列入出力API関数を使用する。データのLF-CRLF変換をする。</td></tr>
</table>
<h4 id="use_find">_USE_FIND</h4>
<p>フィルタ付きディレクトリ読み出し機能の構成(0:無効 または 1:有効)。有効にすると、<tt>f_findfirst</tt><tt>f_findnext</tt>関数が利用可能になります。<tt>_FS_MINIMIZE</tt>は、1以下でなければなりません。</p>
<h4 id="use_mkfs">_USE_MKFS</h4>
<p>ボリューム作成機能の構成(0:無効 または 1:有効)。有効にすると<tt>f_mkfs</tt>関数が利用可能になります。</p>
<h4 id="use_fastseek">_USE_FASTSEEK</h4>
<p>高速シーク機能の構成(0:無効 または 1:有効)。有効にすると、<tt>f_lseek</tt><tt>f_read</tt><tt>f_write</tt>関数において高速化モードが利用可能になります。詳しくは、<a href="lseek.html">こちら</a>を参照してください。</p>
<h4 id="use_expand">_USE_EXPAND</h4>
<p>連続領域割り当て機能の構成(0:無効 または 1:有効)。有効にすると<tt>f_expand</tt>関数が利用可能になります。<tt>_FS_READONLY</tt>は0でなければなりません。</p>
<h4 id="use_chmod">_USE_CHMOD</h4>
<p>メタデータ操作機能の構成(0:無効 または 1:有効)。有効にすると、<tt>f_chmod</tt><tt>f_utime</tt>関数が利用可能になります。<tt>_FS_READONLY</tt>は0でなければなりません。</p>
<h4 id="use_label">_USE_LABEL</h4>
<p>ボリューム ラベル操作機能の構成(0:無効 または 1:有効)。有効にすると、<tt>f_getlabel</tt><tt>f_setlabel</tt>関数(<tt>_FS_READONLY == 0</tt>のとき)が利用可能になります。</p>
<h4 id="use_forward">_USE_FORWARD</h4>
<p>ストリーミング読み出し機能の構成(0:無効 または 1:有効)。これと<tt>_FS_TINY</tt>を1にすることで<tt>f_forward</tt>関数が利用可能になります。</p>
</div>
<div class="para doc" id="name">
<h3>名前空間とロケールの設定</h3>
<h4 id="code_page">_CODE_PAGE</h4>
<p>パス名等の文字列データのコード ページを指定します。不適切な設定は、ファイル オープン エラーの原因になる可能性があります。拡張文字が全く使われない場合は、どれを選んでも同じです。</p>
<table class="lst1">
<tr><th></th><th>解説</th></tr>
<tr><td>1</td><td>ASCII (非LFN構成でのみ有効)</td></tr>
<tr><td>437</td><td>U.S.</td></tr>
<tr><td>720</td><td>Arabic</td></tr>
<tr><td>737</td><td>Greek</td></tr>
<tr><td>771</td><td>KBL</td></tr>
<tr><td>775</td><td>Baltic</td></tr>
<tr><td>850</td><td>Latin 1</td></tr>
<tr><td>852</td><td>Latin 2</td></tr>
<tr><td>855</td><td>Cyrillic</td></tr>
<tr><td>857</td><td>Turkish</td></tr>
<tr><td>860</td><td>Portuguese</td></tr>
<tr><td>861</td><td>Icelandic</td></tr>
<tr><td>862</td><td>Hebrew</td></tr>
<tr><td>863</td><td>Canadian French</td></tr>
<tr><td>864</td><td>Arabic</td></tr>
<tr><td>865</td><td>Nordic</td></tr>
<tr><td>866</td><td>Russian</td></tr>
<tr><td>869</td><td>Greek 2</td></tr>
<tr><td>932</td><td>日本語 (DBCS)</td></tr>
<tr><td>936</td><td>簡体字中国語 (DBCS)</td></tr>
<tr><td>949</td><td>韓国語 (DBCS)</td></tr>
<tr><td>950</td><td>繁体字中国語 (DBCS)</td></tr>
</table>
<h4 id="use_lfn">_USE_LFN</h4>
<p>LFN(長いファイル名)対応を設定します。LFN機能を有効にするときは、Unicode操作関数<tt>option/unicode.c</tt>をプロジェクトに加える必要があります。また、LFN操作のワーク エリアとして<tt>(_MAX_LFN + 1) * 2</tt>バイト(exFAT構成時はさらに608バイト)を使用します。このため、バッファをスタックに確保するときは、スタック オーバ フローに注意する必要があります。ヒープに確保するときは、メモリ操作関数(<tt>ff_memalloc</tt><tt>ff_memfree</tt>(<tt>option/syscall.c</tt>にサンプルあり))をプロジェクトに加える必要があります。</p>
<table class="lst1">
<tr><th></th><th>解説</th></tr>
<tr><td>0</td><td>LFN機能を使わない。8.3形式の名前のみ使用可能。</td></tr>
<tr><td>1</td><td>LFN機能を使う。ワーク エリアは静的に確保。常にスレッド セーフではない。</td></tr>
<tr><td>2</td><td>LFN機能を使う。ワーク エリアはスタックに確保。</td></tr>
<tr><td>3</td><td>LFN機能を使う。ワーク エリアはヒープに確保。</td></tr>
</table>
<h4 id="max_lfn">_MAX_LFN</h4>
<p>LFN操作バッファのサイズを文字単位で指定(12~255)します。LFN機能が無効のときは意味を持ちません。</p>
<h4 id="lfn_unicode">_LFN_UNICODE</h4>
<p>ファイルAPI上におけるUnicode対応機能を設定します。非LFN構成のときは、0でなければなりません。LFN構成のときに1を選択すると、ファイルAPI上の文字列データ<tt>TCHAR</tt>型の定義が切り替わり、パス名等にUnicodeを使用するようになります。この機能は、文字列入出力関数にも影響します。詳しくは、<a href="filename.html#uni">こちら</a>を参照してください。</p>
<h4 id="strf_encode">_STRF_ENCODE</h4>
<p>Unicode API構成のとき、文字列入出力関数、<tt>f_gets</tt><tt>f_putc</tt><tt>f_puts</tt><tt>f_printf</tt>、におけるファイル上のエンコーディングを指定します。非Unicode API構成のときは意味を持ちません。</p>
<table class="lst1">
<tr><th></th><th>解説</th></tr>
<tr><td>0</td><td>ANSI/OEM</td></tr>
<tr><td>1</td><td>UTF-16LE</td></tr>
<tr><td>2</td><td>UTF-16BE</td></tr>
<tr><td>3</td><td>UTF-8</td></tr>
</table>
<h4 id="fs_rpath">_FS_RPATH</h4>
<p>相対パス機能を設定します。この機能は、ディレクトリ読み出し関数の出力にも影響します。詳しくは、<a href="filename.html#nam">こちら</a>を参照してください。</p>
<table class="lst1">
<tr><th></th><th>解説</th></tr>
<tr><td>0</td><td>相対パス機能を使わない。パス名は常にルート ディレクトリから辿る。</td></tr>
<tr><td>1</td><td>相対パス機能を使う。<tt>f_chdir</tt><tt>f_chdrive</tt>関数が利用可能になる。</td></tr>
<tr><td>2</td><td>1に加え、<tt>f_getcwd</tt>関数が利用可能になる。</td></tr>
</table>
</div>
<div class="para doc" id="volume">
<h3>ボリューム/物理ドライブの設定</h3>
<h4 id="volumes">_VOLUMES</h4>
<p>利用するボリューム(論理ドライブ)の数を1~9の範囲で設定します。</p>
<h4 id="str_volume_id">_STR_VOLUME_ID</h4>
<p>文字列ボリュームIDの設定(0:無効 または 1:有効)。パス名中のボリュームIDに数字に加え任意の文字列も使用できるようにするオプションです。ボリュームID文字列は<tt>_VOLUME_STRS</tt>で定義します。</p>
<h4 id="volume_strs">_VOLUME_STRS</h4>
<p>ボリュームID文字列を定義します。<tt>_VOLUMES</tt>で設定された個数の文字列を<tt>"RAM","SD","CF",...</tt> のように挙列します。使用可能な文字はA~Zおよび0~9で、先頭の項目が論理ドライブ0に対応します。</p>
<h4 id="multi_partition">_MULTI_PARTITION</h4>
<p>マルチ区画機能の設定(0:無効 または 1:有効)。無効のときは、個々の論理ドライブは同じ番号の物理ドライブに1:1で対応し、それぞれの物理ドライブ中の最初の区画に結びつけられます。マルチ区画機能を有効にすると、論理ドライブはそれぞれ任意の物理ドライブの任意の区画に結びつけることができます。マッピングは、ユーザ定義の変換テーブル<tt>VolToPart[]</tt>によって行います。また、<tt>f_fdisk</tt>関数が利用可能になります。詳しくは、<a href="filename.html#vol">こちら</a>を参照してください。</p>
<h4 id="max_ss">_MIN_SS、_MAX_SS</h4>
<p>使用する物理ドライブのセクタ サイズ(データの読み書きの最小単位)を設定します。有効な値は、512、1024、2048、4096です。<tt>_MIN_SS</tt>は最小サイズ、<tt>_MAX_SS</tt>は最大サイズを設定します。メモリ カードやハードディスクでは、常に両方に512を設定しますが、オンボード メモリや一部の光学メディアでは大きな値を設定する必要があるかも知れません。<tt>_MAX_SS &gt; _MIN_SS</tt>に設定したときは可変セクタ サイズ構成となり、<tt>disk_ioctl</tt>関数には<tt>GET_SECTOR_SIZE</tt>コマンドを実装する必要があります。</p>
<h4 id="use_trim">_USE_TRIM</h4>
<p>ATA-TRIM機能の使用の設定(0:無効 または 1:有効)。この機能を有効にしたときは、<tt>disk_ioctl</tt>関数に<tt>CTRL_TRIM</tt>コマンドを実装するべきです。</p>
<h4 id="fs_nofsinfo">_FS_NOFSINFO</h4>
<p>FAT32ボリュームのFSINFOの使用の設定(0~3)。FAT32ボリュームで必ず正確な空き容量を取得する必要があるとき、設定値のビット0をセットすると<tt>f_getfree</tt>関数はFSINFOの情報を使わずに全FATスキャンを行って空き容量を得ます。ビット1は最終割り当てクラスタ番号の利用の制御です。</p>
<table class="lst1">
<tr><th></th><th>解説</th></tr>
<tr><td>bit0=0</td><td>FSINFOの空きクラスタ情報が有効なときはそれを利用する。</td></tr>
<tr><td>bit0=1</td><td>FSINFOの空きクラスタ情報を利用しない。</td></tr>
<tr><td>bit1=0</td><td>FSINFOの最終割り当てクラスタ番号が有効なときはそれを利用する。</td></tr>
<tr><td>bit1=1</td><td>FSINFOの最終割り当てクラスタ番号を利用しない。</td></tr>
</table>
</div>
<div class="para doc" id="system">
<h3>システムの設定</h3>
<h4 id="fs_tiny">_FS_TINY</h4>
<p>ファイル データ転送バッファの構成(0:ノーマル または 1:タイニ)。タイニ構成では、ファイル オブジェクト<tt>FIL</tt>内のプライベート セクタ バッファが削除され、<tt>_MAX_SS</tt>バイト小さくなります。ファイル データの転送には、代わりにファイル システム オブジェクト<tt>FATFS</tt>内のボリューム共有セクタ バッファが使われます。</p>
<h4 id="fs_exfat">_FS_EXFAT</h4>
<p>exFATのサポート(0:使用しない または 1:使用する)。exFATを使用するには、LFN機能を有効にしなければなりません。また、exFATの完全サポートのためには、<tt>_LFN_UNICODE = 1</tt><tt>_MAX_LFN = 255</tt>の設定が推奨されます。exFAT機能では64-bit整数を使用するため、これを有効にするとC89(ANSI C)互換が失われます。</p>
<h4 id="fs_nortc">_FS_NORTC</h4>
<p>RTC機能の使用の設定(0:使用する または 1:使用しない)。システムがRTC(カレンダ時計)をサポートしない場合は、1をセットします。この場合、FatFsが変更を加えたオブジェクトのタイムスタンプはデフォルトの日時を持ちます。RTCが使用可能なときは、0を設定し、<tt>get_fattime</tt>関数をプロジェクトに加えます。リード オンリ構成ではこのオプションは意味を持ちません。</p>
<h4 id="nortc_time">_NORTC_MON、_NORTC_MDAY、_NORTC_YEAR</h4>
<p>デフォルト日時の設定。<tt>_FS_NORTC</tt>が1のとき、固定して与えられる日付を指定します。<tt>_FS_NORTC</tt>が0のとき、およびリード オンリ構成ではこれらのオプションは意味を持ちません。</p>
<h4 id="fs_lock">_FS_LOCK</h4>
<p>ファイル ロック機能の設定。このオプションは、開かれたオブジェクトに対する不正な操作の制御機能を設定します。リード オンリ構成では0に設定しなければなりません。なお、ファイル ロック機能はリエントランシーとは関係ありません。</p>
<table class="lst1">
<tr><th></th><th>解説</th></tr>
<tr><td>0</td><td>ファイル ロック機能を使わない。ボリュームの破損を防ぐため、アプリケーションは不正なファイル操作を避けなければならない。</td></tr>
<tr><td>&gt;0</td><td>ファイル ロック機能を使う。数値は同時にオープンできるファイルやサブ ディレクトリの数を設定します。</td></tr>
</table>
<h4 id="fs_reentrant">_FS_REENTRANT</h4>
<p>リエントランシーの設定(0:無効 または 1:有効)。このオプションは、FatFsモジュール自体のリエントランシー(スレッド セーフ)の設定をします。異なるボリュームに対するファイル アクセスはこのオプションに関係なく常にリエントラントで、<tt>f_mount</tt><tt>f_mkfs</tt><tt>f_fdisk</tt>などのボリューム操作関数はこのオプションに関係なく常にリエントラントではありません。同じボリュームに対するファイル アクセス(つまり、ファイル システム オブジェクトの排他使用)のみがこのオプションの制御下にあります。このオプションを有効にしたときは、同期関数である<tt>ff_req_grant</tt><tt>ff_rel_grant</tt><tt>ff_del_syncobj</tt><tt>ff_cre_syncobj</tt>をプロジェクトに追加する必要があります。サンプルが<tt>option/syscall.c</tt>にあります。</p>
<h4 id="fs_timeout">_FS_TIMEOUT</h4>
<p>タイムアウト時間の設定。待ち合わせ時間が長いときに<tt>FR_TIMEOUT</tt>でファイル関数をアボートする時間を設定します。<tt>_FS_REENTRANT</tt>が0のときは意味を持ちません。</p>
<h4 id="sync_t">_SYNC_t</h4>
<p>O/S定義の同期オブジェクトの型を設定します。例: <tt>HANDLE</tt><tt>ID</tt><tt>OS_EVENT*</tt><tt>SemaphoreHandle_t</tt>など。また、O/S機能のヘッダ ファイルを<tt>ff.c</tt>のスコープ内にインクルードする必要があります。<tt>_FS_REENTRANT</tt>が0のときは意味を持ちません。</p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>
+11 -11
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/dinit.html"> <link rel="alternate" hreflang="en" title="English" href="../en/dinit.html">
@@ -13,34 +13,34 @@
<div class="para func"> <div class="para func">
<h2>disk_initialize</h2> <h2>disk_initialize</h2>
<p>ディスク・ドライブを初期化します。</p> <p>ストレージ デバイスを初期化します。</p>
<pre> <pre>
DSTATUS disk_initialize ( DSTATUS disk_initialize (
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] 物理ドライブ番号 */</span> BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] 物理ドライブ番号 */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>pdrv</dt> <dt>pdrv</dt>
<dd>初期化する物理ドライブ番号(0-9)が指定されます。</dd> <dd>対象のデバイスを識別する物理ドライブ番号(0-9)が指定されます。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p>この関数は戻り値としてディスクステータスを返します。ディスクステータスの詳細に関しては<tt><a href="dstat.html">disk_status()</a></tt>を参照してください。</p> <p>この関数は戻り値としてディスク ステータスを返します。ディスク ステータスの詳細に関しては<a href="dstat.html"><tt>disk_status</tt></a>関数を参照してください。</p>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>ディスク・ドライブを初期化します。関数が成功すると、戻り値の<tt>STA_NOINIT</tt>フラグがクリアされます。</p> <p>ストレージ デバイスを初期化し、データの読み書きなど全ての動作が可能な状態にします。関数が成功すると、戻り値の<tt>STA_NOINIT</tt>フラグがクリアされます。</p>
<p><em>FatFsを使用中はアプリケーションからはこの関数を呼び出してはなりません。さもないと、FATボリュームが破壊されます。エラー等により再初期化が必要なときは、<tt>f_mount()</tt>を使用してください。</em>FatFsモジュールは、自動マウント動作により、必要に応じてこの関数を呼び出します。</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>
</body> </body>
</html> </html>
+53 -23
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/dioctl.html"> <link rel="alternate" hreflang="en" title="English" href="../en/dioctl.html">
@@ -13,56 +13,86 @@
<div class="para func"> <div class="para func">
<h2>disk_ioctl</h2> <h2>disk_ioctl</h2>
<p>セクタの読み書き以外のディスク・ドライブ自体に対する様々な制御をます。</p> <p>一般的なデータ読み書き以外のストレージ デバイス自体に対する様々な制御を行います。</p>
<pre> <pre>
DRESULT disk_ioctl ( DRESULT disk_ioctl (
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span> BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
BYTE <span class="arg">cmd</span>, <span class="c">/* [IN] 制御コマンド */</span> BYTE <span class="arg">cmd</span>, <span class="c">/* [IN] 制御コマンド */</span>
void* <span class="arg">buff</span> <span class="c">/* [I/O] データ受け渡しバッファ */</span> void* <span class="arg">buff</span> <span class="c">/* [I/O] データ受け渡しバッファ */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>pdrv</dt> <dt>pdrv</dt>
<dd>物理ドライブ番号(0-9)が指定されます。</dd> <dd>対象のデバイスを識別する物理ドライブ番号(0-9)が指定されます。</dd>
<dt>cmd</dt> <dt>cmd</dt>
<dd>制御コマンドコードが指定されます。</dd> <dd>制御コマンド コードが指定されます。</dd>
<dt>buff</dt> <dt>buff</dt>
<dd>制御コマンドに依存したパラメータを授受するバッファを指すポインタが指定されます。ータの授受のないコマンドの場合は、値に意味はありません。</dd> <dd>制御コマンドに依存したパラメータを授受するバッファを指すポインタが指定されます。パラメータの授受のないコマンドの場合は、値に意味はありません。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<dl class="ret"> <dl class="ret">
<dt>RES_OK (0)</dt> <dt>RES_OK (0)</dt>
<dd>正常終了。</dd> <dd>正常終了。</dd>
<dt>RES_ERROR</dt> <dt>RES_ERROR</dt>
<dd>何らかのエラーが発生した。</dd> <dd>何らかのエラーが発生した。</dd>
<dt>RES_PARERR</dt> <dt>RES_PARERR</dt>
<dd>コマンドが不正。</dd> <dd>コマンドが不正。</dd>
<dt>RES_NOTRDY</dt> <dt>RES_NOTRDY</dt>
<dd>ドライブが動作可能状態ではない、または初期化されていない。</dd> <dd>ドライブが動作可能状態ではない、または初期化されていない。</dd>
</dl> </dl>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>物理ドライブの種類によりサポートされるコマンドは異なりますが、FatFsモジュールは、次の汎用コマンドのみ使用し、特定のハードウェアに依存した制御は行いません。</p> <p>ストレージ デバイスの種類によりサポートされるコマンドは異なりますが、FatFsモジュール自体は、次の汎用コマンドのみ使用し、特定のデバイスに依存した制御は行いません。</p>
<table class="lst"> <table class="lst">
<tr><th>コマンド</th><th>解説</th></tr> <caption>標準ioctlコマンド</caption>
<tr><td>CTRL_SYNC</td><td>ドライブ内のデータ書き込み処理の完了待ち。ライト・バック・キャッシュなどが存在する場合は、書き込まれていないデータを即時書き戻します。リード・オンリー構成では使用されません。</td></tr> <tr><th>コマンド</th><th>解説</th></tr>
<tr><td>GET_SECTOR_COUNT</td><td><tt class="arg">buff</tt>の指す<tt>DWORD</tt>型変数にドライブ上の総セクタ数を返します。<tt>f_mkfs()</tt>内で呼び出され、作成するボリュームのサイズを決定するために使用されます</td></tr> <tr><td>CTRL_SYNC</td><td>デバイスのデータ書き込み処理を完了させます。ドライバがライト バック キャッシュなどを持っている場合は、書き込まれていないデータを即時書き込みます。メディア上への書き込みがそれぞれ<tt>disk_write</tt>関数の中で完了する場合は、このコマンドに対してすることはありません</td></tr>
<tr><td>GET_SECTOR_SIZE</td><td><tt class="arg">buff</tt>の指す<tt>WORD</tt>型変数にドライブのセクタ・サイズを返します。有効値は512、1024、2048または4096です。セクタ・サイズ固定構成(<tt>_MAX_SS ==_MIN_SS</tt>)のときはこのコマンドは使われることはなく、そのセクタ・サイズで動作しなければなりません</td></tr> <tr><td>GET_SECTOR_COUNT</td><td>総セクタ数の取得。<tt class="arg">buff</tt>の指す<tt>DWORD</tt>型変数にドライブ上の総セクタ数を返します。<tt>f_mkfs, f_fdisk</tt>関数内から呼び出され、作成するボリュームのサイズを決定するために使用されます</td></tr>
<tr><td>GET_BLOCK_SIZE</td><td><tt class="arg">buff</tt>の指す<tt>DWORD</tt>型変数にフラッシュ・メモリの消去ブロック・サイズ(セクタ単位)を返します。1から32768の範囲で2の累乗の値でなければなりません。不明な場合またはフラッシュ・メモリ以外のメディアでは1を返します。<tt>f_mkfs()</tt>内でのみ使用され、ボリュームのデータ領域はこの境界にアライメントされます</td></tr> <tr><td>GET_SECTOR_SIZE</td><td>セクタ サイズの取得。セクタ サイズ可変(<tt>_MAX_SS &gt; _MIN_SS</tt>)のとき、<tt>disk_initailize</tt>関数の成功に続き呼び出されるので、<tt class="arg">buff</tt>の指す<tt>WORD</tt>型変数に現在のセクタ サイズを返します。有効値は512、1024、2048または4096です。セクタ サイズ固定(<tt>_MAX_SS == _MIN_SS</tt>)のときはこのコマンドは使われることはなく、デバイスは常にそのセクタ サイズで動作しなければなりません</td></tr>
<tr><td>CTRL_ERASE_SECTOR</td><td>フラッシュ・メモリ上の指定領域の消去<tt class="arg">buff</tt>の指す<tt>DWORD</tt>配列には消去する領域 {開始セクタ,終了セクタ} を指定して呼び出されます。<tt>_USE_ERASE</tt>が1のとき、クラスタが解放されるときに呼び出されます。これは、ATAコマンド・セットのTrimコマンドと等価で、この機能をサポートしない場合は何もする必要はありません。また、戻り値はチェックされず、消去が完全に行われなかったとしてもFatFsの動作には影響ありません</td></tr> <tr><td>GET_BLOCK_SIZE</td><td>消去ブロック サイズの取得<tt class="arg">buff</tt>の指す<tt>DWORD</tt>変数にフラッシュ メモリの消去ブロック サイズ(セクタ単位)を返します。1から32768の範囲で2の累乗の値でなければなりません。ブロック サイズ不明またはフラッシュ メモリ以外のデバイスでは1を返します。<tt>f_mkfs</tt>関数内でのみ使用され、作成されるボリュームのデータ領域はこの境界にアライメントされます</td></tr>
<tr><td>CTRL_TRIM</td><td>不必要セクタの通知。<tt class="arg">buff</tt>の指す<tt>DWORD</tt>型配列には不必要になった領域 {開始セクタ,終了セクタ} を指定して呼び出されます。TRIM機能が有効(<tt>_USE_TRIM == 1</tt>)で、クラスタが解放されるとき、およびフォーマット時に呼び出されます。これは、ATAコマンド セットのTrimコマンドと等価で、この機能をサポートしないデバイスは何もする必要はありません。また、戻り値はチェックされず、結果によってFatFsの動作が影響を受けることはありません。</td></tr>
</table>
<p>FatFs自体はデバイス依存コマンドやユーザ定義コマンドは一切使用しませんが、アプリケーションから何らかのデバイス制御が行えると便利なことがあります。アプリケーション上で標準以外の制御が必要なときは、必要に応じてユーザ定義コマンドを追加して利用するとよいでしょう。次にコマンドの例を示します。</p>
<table class="lst">
<caption>ユーザ定義ioctlコマンドの例</caption>
<tr><th>コマンド</th><th>解説</th></tr>
<tr><td>CTRL_FORMAT</td><td>メディアの物理フォーマットを行います。<tt class="arg">buff</tt>はNULLでないとき、進行表示のためのコールバック関数のアドレスを示します。</td></tr>
<tr><td>CTRL_POWER_IDLE</td><td>デバイスをアイドル状態にします。通常の読み書き要求でアクティブ状態に戻るなら、<tt>STA_NOINIT</tt>フラグをセットする必要はありません。</td></tr>
<tr><td>CTRL_POWER_OFF</td><td>デバイスをシャットダウン状態にします。<tt>STA_NOINIT</tt>はセットされます。デバイスは<tt>disk_initialize</tt>関数でアクティブ状態に戻ります。</td></tr>
<tr><td>CTRL_LOCK</td><td>ユーザによるメディアの取り出しを禁止します。</td></tr>
<tr><td>CTRL_UNLOCK</td><td>ユーザによるメディアの取り出しを許可します。</td></tr>
<tr><td>CTRL_EJECT</td><td>メディアを排出します。完了後、<tt>STA_NOINIT</tt><tt>STA_NODISK</tt>フラグはセットされます。</td></tr>
<tr><td>MMC_GET_TYPE</td><td>カード タイプを示すフラグ(b0:MMCv3, b1:SDv1, b2:SDv2+, b3:LBA)を<tt class="arg">buff</tt>の示す<tt>BYTE</tt>変数に読み出します。(MMC/SDカード専用)</td></tr>
<tr><td>MMC_GET_CSD</td><td>CSDレジスタの内容を<tt class="arg">buff</tt>の示す16バイトのバッファに読み出します。(MMC/SDカード専用)</td></tr>
<tr><td>MMC_GET_CID</td><td>CIDレジスタの内容を<tt class="arg">buff</tt>の示す16バイトのバッファに読み出します。(MMC/SDカード専用)</td></tr>
<tr><td>MMC_GET_OCR</td><td>OCRレジスタの内容を<tt class="arg">buff</tt>の示す4バイトのバッファに読み出します。(MMC/SDカード専用)</td></tr>
<tr><td>MMC_GET_SDSTAT</td><td>SD STATUSレジスタの内容を<tt class="arg">buff</tt>の示す64バイトのバッファに読み出します。(SDカード専用)</td></tr>
<tr><td>ATA_GET_REV</td><td>リビジョン コードを<tt class="arg">buff</tt>の示す16バイトのバッファに読み出します。(ATA/CFカード専用)</td></tr>
<tr><td>ATA_GET_MODEL</td><td>モデル コードを<tt class="arg">buff</tt>の示す40バイトのバッファに読み出します。(ATA/CFカード専用)</td></tr>
<tr><td>ATA_GET_SN</td><td>シリアル番号を<tt class="arg">buff</tt>の示す20バイトのバッファに読み出します。(ATA/CFカード専用)</td></tr>
<tr><td>ISDIO_READ</td><td><tt class="arg">buff</tt>の示すコマンド構造体に従いiSDIOレジスタからデータを読み出します。(FlashAir専用)</td></tr>
<tr><td>ISDIO_WRITE</td><td><tt class="arg">buff</tt>の示すコマンド構造体に従いiSDIOレジスタにデータを書き込みます。(FlashAir専用)</td></tr>
<tr><td>ISDIO_MRITE</td><td><tt class="arg">buff</tt>の示すコマンド構造体に従いiSDIOレジスタの一部のビットを書き換えます。(FlashAir専用)</td></tr>
</table> </table>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <div class="para comp">
<h4>対応情報</h4>
<p>リード オンリー構成で、かつセクタ サイズ固定構成のときは、この関数は必要とされません。</p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+25 -22
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/dread.html"> <link rel="alternate" hreflang="en" title="English" href="../en/dread.html">
@@ -13,57 +13,60 @@
<div class="para func"> <div class="para func">
<h2>disk_read</h2> <h2>disk_read</h2>
<p>ドライブからセクタを読み出します。</p> <p>ストレージ デバイスからデータを読み出します。</p>
<pre> <pre>
DRESULT disk_read ( DRESULT disk_read (
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span> BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
BYTE* <span class="arg">buff</span>, <span class="c">/* [OUT] 読み出しバッファへのポインタ */</span> BYTE* <span class="arg">buff</span>, <span class="c">/* [OUT] 読み出しバッファへのポインタ */</span>
DWORD <span class="arg">sector</span>, <span class="c">/* [IN] 読み出し開始セクタ番号 */</span> DWORD <span class="arg">sector</span>, <span class="c">/* [IN] 読み出し開始セクタ番号 */</span>
UINT <span class="arg">count</span> <span class="c">/* [IN] 読み出すセクタ数 */</span> UINT <span class="arg">count</span> <span class="c">/* [IN] 読み出すセクタ数 */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>pdrv</dt> <dt>pdrv</dt>
<dd>物理ドライブ番号(0-9)が指定されます。</dd> <dd>対象のデバイスを識別する物理ドライブ番号(0-9)が指定されます。シングル ドライブ システムでは、常に0が指定されます。</dd>
<dt>buff</dt> <dt>buff</dt>
<dd>ディスクから読み出したデータを格納する<em>バイト配列</em>で、読み出されるバイト数分のサイズが必要です。</dd> <dd>ストレージ デバイスから読み出したデータを格納する<em>バイト配列</em>が指定されます。</dd>
<dt>sector</dt> <dt>sector</dt>
<dd>読み出しを開始するセクタ番号。LBAで指定されます。</dd> <dd>読み出しを開始するセクタ番号。32ビットLBAで指定されます。</dd>
<dt>count</dt> <dt>count</dt>
<dd>読み出すセクタ数。 1~128の範囲の値で指定されます。一般的に、複数セクタの転送要求はデバイスに対して可能な限りマルチ・セクタ転送しなければなりません。複数のシングル・セクタ読み出しに分解した場合、スループットが低下することがあります。</dd> <dd>読み出すセクタ数(1以上の値)が指定されます。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<dl class="ret"> <dl class="ret">
<dt>RES_OK (0)</dt> <dt>RES_OK (0)</dt>
<dd>正常終了。</dd> <dd>正常終了。</dd>
<dt>RES_ERROR</dt> <dt>RES_ERROR</dt>
<dd>読み込み中にエラーが発生し、その回復にも失敗した。</dd> <dd>回復不能なエラーにより、読み出し操作を完了できなかった。</dd>
<dt>RES_PARERR</dt> <dt>RES_PARERR</dt>
<dd>パラメータが不正。</dd> <dd>パラメータが不正。</dd>
<dt>RES_NOTRDY</dt> <dt>RES_NOTRDY</dt>
<dd>ドライブが動作可能状態ではない初期化されていない</dd> <dd>ストレージ デバイスが動作可能状態ではない (初期化されていない)</dd>
</dl> </dl>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p><tt class="arg">buff</tt><tt>BYTE</tt>型なので、指定されるアドレスは<em>常にワード・アライメントされているとは限りません</em>。非アライメント・アドレスへの転送は、<a href="appnote.html#fs1">直接転送</a>において発生することがあります。もしも、ハードウェア上の制約でそのような転送が不可能なときは、この関数内で二段転送するなどして解決するか、または別の方法で対応しなければなりません。次にいくつかの対応方法を示します(いずれか一つでOK)</p> <p>ストレージ デバイスに対するデータの読み書きは、セクタ単位で行われます。FatFsでは512~4096バイトのセクタ サイズをサポートします。固定セクタ サイズ構成(<tt>_MIN_SS == MAX_SS</tt>)のときは、暗黙的にそのセクタ サイズで動作しなければなりません。可変セクタ サイズ構成(<tt>_MIN_SS &lt; MAX_SS</tt>)のときは、<tt>disk_initialize</tt>関数に続いて<tt>disk_ioctl</tt>関数でセクタ サイズを問い合わせてくるので、それに対して正しい値を返す必要があります</p>
<p><tt class="arg">buff</tt><tt>BYTE</tt>型なので、指定されるアドレスは<em>常にワード アライメントされているとは限りません</em>。非アライメント アドレスへの転送は、<a href="appnote.html#fs1">直接転送</a>において発生することがあります。もしも、ハードウェア上の制約でそのような転送が不可能なときは、この関数内で二段転送するなどして解決するか、または別の方法で対応しなければなりません。次にいくつかの対応方法を示します(いずれか一つでOK)。</p>
<ul> <ul>
<li>この関数内で解決する - 推奨</li> <li>この関数内で解決する - 推奨</li>
<li><tt>f_read()</tt>において、セクタ全体を含む転送を避ける - 直接転送が発生しない</li> <li>全ての<tt>f_read()</tt>において、セクタ全体を含む転送を避ける - 直接転送が発生しない</li>
<li><tt>f_read(fp, buff, btr, &amp;br)</tt>において、<tt>(((UINT)buff &amp; 3) == (f_tell(fp) &amp; 3))</tt>を満足させる - <tt class="arg">buff</tt>のワードアライメントが保証される</li> <li><tt>f_read(fp, data, btr, &amp;br)</tt>において、<tt>(((UINT)data &amp; 3) == (f_tell(fp) &amp; 3))</tt>を満足させる - 直接転送での<tt class="arg">buff</tt>のワード アライメントが保証される</li>
</ul> </ul>
<p>一般的に、複数セクタの転送要求は、ストレージ デバイスに対して可能な限りマルチ セクタ転送しなければなりません。複数のシングル セクタ読み出しに分解された場合、スループットが低下することがあります。</p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+12 -12
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/dstat.html"> <link rel="alternate" hreflang="en" title="English" href="../en/dstat.html">
@@ -13,36 +13,36 @@
<div class="para func"> <div class="para func">
<h2>disk_status</h2> <h2>disk_status</h2>
<p>ディスク・ドライブの状態を取得します。</p> <p>ストレージ デバイスの状態を取得します。</p>
<pre> <pre>
DSTATUS disk_status ( DSTATUS disk_status (
BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] 物理ドライブ番号 */</span> BYTE <span class="arg">pdrv</span> <span class="c">/* [IN] 物理ドライブ番号 */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>pdrv</dt> <dt>pdrv</dt>
<dd>ステータスを取得する物理ドライブ番号が指定されます。</dd> <dd>対象のデバイスを識別する物理ドライブ番号(0-9)が指定されます。物理ドライブが1台のときは、常に0になります。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p>物理ドライブの状態を次のフラグの組み合わせ値で返します。</p> <p>現在のストレージ デバイスの状態を次のフラグの組み合わせ値で返します。</p>
<dl class="ret"> <dl class="ret">
<dt>STA_NOINIT</dt> <dt>STA_NOINIT</dt>
<dd>ドライブが初期化されていないことを示すフラグ。システムリセットやメディアの取り外し等でセットされ、<tt>disk_initialize()</tt>の正常終了でクリア、失敗でセットされます。メディア交換は非同期に発生するイベントなので、過去にメディア交換があった場合もこのフラグに反映させる必要があります。FatFsモジュールは、このフラグを参照して自動マウント動作を行うかどうかを判断します。</dd> <dd>デバイスが初期化されていないことを示すフラグ。システム リセットやメディアの取り外し等でセットされ、<tt>disk_initialize</tt>関数の正常終了でクリア、失敗でセットされます。メディア交換は非同期に発生するイベントなので、過去にメディア交換があった場合もこのフラグに反映させる必要があります。FatFsモジュールは、このフラグを参照してマウント動作が必要かどうかを判断します。</dd>
<dt>STA_NODISK</dt> <dt>STA_NODISK</dt>
<dd>メディアが存在しないことを示すフラグ。メディアが取り外されている間はセットされ、セットされている間はクリアされます。固定ディスクでは常にクリアします。なお、このフラグはFatFsモジュールでは参照されません。</dd> <dd>メディアが存在しないことを示すフラグ。メディアが取り外されている間はセットされ、セットされている間はクリアされます。固定ディスクでは常にクリアします。なお、このフラグはFatFsモジュールでは参照されません。</dd>
<dt>STA_PROTECTED</dt> <dt>STA_PROTECT</dt>
<dd>メディアがライトプロテクトされていることを示すフラグ。ライトプロテクト機能をサポートしないときは、常にクリアします。リードオンリ構成では参照されません。</dd> <dd>メディアがライト プロテクトされていることを示すフラグ。ライト プロテクト機能をサポートしないときは、常にクリアします。リード オンリ構成では参照されません。</dd>
</dl> </dl>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+29 -21
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/dwrite.html"> <link rel="alternate" hreflang="en" title="English" href="../en/dwrite.html">
@@ -13,56 +13,64 @@
<div class="para func"> <div class="para func">
<h2>disk_write</h2> <h2>disk_write</h2>
<p>ディスクにデータを書き込みます。</p> <p>ストレージ デバイスにデータを書き込みます。</p>
<pre> <pre>
DRESULT disk_write ( DRESULT disk_write (
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span> BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
const BYTE* <span class="arg">buff</span>, <span class="c">/* [IN] 書き込むデータへのポインタ */</span> const BYTE* <span class="arg">buff</span>, <span class="c">/* [IN] 書き込むデータへのポインタ */</span>
DWORD <span class="arg">sector</span>, <span class="c">/* [IN] 書き込み開始セクタ番号 */</span> DWORD <span class="arg">sector</span>, <span class="c">/* [IN] 書き込み開始セクタ番号 */</span>
UINT <span class="arg">count</span> <span class="c">/* [IN] 書き込むセクタ数 */</span> UINT <span class="arg">count</span> <span class="c">/* [IN] 書き込むセクタ数 */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>pdrv</dt> <dt>pdrv</dt>
<dd>物理ドライブ番号(0-9)が指定されます。</dd> <dd>対象のデバイスを識別する物理ドライブ番号(0-9)が指定されます。</dd>
<dt>buff</dt> <dt>buff</dt>
<dd>ディスクに書き込む<em>バイト配列</em>が指定されます。<em>アドレスは常にワード・アライメントされているとは限りません</em></dd> <dd>ストレージ デバイスに書き込むセクタ データが格納された<em>バイト配列</em>が指定されます。データのバイト数は、セクタ サイズ*<tt class="arg">count</tt>となります</dd>
<dt>sector</dt> <dt>sector</dt>
<dd>書き込みを開始するセクタ番号。LBAで指定されます。</dd> <dd>書き込みを開始するセクタ番号。32ビットLBAで指定されます。</dd>
<dt>count</dt> <dt>count</dt>
<dd>書き込むセクタ数。 1~128の範囲の値で指定されます。一般的に、複数セクタの転送要求はデバイスに対して可能な限りマルチ・セクタ転送しなければなりません。複数のシングル・セクタ書き込みに分解した場合、スループットが極端に低下することがあります。</dd> <dd>書き込むセクタ数(1以上の値)が指定されます。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<dl class="ret"> <dl class="ret">
<dt>RES_OK (0)</dt> <dt>RES_OK (0)</dt>
<dd>正常終了。</dd> <dd>正常終了。</dd>
<dt>RES_ERROR</dt> <dt>RES_ERROR</dt>
<dd>書き込み中にエラーが発生し、その回復にも失敗した。</dd> <dd>回復不能なエラーにより、書き込み操作を完了できなかった。</dd>
<dt>RES_WRPRT</dt> <dt>RES_WRPRT</dt>
<dd>メディアが書き込み禁止状態。</dd> <dd>メディアが書き込み禁止状態。</dd>
<dt>RES_PARERR</dt> <dt>RES_PARERR</dt>
<dd>パラメータが不正。</dd> <dd>パラメータが不正。</dd>
<dt>RES_NOTRDY</dt> <dt>RES_NOTRDY</dt>
<dd>ドライブが動作可能状態ではない初期化されていない</dd> <dd>ストレージ デバイスが動作可能状態ではない (初期化されていない)</dd>
</dl> </dl>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>リード・オンリー構成ではこの関数は必要とされません</p> <p><tt class="arg">buff</tt>に指定されるアドレスは<em>常にワード アライメントされているとは限りません</em>。これについては、<a href="dread.html"><tt>disk_read</tt></a>関数の解説を参照してください</p>
<p><em>FatFsの使用中はアプリケーションからはこの関数を呼び出してはなりません。さもないと、FATボリュームが破壊されます。エラー等により再初期化が必要なときは、<tt>f_mount()</tt>を使用してください。</em>FatFsモジュールは、自動マウント動作により、必要に応じてこの関数を呼び出します。</p> <p>一般的に、複数セクタの転送要求は、デバイスに対して可能な限りマルチ セクタ転送しなければなりません。複数のシングル セクタ書き込みに分解された場合、スループットが著しく低下することがあります。</p>
<p>FatFsはディスク制御レイヤが遅延書き込み機能を持つことも想定しています。この関数から戻るとき、デバイスが書き込みを実行中だったり単にライトバック キャッシュに書き込まれただけなど、必ずしもメディアへの書き込みが完了している必要はありません。ただし、<tt class="arg">buff</tt>のデータは、この関数から戻ると無効となります。書き込み完了の要求は、<a href="dioctl.html"><tt>disk_ioctl</tt></a>関数の<tt>CTRL_SYNC</tt>コマンドによって行われます。このような遅延書き込み機能が実装された場合、書き込みスループットを向上させることができます。</p>
<p><em>アプリケーションからはこの関数を呼び出してはなりません。さもないと、FATボリュームが破壊される可能性があります。</em></p>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <div class="para comp">
<h4>対応情報</h4>
<p>リード オンリー構成(<tt>_FS_READONLY == 1</tt>)ではこの関数は必要とされません。</p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+14 -14
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/eof.html"> <link rel="alternate" hreflang="en" title="English" href="../en/eof.html">
@@ -13,50 +13,50 @@
<div class="para func"> <div class="para func">
<h2>f_eof</h2> <h2>f_eof</h2>
<p>リード/ライトポインタがファイル終端に達しているかどうか調べます。.</p> <p>リード/ライト ポインタがファイル終端に達しているかどうか調べます。.</p>
<pre> <pre>
int f_eof ( int f_eof (
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイルオブジェクト */</span> FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル オブジェクト */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>fp</dt> <dt>fp</dt>
<dd>ファイルオブジェクト構造体へのポインタを指定します。</dd> <dd>ファイル オブジェクト構造体へのポインタを指定します。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p>リード/ライトポインタがファイル終端にあり読み出すデータがない場合は、0以外の値を返します。それ以外のは0を返します。</p> <p>リード/ライト ポインタがファイル終端にあり読み出すデータがない場合は、0以外の値を返します。それ以外のときは0を返します。</p>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>f_eof関数は、現リビジョンではマクロとして実装されています。</p> <p>この関数は、現リビジョンではマクロとして実装されています。ファイル オブジェクトの正当性チェックや排他制御は行いません。</p>
<pre> <pre>
<span class="k">#define</span> f_eof(fp) (((fp)->fptr) == ((fp)->fsize) ? 1 : 0) <span class="k">#define</span> f_eof(fp) ((int)((fp)->fptr == (fp)->fsize))
</pre> </pre>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p>常に使用可能。</p> <p>常に使用可能。</p>
</div> </div>
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p> <p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+14 -14
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/error.html"> <link rel="alternate" hreflang="en" title="English" href="../en/error.html">
@@ -13,50 +13,50 @@
<div class="para func"> <div class="para func">
<h2>f_error</h2> <h2>f_error</h2>
<p>エラー発生の有無を調べます。</p> <p>エラー発生の有無を調べます。</p>
<pre> <pre>
int f_error ( int f_error (
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイルオブジェクト */</span> FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル オブジェクト */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>fp</dt> <dt>fp</dt>
<dd>ファイルオブジェクト構造体へのポインタを指定します。</dd> <dd>ファイル オブジェクト構造体へのポインタを指定します。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p>ファイルが操作中のエラーによって処理が中断されている場合は、0以外の値を返します。それ以外の時は0を返します。</p> <p>そのファイルにおいてハード エラーによって処理が中断されている場合は、0以外の値を返します。それ以外の時は0を返します。</p>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>f_error関数は、現リビジョンではマクロとして実装されています。</p> <p>この関数は、現リビジョンではマクロとして実装されています。ファイル オブジェクトの正当性チェックや排他制御は行いません。</p>
<pre> <pre>
<span class="k">#define</span> f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0) <span class="k">#define</span> f_error(fp) ((fp)->err)
</pre> </pre>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p>常に使用可能。</p> <p>常に使用可能。</p>
</div> </div>
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<p><tt><a href="open.html">f_open</a>, <a href="sfile.html">FIL</a></tt></p> <p><tt><a href="open.html">f_open</a>, <a href="sfile.html">FIL</a></tt></p>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+115
View File
@@ -0,0 +1,115 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="ja" title="English" href="../en/expand.html">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_expand</title>
</head>
<body>
<div class="para func">
<h2>f_expand</h2>
<p>ファイルに連続したデータ領域を割り当てます。</p>
<pre>
FRESULT f_expand (
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] ファイル オブジェクト構造体へのポインタ */</span>
FSIZE_t <span class="arg">fsz</span>, <span class="c">/* [IN] 割り当てサイズ */</span>
BYTE <span class="arg">opt</span> <span class="c">/* [IN] 動作オプション */</span>
);
</pre>
</div>
<div class="para arg">
<h4>Parameters</h4>
<dl class="par">
<dt>fp</dt>
<dd>対象となるファイル オブジェクト構造体へのポインタを指定します。</dd>
<dt>fsz</dt>
<dd>ファイルに割り当てるバイト単位のサイズ。データ型<tt>FSIZE_t</tt>は、<tt>DWORD</tt>(32-bit)または<tt>QWORD</tt>(64-bit)のエリアスで、exFATサポートの有無により切り替わります。</dd>
<dt>opt</dt>
<dd>実際に割り当てを行うかどうか指定するフラグ。</dd>
</dl>
</div>
<div class="para ret">
<h4>Return Values</h4>
<p>
<a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#dn">FR_DENIED</a>,
<a href="rc.html#tm">FR_TIMEOUT</a>
</p>
</div>
<div class="para desc">
<h4>解説</h4>
<p><tt class="arg">opt</tt>に1を指定すると、ファイルに連続したデータ領域を割り当てます。<tt>f_lseek</tt>によるサイズ拡張とは異なり、対象ファイルのサイズは0(つまりデータ領域未割り当て)でなければなりません。リード/ライト ポインタは、ファイルの先頭に留まります。この関数により割り当てられたファイルの内容は未定義なので、それに対して何の前提も持つべきではありません。この関数は、次の理由により<tt>FR_DENIED</tt>で失敗することがあります。</p>
<ul>
<li>ボリューム上に連続した空き領域が見つからなかった。</li>
<li>対象ファイルのサイズが0ではなかった。</li>
<li>ファイルが非書き込みモードで開かれている。</li>
<li>指定されたファイル サイズが無効。(FATボリューム上で &gt;= 4GiB)</li>
</ul>
<p><tt class="arg">opt</tt>に0を指定したときは、連続したデータ領域を探すのみで、その時点ではファイルへの割り当てを行わず、代わりにそれを検索開始ポイントとしてファイル システム オブジェクトにセットします。これにより、そのボリューム上で別の操作(FAT変更を伴う)が行われない限り、書き込まれるファイルは少なくともそのサイズまでは連続性が保証され、遅延無く書き込めることになります。</p>
<p>時間的制約のあるファイル読み書き操作において、連続データ領域を割り当てられたファイルは有利となります。これは、分割されたファイルによりもたらされる無用なランダム アクセスが減ることにより、ファイル システムやストレージ デバイスの処理のオーバーヘッドが削減されるからです。特にexFATボリューム上の連続ファイルでは一切のFATアクセスが発生せず、効率的なシーケンシャル アクセスが行えます。</p>
<p>連続ファイルに対して低レベルI/Oを使用したさらに効率的な直接アクセスも容易に行えますが、これは将来の互換性の点で推奨はされません。</p>
</div>
<div class="para comp">
<h4>対応情報</h4>
<p><tt>_USE_EXPAND == 1</tt>で、かつ<tt>_FS_READONLY == 0</tt>のとき使用可能です。</p>
</div>
<div class="para use">
<h4>使用例</h4>
<pre>
<span class="c">/* 連続ファイルの作成 */</span>
<span class="c">/* 新しいファイルの作成 */</span>
res = f_open(fp = malloc(sizeof (FIL)), "file.dat", FA_WRITE|FA_CREATE_ALWAYS);
if (res) { <span class="c">/* ファイルが開かれたかチェック */</span>
free(fp);
...
}
<span class="c">/* 100 MiB の連続領域を割り当てる */</span>
res = f_expand(fp, 104857600, 1);
if (res) { <span class="c">/* 割り当てられたかチェック */</span>
free(fp);
...
}
<span class="c">/* 連続ファイル作成成功 fp でアクセス可能 */</span>
</pre>
<pre>
<span class="c">/* ファイル システムを介さず直接アクセスする例 */</span>
<span class="c">/* ファイル データの物理的位置を取得 */</span>
drv = fp-&gt;obj.fs-&gt;drv;
sect = fp-&gt;obj.fs-&gt;database + fp-&gt;obj.fs-&gt;csize * (fp-&gt;obj.sclust - 2);
<span class="c">/* ファイル先頭から2048セクタを書き込み */</span>
res = disk_write(drv, buffer, sect, 2048);
</pre>
</div>
<div class="para ref">
<h4>参照</h4>
<p><tt><a href="open.html">f_open</a>, <a href="lseek.html">f_lseek</a>, <a href="sfile.html">FIL</a></tt></p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>
+19 -13
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/fattime.html"> <link rel="alternate" hreflang="en" title="English" href="../en/fattime.html">
@@ -13,7 +13,7 @@
<div class="para func"> <div class="para func">
<h2>get_fattime</h2> <h2>get_fattime</h2>
<p>現在時刻を取得します。</p> <p>現在時刻を取得します。</p>
<pre> <pre>
DWORD get_fattime (void); DWORD get_fattime (void);
</pre> </pre>
@@ -21,31 +21,37 @@ DWORD get_fattime (void);
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p>現在のローカルタイム<tt>DWORD</tt>値にパックされて返されます。ビットフィールドは次に示すようになります。</p> <p>現在のローカル タイム<tt>DWORD</tt>値にパックして返します。ビット フィールドは次に示すようになります。</p>
<dl> <dl>
<dt>bit31:25</dt> <dt>bit31:25</dt>
<dd>1980年を起点とした年 0..127 で入ります</dd> <dd>1980年を起点とした年 0..127 でセット</dd>
<dt>bit24:21</dt> <dt>bit24:21</dt>
<dd> 1..12 の値で入ります</dd> <dd> 1..12 の値でセット</dd>
<dt>bit20:16</dt> <dt>bit20:16</dt>
<dd> 1..31 の値で入ります</dd> <dd> 1..31 の値でセット</dd>
<dt>bit15:11</dt> <dt>bit15:11</dt>
<dd> 0..23 の値で入ります</dd> <dd> 0..23 の値でセット</dd>
<dt>bit10:5</dt> <dt>bit10:5</dt>
<dd> 0..59 の値で入ります</dd> <dd> 0..59 の値でセット</dd>
<dt>bit4:0</dt> <dt>bit4:0</dt>
<dd>秒/2 0..29 の値で入ります。</dd> <dd>秒/2 0..29 の値でセット</dd>
</dl> </dl>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>RTCをサポートしないシステムでも、何らかの日付として有効な値を返さなければなりません。0を返した場合、そのファイルは日付を持ちません。リード・オンリー構成ではこの関数は必要とされません</p> <p>RTCをサポートしないシステムでも、ダミーとして何らかの日付として有効な値を返すべきです。0などを返した場合、そのファイルのタイムスタンプは無効になります</p>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <div class="para comp">
<h4>対応情報</h4>
<p>リード オンリー構成(<tt>_FS_READONLY == 1</tt>)または、非RTCサポート構成(<tt>_RTC_NOUSE == 1</tt>)ではこの関数は必要とされません。</p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+24 -24
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/fdisk.html"> <link rel="alternate" hreflang="en" title="English" href="../en/fdisk.html">
@@ -13,30 +13,30 @@
<div class="para func"> <div class="para func">
<h2>f_fdisk</h2> <h2>f_fdisk</h2>
<p>物理ドライブを分割します。</p> <p>物理ドライブを分割します。</p>
<pre> <pre>
FRESULT f_fdisk ( FRESULT f_fdisk (
BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span> BYTE <span class="arg">pdrv</span>, <span class="c">/* [IN] 物理ドライブ番号 */</span>
const DWORD <span class="arg">part[]</span>, <span class="c">/* [IN] 区画マップテーブル */</span> const DWORD <span class="arg">part[]</span>, <span class="c">/* [IN] 区画マップ テーブル */</span>
void* <span class="arg">work</span> <span class="c">/* [-] ワークエリア */</span> void* <span class="arg">work</span> <span class="c">/* [-] ワークエリア */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>pdrv</dt> <dt>pdrv</dt>
<dd>分割する<em>物理ドライブ</em>のドライブ番号を指定します。</dd> <dd>分割する<em>物理ドライブ</em>のドライブ番号を指定します。</dd>
<dt>part[]</dt> <dt>part[]</dt>
<dd>区画マップテーブルへのポインタを指定します。</dd> <dd>区画マップ テーブルへのポインタを指定します。</dd>
<dt>work</dt> <dt>work</dt>
<dd>ワークエリアへのポインタを指定します。サイズは<tt>_MAX_SS</tt>バイト必要です。</dd> <dd>ワークエリアへのポインタを指定します。サイズは<tt>_MAX_SS</tt>バイト必要です。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p> <p>
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
@@ -47,41 +47,41 @@ FRESULT f_fdisk (
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>説明</h4> <h4>説明</h4>
<p>この関数は、指定された物理ドライブのMBRに区画テーブルを作成します。区画分けは一般的なFDISK形式で行うため、最大4つの基本区画を作成することができます。拡張区画には対応していません。区画マップテーブル<tt class="arg">part[]</tt>にはドライブをどのように分割するか指定して渡します。この配列は4つの項目から成り、先頭の項目が1番目の、最後の項目が4番目の区画のサイズを示します。値が100以下の場合、ドライブの総容量に対する割合をパーセント単位で指定します。100を超える値の場合はセクタ数の直接指定になります。</p> <p>この関数は、指定された物理ドライブのMBRに区画テーブルを作成します。区画分けは一般的なFDISK形式で行うため、最大4つの基本区画を作成することができます。拡張区画には対応していません。区画マップテーブル<tt class="arg">part[]</tt>にはドライブをどのように分割するか指定して渡します。この配列は4つの項目から成り、先頭の項目が1番目の、最後の項目が4番目の区画のサイズを示します。値が100以下の場合、ドライブの総容量に対する割合をパーセント単位で指定します。100を超える値の場合はセクタ数の直接指定になります。</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p><tt>_FS_READOLNY == 0</tt><tt>_USE_MKFS == 1</tt><tt>_MULTI_PARTITION == 1</tt> のとき使用可能です。</p> <p><tt>_FS_READOLNY == 0</tt><tt>_USE_MKFS == 1</tt><tt>_MULTI_PARTITION == 1</tt> のとき使用可能です。</p>
</div> </div>
<div class="para use"> <div class="para use">
<h4>使用例</h4> <h4>使用例</h4>
<pre> <pre>
<span class="c">/* ユーザ定義のボリューム管理テーブル (_MULTI_PARTITION == 1 のとき必要) */</span> <span class="c">/* ユーザ定義のボリューム管理テーブル (_MULTI_PARTITION == 1 のとき必要) */</span>
PARTITION VolToPart[] = { PARTITION VolToPart[] = {
{0, 1}, <span class="c">/* 論理ドライブ 0 ==> 物理ドライブ 0, 第1区画 */</span> {0, 1}, <span class="c">/* 論理ドライブ 0 ==> 物理ドライブ 0, 第1区画 */</span>
{0, 2}, <span class="c">/* 論理ドライブ 1 ==> 物理ドライブ 0, 第2区画 */</span> {0, 2}, <span class="c">/* 論理ドライブ 1 ==> 物理ドライブ 0, 第2区画 */</span>
{1, 0} <span class="c">/* 論理ドライブ 2 ==> 物理ドライブ 1, 自動検出 */</span> {1, 0} <span class="c">/* 論理ドライブ 2 ==> 物理ドライブ 1, 自動検出 */</span>
}; };
</pre> </pre>
<pre> <pre>
<span class="c">/* 新しい物理ドライブ(0)の初期化 */</span> <span class="c">/* 新しい物理ドライブ(0)の初期化 */</span>
FATFS fs; FATFS fs;
DWORD plist[] = {50, 50, 0, 0}; <span class="c">/* 2分割 */</span> DWORD plist[] = {50, 50, 0, 0}; <span class="c">/* 2分割 */</span>
BYTE work[_MAX_SS]; BYTE work[_MAX_SS];
f_fdisk(0, plist, work); <span class="c">/* 物理ドライブ 0 の分割 */</span> f_fdisk(0, plist, work); <span class="c">/* 物理ドライブ 0 の分割 */</span>
f_mount(&amp;fs "0:", 0); f_mount(&amp;fs "0:", 0);
f_mkfs("0:", 0, 0); <span class="c">/* 論理ドライブ 0 のフォーマット. 第二引数は無視される. */</span> f_mkfs("0:", 0, 0); <span class="c">/* 論理ドライブ 0 のフォーマット. 第二引数は無視される. */</span>
f_mount(0, "0:", 0); f_mount(0, "0:", 0);
f_mount(&amp;fs, "1:", 0); f_mount(&amp;fs, "1:", 0);
f_mkfs("1:", 0, 0); <span class="c">/* 論理ドライブ 0 のフォーマット. 第二引数は無視される. */</span> f_mkfs("1:", 0, 0); <span class="c">/* 論理ドライブ 0 のフォーマット. 第二引数は無視される. */</span>
f_mount(0, "1:", 0); f_mount(0, "1:", 0);
</pre> </pre>
+34 -27
View File
@@ -11,35 +11,42 @@
<body> <body>
<h1>パス名のフォーマット</h1> <h1>パス名のフォーマット</h1>
<div class="para" id="nam"> <div class="para doc" id="nam">
<h3>ファイルディレクトリ名</h3> <h3>ファイル ディレクトリ名</h3>
<p>FatFsモジュールでファイル、ディレクトリ、ドライブの指定方法はDOS/Windows APIとほぼ同じです。パス名のフォーマットは次の通りです。</p> <p>FatFsモジュールでは、パス名によるファイル、ディレクトリ、ドライブの指定方法はDOS/Windows APIとほぼ同じです。パス名のフォーマットは次の通りです。</p>
<pre>"[論理ドライブ番号:][/]ディレクトリ名/ファイル名"</pre> <pre>"[論理ドライブ番号:][/]ディレクトリ名/ファイル名"</pre>
<p>FatFsモジュールは長いファイル名(LFN)および8.3形式ファイル名(SFN)に対応しています。LFNは、(<tt>_USE_LFN &gt; 0</tt>)のとき使用可能になります。ディレクトリセパレータにはDOS/Windows APIと同じく<tt>'/'</tt><tt>'\'</tt>を使用します。連続したセパレータは無視され1個として扱われます。唯一の違いは、論理ドライブの指定だけです。論理ドライブ番号は、<tt>'0'</tt><tt>'9'</tt>の一文字の数字とコロンで指定し、省略した場合は<em>デフォルトドライブ</em>(0またはカレントドライブ)が選択されます。</p> <p>FatFsモジュールは長いファイル名(LFN)および8.3形式ファイル名(SFN)に対応しています。LFNは、(<tt><a href="config.html#use_lfn">_USE_LFN</a> &gt; 0</tt>)のとき使用可能になります。ディレクトリ セパレータにはDOS/Windows APIと同じく<tt>'/'</tt><tt>'\'</tt>を使用します。連続したセパレータは無視され1個として扱われます。唯一の違いは、論理ドライブの指定だけです。論理ドライブ番号は、<tt>'0'</tt><tt>'9'</tt>の一文字の数字とコロンで指定し、省略した場合は<em>デフォルト ドライブ</em>(0またはカレント ドライブ)が選択されます。</p>
<p>ヌル文字や制御文字(<tt>'\0'</tt><tt>'\x1F'</tt>)は、パス名の終端として認識されます。パス名に先行あるいは中に含まれるスペースは、LFN構成では名前の一部として有効ですが、非LFN構成ではスペースはパス名の終端として認識されます。</p> <p>ヌル文字や制御文字(<tt>'\0'</tt><tt>'\x1F'</tt>)は、パス名の終端として認識されます。パス名に先行あるいは中に含まれるスペースは、LFN構成では名前の一部として有効ですが、非LFN構成ではスペースはパス名の終端として認識されます。</p>
<p>標準構成(<tt>_FS_RPATH == 0</tt>)のときは、全てのオブジェクトがルートディレクトリから辿る絶対パスで指定されます。OS指向なカレントディレクトリという概念は無く、またドットディレクトリ(&quot;.&quot;&quot;..&quot;)は使用できません。パス名先頭のセパレータは無視されます。デフォルトドライブ番号は常に0になります。</p> <p>標準構成(<tt><a href="config.html#fs_rpath">_FS_RPATH</a> == 0</tt>)のときは、全てのオブジェクトがルート ディレクトリから辿る絶対パスで指定されます。OS指向なカレント ディレクトリという概念は無く、またドット ディレクトリ(<tt>"."</tt><tt>".."</tt>)は使用できません。パス名先頭のセパレータは無視されます。デフォルト ドライブ番号は常に0になります。</p>
<p>相対パスを有効(<tt>_FS_RPATH == 1</tt>)にしたときは、先行するセパレータの有無によって検索開始ディレクトリが変わり、セパレータがある場合はルートディレクトリから、無い場合は<a href="chdir.html"><tt>f_chdir()</tt></a>で設定されるカレントディレクトリからになります。またパス名にドットディレクトリが使用できます。デフォルトドライブ番号は<a href="chdrive.html"><tt>f_chdrive()</tt></a>で設定された値となります。</p> <p>相対パスを有効(<tt>_FS_RPATH &gt;= 1</tt>)にしたときは、先行するセパレータの有無によって検索開始ディレクトリが変わり、セパレータがある場合はルート ディレクトリから、無い場合は<a href="chdir.html"><tt>f_chdir</tt></a>関数で設定されるカレント ディレクトリからになります。またパス名にドット ディレクトリが使用できます。デフォルト ドライブ番号は<a href="chdrive.html"><tt>f_chdrive</tt></a>関数で設定された値となります。</p>
<table class="lst2"> <table class="lst2">
<tr><td>パス名の例</td><td>_FS_RPATH == 0</td><td>_FS_RPATH == 1</td></tr> <tr><td>パス名の例</td><td>_FS_RPATH == 0</td><td>_FS_RPATH &gt;= 1</td></tr>
<tr class="lst3"><td>file.txt</td><td>ドライブ0のルートディレクトリ下のファイル</td><td>カレントドライブのカレントディレクトリ下のファイル</td></tr> <tr class="lst3"><td>file.txt</td><td>ドライブ0のルート ディレクトリ下のファイル</td><td>カレント ドライブのカレント ディレクトリ下のファイル</td></tr>
<tr><td>/file.txt</td><td>ドライブ0のルートディレクトリ下のファイル</td><td>カレントドライブのルートディレクトリ下のファイル</td></tr> <tr><td>/file.txt</td><td>ドライブ0のルート ディレクトリ下のファイル</td><td>カレント ドライブのルート ディレクトリ下のファイル</td></tr>
<tr><td></td><td>ドライブ0のルートディレクトリ</td><td>カレントドライブのカレントディレクトリ</td></tr> <tr><td></td><td>ドライブ0のルート ディレクトリ</td><td>カレント ドライブのカレント ディレクトリ</td></tr>
<tr><td>2:</td><td>ドライブ2のルートディレクトリ</td><td>ドライブ2のカレントディレクトリ</td></tr> <tr><td>2:</td><td>ドライブ2のルート ディレクトリ</td><td>ドライブ2のカレント ディレクトリ</td></tr>
<tr><td>2:file1.txt</td><td>ドライブ2のルートディレクトリ下のファイル</td><td>ドライブ2のカレントディレクトリ下のファイル</td></tr> <tr><td>2:file1.txt</td><td>ドライブ2のルート ディレクトリ下のファイル</td><td>ドライブ2のカレント ディレクトリ下のファイル</td></tr>
<tr><td>2:/</td><td>ドライブ2のルートディレクトリ</td><td>ドライブ2のルートディレクトリ</td></tr> <tr><td>2:/</td><td>ドライブ2のルート ディレクトリ</td><td>ドライブ2のルート ディレクトリ</td></tr>
<tr><td>../file.txt</td><td>無効</td><td>親ディレクトリ下のファイル</td></tr> <tr><td>../file.txt</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>..</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>
<p>また、<tt>_STR_VOLUME_ID</tt>オプションを有効にすることでドライブ番号の識別には数字のほか、任意の文字列を使用することも可能になります。</p> <p>また、<tt><a href="config.html#str_volume_id">_STR_VOLUME_ID</a></tt>オプションを有効にすることでドライブ番号の識別には数字のほか、<tt>"sd:file1.txt"</tt><tt>"ram:swapfile.dat"</tt>のように、任意の文字列を使用することも可能になります。</p>
<p><em>【注意】現リビジョン(R0.12)では、exFATボリューム上においてダブル ドット<tt>".."</tt>はシングル ドット<tt>"."</tt>として機能し、親ディレクトリを辿ることはできません。</em></p>
</div> </div>
<p><br></p> <div class="para doc" id="case">
<div class="para" id="uni"> <h3>使用可能な文字と大文字小文字の識別</h3>
<p>FATファイル システムでファイル名に使用可能な文字は、<tt>09 AZ ! # $ % &amp; ' ( ) - @ ^ _ ` { } ~</tt>および拡張文字(<tt>\x80</tt><tt>\xFF</tt>)となっています。LFN拡張ではこれらに加え、<tt>+ , ; = [ ]</tt>およびスペースが使用可能になり、スペースとピリオドはファイル名の末尾を除く任意の位置に挿入できます。</p>
<p>FATファイル システムでは、パス名についてケース インセンシティブです。たとえば、<tt>file.txt, File.Txt, FILE.TXT</tt>の3つの名前は同じ物として扱われます。これは、ASCII文字だけでなく拡張文字についても適用されます。ファイルが作成される際、SFNエントリには全て大文字に変換された名前が記録されます。LFN対応システムでは、LFNエントリには大文字変換されない名前が記録されます。</p>
<p>古い日本語MS-DOSでは拡張文字(いわゆる全角文字)についてはケース センシティブでした。FatFsモジュールではこれにしたがい、非LFN構成で文字コードにDBCSが選択されたときに限り、拡張文字に対して大文字変換を行わずにSFNエントリに記録および検索されます(日本語MSDOS仕様)。LFN構成では拡張文字についても大文字変換を行います(WindowsNT仕様)。このため、非LFN構成で全角小文字を含む名前でファイルを作成すると、Windowsでそのファイルを開けなくなるなどの互換性問題を起こすので、それらのシステムで相互利用するボリューム上ではDBCS拡張文字の使用は避けるべきです。</p>
</div>
<div class="para doc" id="uni">
<h3>Unicode API</h3> <h3>Unicode API</h3>
<p>ファイル関数の入出力のうちファイル名やパス名を指定する引数の型は、<tt>TCHAR</tt>で定義されていますが、これは通常は<tt>char</tt>のエリアスになっています。そして、<tt>_CODE_PAGE</tt>で指定されるANSI/OEMコード(SBCSまたはDBCS)の文字列として扱われます。ファイル名入出力をUnicodeとする構成(<tt>_LFN_UNICODE == 1</tt>)にしたときは、<tt>TCHAR</tt>はワイド文字(<tt>WCHAR, unsigned short</tt>)に切り替わり、パス名の入出力にUnicodeを使用するようになります。これによりLFN規格に完全対応となり、ANSI/OEMコードにない文字(たとえば ✝☪✡☸☭など)も使用できます。この設定は文字列入出力関数のデータ型とエンコーディングに影響を与えます。リテラル文字列を定義するとき、次に示すように<tt>_T(s)</tt>および<tt>_TEXT(s)</tt>マクロを使ってANSI/OEMとUnicodeを自動切り替えすることができます。</p> <p>ファイル関数の入出力のうちファイル名やパス名を指定する引数の型は、<tt>TCHAR</tt>で定義されていますが、これは通常は<tt>char</tt>のエリアスになっています。そして、<tt><a href="config.html#code_page">_CODE_PAGE</a></tt>で指定されるANSI/OEMコード(SBCSまたはDBCS)の文字列として扱われます。ファイル名入出力をUnicodeとする構成(<tt><a href="config.html#lfn_unicode">_LFN_UNICODE</a> == 1</tt>)にしたときは、<tt>TCHAR</tt>はワイド文字(<tt>WCHAR, unsigned short</tt>)に切り替わり、パス名の入出力にUnicodeを使用するようになります。これによりLFN規格に完全対応となり、ファイル名としてANSI/OEMコードにない文字(たとえば ✝☪✡☸☭など)も使用できます。この設定は文字列入出力関数においては、データ型とファイル上のエンコーディングに影響を与えます。リテラル文字列を定義するとき、次に示すように<tt>_T(s)</tt>および<tt>_TEXT(s)</tt>マクロを使ってANSI/OEMとUnicodeを自動切り替えすることができます。</p>
<pre> <pre>
f_open(fp, "filename.txt", FA_READ); <span class="c">/* ANSI/OEM専用コード */</span> f_open(fp, "filename.txt", FA_READ); <span class="c">/* ANSI/OEM専用コード */</span>
f_open(fp, L"filename.txt", FA_READ); <span class="c">/* Unicode専用コード */</span> f_open(fp, L"filename.txt", FA_READ); <span class="c">/* Unicode専用コード */</span>
@@ -47,11 +54,10 @@
</pre> </pre>
</div> </div>
<p><br></p> <div class="para doc" id="vol">
<div class="para" id="vol">
<h3>ボリューム管理</h3> <h3>ボリューム管理</h3>
<p>デフォルトの構成では、それぞれの論理ドライブは同じ番号の物理ドライブに1:1で結びつけられていて、自動検出機能によりその物理ドライブ上の一つのFATボリュームがマウントされます。FATボリュームの検出は、セクタ0、第一区画、第二区画、第三区画、第四区画の順に行われます。</p> <p>デフォルトの構成では、それぞれの論理ドライブは同じ番号の物理ドライブに1:1で結びつけられていて、自動検出機能によりその物理ドライブ上の一つのFATボリュームがマウントされます。FATボリュームの検出は、セクタ0、第一区画第四区画の順に行われます。</p>
<p><tt>_MULTI_PARTITION</tt>に1を指定すると、それぞれの論理ドライブに対して個別に物理ドライブ番号と区画を指定できるようになります。この構成では、論理ドライブと区画の対応を解決するためのテーブルを次に示すように定義する必要があります。</p> <p><tt><a href="config.html#multi_partition">_MULTI_PARTITION</a></tt>に1を指定すると、それぞれの論理ドライブに対して個別に物理ドライブ番号と区画を指定できるようになります。この構成では、論理ドライブと区画の対応を解決するためのテーブルを次に示すように定義する必要があります。</p>
<pre> <pre>
例:論理ドライブ0~2を物理ドライブ0(非リムーバブル)の3つの基本区画に割り当て、 例:論理ドライブ0~2を物理ドライブ0(非リムーバブル)の3つの基本区画に割り当て、
論理ドライブ3を物理ドライブ1(リムーバブル)に割り当てる場合。 論理ドライブ3を物理ドライブ1(リムーバブル)に割り当てる場合。
@@ -62,15 +68,16 @@ PARTITION VolToPart[] = {
{0, 3}, <span class="c">/* 論理ドライブ 2 ==> 物理ドライブ 0, 第3区画 */</span> {0, 3}, <span class="c">/* 論理ドライブ 2 ==> 物理ドライブ 0, 第3区画 */</span>
{1, 0} <span class="c">/* 論理ドライブ 3 ==> 物理ドライブ 1, 自動検出 */</span> {1, 0} <span class="c">/* 論理ドライブ 3 ==> 物理ドライブ 1, 自動検出 */</span>
}; };
<img src="../img/f7.png" width="828" height="288" alt="論理ドライブと物理ドライブの関係">
</pre> </pre>
<div><img src="../img/f7.png" width="828" height="288" alt="論理ドライブと物理ドライブの関係"></div>
<p>複数区画指定を使用する場合、次の点に注意しなければなりません。 <p>複数区画指定を使用する場合、次の点に注意しなければなりません。
<ul> <ul>
<li>マウント可能な区画は基本区画のみで、拡張区画内には対応しない。</li>
<li>複数のマウントされた区画を持つ物理ドライブは、非リムーバブルでなければならず、システム動作中のメディア交換は禁止。</li> <li>複数のマウントされた区画を持つ物理ドライブは、非リムーバブルでなければならず、システム動作中のメディア交換は禁止。</li>
<li>基本区画のみマウント可能で、拡張区画内の区画には対応しない。</li>
<li>Windowsは、リムーバブル ドライブでは複数区画をサポートせず、先頭区画のみ認識する。</li>
</ul> </ul>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+119
View File
@@ -0,0 +1,119 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/findfirst.html">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_findfirst</title>
</head>
<body>
<div class="para func">
<h2>f_findfirst</h2>
<p>ディレクトリ内のオブジェクトの検索を開始します。</p>
<pre>
FRESULT f_findfirst (
DIR* <span class="arg">dp</span>, <span class="c">/* [OUT] ディレクトリ オブジェクト構造体へのポインタ */</span>
FILINFO* <span class="arg">fno</span>, <span class="c">/* [OUT] ファイル情報構造体へのポインタ */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] ディレクトリ名へのポインタ */</span>
const TCHAR* <span class="arg">pattern</span> <span class="c">/* [IN] マッチ パターン文字列へのポインタ */</span>
);
</pre>
</div>
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>dp</dt>
<dd>空のディレクトリ オブジェクト構造体へのポインタを指定します。</dd>
<dt>fno</dt>
<dd>最初にマッチしたディレクトリ項目を格納するファイル情報構造体へのポインタを指定します。</dd>
<dt>path</dt>
<dd>オープンするディレクトリの<a href="filename.html">パス名</a>を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。</dd>
<dt>pattern</dt>
<dd>検索する名前を示すヌル文字<tt>'\0'</tt>終端の文字列へのポインタを指定します。この文字列は、続く<tt>f_findnext</tt>関数でも参照されるため、一連の処理が終了するまで有効でなければなりません。</dd>
</dl>
</div>
<div class="para ret">
<h4>戻り値</h4>
<p>
<a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#np">FR_NO_PATH</a>,
<a href="rc.html#in">FR_INVALID_NAME</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#id">FR_INVALID_DRIVE</a>,
<a href="rc.html#ne">FR_NOT_ENABLED</a>,
<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,
<a href="rc.html#tm">FR_TIMEOUT</a>,
<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>,
<a href="rc.html#tf">FR_TOO_MANY_OPEN_FILES</a>
</p>
</div>
<div class="para desc">
<h4>解説</h4>
<p><tt class="arg">path</tt>で指定されるディレクトリを開き、そのディレクトリ内の項目の検索を開始します。正常終了すると、ディレクトリ オブジェクト構造体が作成され、最初に検索名文字列に名前がマッチした項目の情報が<tt class="arg">fno</tt>の指定するファイル情報構造体にストアされます。名前のマッチする項目が見つからなかった場合は、<tt>fno-&gt;fname[]</tt>にヌル文字列が返されます。ファイル情報構造体の使い方については、<a href="readdir.html"><tt>f_readdir</tt></a>関数を参照してください。</p>
<p>マッチ パターン文字列は、ワイルドカード文字(<tt>?</tt><tt>*</tt>)を含むことができます。<tt>?</tt>は任意の1文字に、<tt>*</tt>は0文字以上の任意の文字列にマッチします。LFN構成では、SFNとLFN(あれば)の両方に対してテストを行います。現リビジョンではパターン マッチングにおいて次の点で標準システムとは異なる動作となります。</p>
<ul>
<li><tt>"*.*"</tt>は拡張子なしの名前にマッチしない。(標準システムでは全ての名前にマッチ)</li>
<li>ピリオドで終わるパターンは、どの名前にもマッチしない。(標準システムでは拡張子無しの名前にマッチ)</li>
<li><a href="filename.html#case">DBCS拡張文字</a>については、LFN構成でも非Unicode API構成ではケース センシティブとなる。</li>
</ul>
</div>
<div class="para comp">
<h4>対応情報</h4>
<p>この関数は、<a href="opendir.html"><tt>f_opendir</tt></a>関数および<a href="readdir.html"><tt>f_readdir</tt></a>関数のラッパー関数です。<tt>_USE_FIND == 1</tt>で、かつ<tt>_FS_MINIMIZE &lt;= 1</tt>のとき使用可能になります。</p>
</div>
<div class="para use">
<h4>使用例</h4>
<pre>
<span class="c">/* ディレクトリ内のオブジェクトの検索と表示 */</span>
void find_image (void)
{
FRESULT fr; <span class="c">/* 戻り値 */</span>
DIR dj; <span class="c">/* ディレクトリ オブジェクト */</span>
FILINFO fno; <span class="c">/* ファイル情報構造体 */</span>
<span class="k">#if</span> _USE_LFN
char lfn[_MAX_LFN + 1];
fno.lfname = lfn;
fno.lfsize = _MAX_LFN + 1;
<span class="k">#endif</span>
fr = f_findfirst(&amp;dj, &amp;fno, "", "dsc*.jpg"); <span class="c">/* "dsc"で始まるJPEGファイルを検索 */</span>
while (fr == FR_OK &amp;&amp; fno.fname[0]) { <span class="c">/* 見つかる間繰り返し */</span>
<span class="k">#if</span> _USE_LFN
printf("%s %s\n", fno.fname, fno.lfname);<span class="c">/* 見つけた項目の名前を表示 */</span>
<span class="k">#else</span>
printf("%s\n", fno.fname);
<span class="k">#endif</span>
fr = f_findnext(&amp;dj, &amp;fno); <span class="c">/* 次を検索 */</span>
}
f_closedir(&amp;dj);
}
</pre>
</div>
<div class="para ref">
<h4>参照</h4>
<p><tt><a href="findnext.html">f_findnext</a>, <a href="closedir.html">f_closedir</a>, <a href="sdir.html">DIR</a>, <a href="sfileinfo.html">FILINFO</a></tt></p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>
+68
View File
@@ -0,0 +1,68 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="up" title="FatFs" href="../00index_j.html">
<link rel="alternate" hreflang="en" title="English" href="../en/findnext.html">
<link rel="stylesheet" href="../css_j.css" type="text/css" media="screen" title="ELM Default">
<title>FatFs - f_findnext</title>
</head>
<body>
<div class="para func">
<h2>f_findnext</h2>
<p>次にマッチするオブジェクトを検索します。</p>
<pre>
FRESULT f_findnext (
DIR* <span class="arg">dp</span>, <span class="c">/* [IN] ディレクトリ構造体へのポインタ */</span>
FILINFO* <span class="arg">fno</span> <span class="c">/* [OUT] ファイル情報構造体へのポインタ */</span>
);
</pre>
</div>
<div class="para arg">
<h4>引数</h4>
<dl class="par">
<dt>dp</dt>
<dd><tt>f_findfirst</tt>関数で作成された有効なディレクトリ構造体へのポインタを指定します。</dd>
<dt>fno</dt>
<dd>マッチしたディレクトリ項目を格納するファイル情報構造体へのポインタを指定します。</dd>
</dl>
</div>
<div class="para ret">
<h4>戻り値</h4>
<p>
<a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#tm">FR_TIMEOUT</a>,
<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
</p>
</div>
<div class="para desc">
<h4>解説</h4>
<p>次に名前のマッチするディレクトリ項目を検索し、見つかった項目をファイル情報構造体にストアします。名前のマッチする項目が見つからずディレクトリの最後まで達した場合は、<tt>fno-&gt;fname[]</tt>にヌル文字列が返されます。</p>
</div>
<div class="para comp">
<h4>対応情報</h4>
<p>この関数は、<a href="readdir.html"><tt>f_readdir</tt></a>関数のラッパー関数です。<tt>_USE_FIND == 1</tt>で、かつ<tt>_FS_MINIMIZE &lt;= 1</tt>のとき使用可能になります。</p>
</div>
<div class="para ref">
<h4>参照</h4>
<p><tt><a href="findfirst.html">f_findfirst</a>, <a href="closedir.html">f_closedir</a>, <a href="sdir.html">DIR</a>, <a href="sfileinfo.html">FILINFO</a></tt></p>
</div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body>
</html>
+37 -38
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/forward.html"> <link rel="alternate" hreflang="en" title="English" href="../en/forward.html">
@@ -13,39 +13,38 @@
<div class="para func"> <div class="para func">
<h2>f_forward</h2> <h2>f_forward</h2>
<p>ファイルからデータを読み出し、送信ストリームに直接転送します。</p> <p>ファイルからデータを読み出し、送信ストリームに直接転送します。</p>
<pre> <pre>
FRESULT f_forward ( FRESULT f_forward (
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] ファイルオブジェクト構造体 */</span> FIL* <span class="arg">fp</span>, <span class="c">/* [IN] ファイル オブジェクト構造体 */</span>
UINT (*<span class="arg">func</span>)(const BYTE*,UINT), <span class="c">/* [IN] データ転送関数 */</span> UINT (*<span class="arg">func</span>)(const BYTE*,UINT), <span class="c">/* [IN] データ転送関数 */</span>
UINT <span class="arg">btf</span>, <span class="c">/* [IN] 転送するバイト数 */</span> UINT <span class="arg">btf</span>, <span class="c">/* [IN] 転送するバイト数 */</span>
UINT* <span class="arg">bf</span> <span class="c">/* [OUT] 転送されたバイト数 */</span> UINT* <span class="arg">bf</span> <span class="c">/* [OUT] 転送されたバイト数 */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>fp</dt> <dt>fp</dt>
<dd>ファイルオブジェクト構造体へのポインタを指定します。</dd> <dd>ファイル オブジェクト構造体へのポインタを指定します。</dd>
<dt>func</dt> <dt>func</dt>
<dd>データを渡すユーザ定義関数へのポインタを指定します。この関数の仕様はサンプルを参照してください。</dd> <dd>データを渡すユーザ定義関数へのポインタを指定します。この関数の仕様はサンプルを参照してください。</dd>
<dt>btf</dt> <dt>btf</dt>
<dd>転送するバイト数(0~UINTの最大値)を指定します。</dd> <dd>転送するバイト数(0~UINTの最大値)を指定します。</dd>
<dt>bf</dt> <dt>bf</dt>
<dd>実際に転送されたバイト数を格納する変数を指すポインタを指定します。</dd> <dd>実際に転送されたバイト数を格納する変数を指すポインタを指定します。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p> <p>
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>, <a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#de">FR_DENIED</a>, <a href="rc.html#de">FR_DENIED</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>, <a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#tm">FR_TIMEOUT</a> <a href="rc.html#tm">FR_TIMEOUT</a>
@@ -54,40 +53,40 @@ FRESULT f_forward (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>ファイルのデータをバッファに読み出さずに送信ストリームに直接転送します。アプリケーション側でデータバッファを必要としないので、メモリの限られた環境で有効です。リード/ライトポインタは転送されたバイト数だけ進みます。指定されたバイト数の転送中にファイルの終端に達した場合や送信ストリームがビジーになった場合、<tt class="arg">*bf</tt><tt class="arg">btf</tt>よりも小さくなります。</p> <p>ファイルのデータをバッファに読み出さずに送信ストリームに直接転送します。アプリケーション側でデータ バッファを必要としないので、メモリの限られた環境で有効です。リード/ライト ポインタは転送されたバイト数だけ進みます。指定されたバイト数の転送中にファイルの終端に達した場合や送信ストリームがビジーになった場合、<tt class="arg">*bf</tt><tt class="arg">btf</tt>よりも小さくなります。</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p><tt>_USE_FORWARD == 1</tt>で、且つ<tt>_FS_TINY == 1</tt>のときに使用可能です。</p> <p><tt>_USE_FORWARD == 1</tt>で、且つ<tt>_FS_TINY == 1</tt>のときに使用可能です。</p>
</div> </div>
<div class="para use"> <div class="para use">
<h4>使用例(オーディオ再生)</h4> <h4>使用例(オーディオ再生)</h4>
<pre> <pre>
<span class="c">/*-----------------------------------------------------------------------*/</span> <span class="c">/*-----------------------------------------------------------------------*/</span>
<span class="c">/* f_forward関数から呼ばれるデータ送信関数の例 */</span> <span class="c">/* f_forward関数から呼ばれるデータ送信関数の例 */</span>
<span class="c">/*-----------------------------------------------------------------------*/</span> <span class="c">/*-----------------------------------------------------------------------*/</span>
UINT out_stream ( <span class="c">/* 戻り値: 転送されたバイト数またはストリームの状態 */</span> UINT out_stream ( <span class="c">/* 戻り値: 転送されたバイト数またはストリームの状態 */</span>
const BYTE *p, <span class="c">/* 転送するデータを指すポインタ */</span> const BYTE *p, <span class="c">/* 転送するデータを指すポインタ */</span>
UINT btf <span class="c">/* &gt;0: 転送を行う(バイト数). 0: ストリームの状態を調べる */</span> UINT btf <span class="c">/* &gt;0: 転送を行う(バイト数). 0: ストリームの状態を調べる */</span>
) )
{ {
UINT cnt = 0; UINT cnt = 0;
if (btf == 0) { <span class="c">/* センス要求 */</span> if (btf == 0) { <span class="c">/* センス要求 */</span>
<span class="c">/* ストリームの状態を返す (0: ビジー, 1: レディ) */</span> <span class="c">/* ストリームの状態を返す (0: ビジー, 1: レディ) */</span>
<span class="c">/* 一旦、レディを返したら、続く転送要求で少なくとも1バイトは */</span> <span class="c">/* 一旦、レディを返したら、続く転送要求で少なくとも1バイトは */</span>
<span class="c">/* 転送されないと f_forward関数は FR_INT_ERR となる。 */</span> <span class="c">/* 転送されないと f_forward関数は FR_INT_ERR となる。 */</span>
if (FIFO_READY) cnt = 1; if (FIFO_READY) cnt = 1;
} }
else { <span class="c">/* 転送要求 */</span> else { <span class="c">/* 転送要求 */</span>
do { <span class="c">/* 全てのバイトを転送するか、ストリームがビジーになるまで繰り返す */</span> do { <span class="c">/* 全てのバイトを転送するか、ストリームがビジーになるまで繰り返す */</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);
@@ -98,31 +97,31 @@ UINT out_stream ( <span class="c">/*
<span class="c">/*-----------------------------------------------------------------------*/</span> <span class="c">/*-----------------------------------------------------------------------*/</span>
<span class="c">/* f_forward関数の使用例 */</span> <span class="c">/* f_forward関数の使用例 */</span>
<span class="c">/*-----------------------------------------------------------------------*/</span> <span class="c">/*-----------------------------------------------------------------------*/</span>
FRESULT play_file ( FRESULT play_file (
char *fn <span class="c">/* 再生するオーディオファイル名を指すポインタ */</span> char *fn <span class="c">/* 再生するオーディオ ファイル名を指すポインタ */</span>
) )
{ {
FRESULT rc; FRESULT rc;
FIL fil; FIL fil;
UINT dmy; UINT dmy;
<span class="c">/* ファイルを読み出しモードで開く */</span> <span class="c">/* ファイルを読み出しモードで開く */</span>
rc = f_open(&amp;fil, fn, FA_READ); rc = f_open(&amp;fil, fn, FA_READ);
if (rc) return rc; if (rc) return rc;
<span class="c">/* 全てのデータが転送されるかエラーが発生するまで続ける */</span> <span class="c">/* 全てのデータが転送されるかエラーが発生するまで続ける */</span>
while (rc == FR_OK &amp;&amp; fil.fptr &lt; fil.fsize) { while (rc == FR_OK &amp;&amp; !f_eof(&amp;fil)) {
<span class="c">/* ほかの処理... */</span> <span class="c">/* ほかの処理... */</span>
<span class="c">/* 定期的または要求に応じてデータをストリームに送出する */</span> <span class="c">/* 定期的または要求に応じてデータをストリームに送出する */</span>
rc = f_forward(&amp;fil, out_stream, 1000, &amp;dmy); rc = f_forward(&amp;fil, out_stream, 1000, &amp;dmy);
} }
<span class="c">/* ファイルを閉じて戻る */</span> <span class="c">/* ファイルを閉じて戻る */</span>
f_close(&amp;fil); f_close(&amp;fil);
return rc; return rc;
} }
@@ -131,10 +130,10 @@ FRESULT play_file (
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<p><tt><a href="open.html">f_open</a>, <a href="gets.html">fgets</a>, <a href="write.html">f_write</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p> <p><tt><a href="open.html">f_open</a>, <a href="gets.html">fgets</a>, <a href="write.html">f_write</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+15 -14
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/getcwd.html"> <link rel="alternate" hreflang="en" title="English" href="../en/getcwd.html">
@@ -13,28 +13,28 @@
<div class="para func"> <div class="para func">
<h2>f_getcwd</h2> <h2>f_getcwd</h2>
<p>カレントディレクトリを得ます</p> <p>カレント ディレクトリを得ます</p>
<pre> <pre>
FRESULT f_getcwd ( FRESULT f_getcwd (
TCHAR* <span class="arg">buff</span>, <span class="c">/* [OUT] バッファ */</span> TCHAR* <span class="arg">buff</span>, <span class="c">/* [OUT] バッファ */</span>
UINT <span class="arg">len</span> <span class="c">/* [IN] バッファサイズ */</span> UINT <span class="arg">len</span> <span class="c">/* [IN] バッファ サイズ */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>buff</dt> <dt>buff</dt>
<dd>カレントディレクトリの文字列を格納するバッファ</dd> <dd>カレント ディレクトリのパス名文字列を格納するバッファ</dd>
<dt>len</dt> <dt>len</dt>
<dd>TCHAR単位のバッファサイズ</dd> <dd><tt>TCHAR</tt>単位のバッファ サイズ</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p> <p>
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
@@ -49,22 +49,23 @@ FRESULT f_getcwd (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>カレントドライブのカレントディレクトリのフルパス文字列を取得します。<tt>_VOLUMES</tt>が2以上のときは、論理ドライブ番号の付加されたフル・パス名となります。</p> <p>カレント ドライブのカレント ディレクトリのフル パス文字列を取得します。<tt>_VOLUMES</tt>が2以上のときは、論理ドライブ番号の付加されたパス名となります。</p>
<p><em>現リビジョン(R0.12)では、exFATボリューム上ではカレント ディレクトリを得ることが出来ません。常にルート ディレクトリを返します。</em></p>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p><tt>_FS_RPATH == 2</tt>のとき使用可能です。</p> <p><tt>_FS_RPATH == 2</tt>のとき使用可能です。</p>
</div> </div>
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<p><tt><a href="chdrive.html">f_chdrive</a>, <a href="chdir.html">f_chdir</a></tt></p> <p><tt><a href="chdrive.html">f_chdrive</a>, <a href="chdir.html">f_chdir</a></tt></p>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+20 -20
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/getfree.html"> <link rel="alternate" hreflang="en" title="English" href="../en/getfree.html">
@@ -13,31 +13,31 @@
<div class="para func"> <div class="para func">
<h2>f_getfree</h2> <h2>f_getfree</h2>
<p>論理ドライブ上の未使用クラスタ数を取得します。</p> <p>ボリューム上の空き領域のサイズを取得します。</p>
<pre> <pre>
FRESULT f_getfree ( FRESULT f_getfree (
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 対象ドライブを指定します */</span> const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 対象ドライブを指定します */</span>
DWORD* <span class="arg">nclst</span>, <span class="c">/* [OUT] 空きクラスタ数を格納する変数へのポインタ */</span> DWORD* <span class="arg">nclst</span>, <span class="c">/* [OUT] 空きクラスタ数を格納する変数へのポインタ */</span>
FATFS** <span class="arg">fatfs</span> <span class="c">/* [OUT] ファイルシステムオブジェクトを指すポインタへのポインタ */</span> FATFS** <span class="arg">fatfs</span> <span class="c">/* [OUT] ファイル システム オブジェクトを指すポインタへのポインタ */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<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>nclst</dt> <dt>nclst</dt>
<dd>空きクラスタ数を格納する<tt>DWORD</tt>変数へのポインタを指定します。</dd> <dd>空きクラスタ数を格納する<tt>DWORD</tt>変数へのポインタを指定します。</dd>
<dt>fatfs</dt> <dt>fatfs</dt>
<dd>対象ドライブのファイルシステムオブジェクトを指すポインタが返されます。</dd> <dd>対象ドライブのファイル システム オブジェクトを指すポインタが返されます。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p> <p>
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
@@ -52,33 +52,33 @@ FRESULT f_getfree (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>論理ドライブ上の空きクラスタ数を取得します。返されたファイルシステムオブジェクトの<tt>csize</tt>メンバがクラスタあたりのセクタ数を示しているので、これを元に実際の空きサイズが計算できます。FAT32ボリュームにおいては、FSINFOが実際の状態と同期していない場合、不正確な空きサイズを返す可能性があります。この問題を避けるため、<tt>_FS_NOFSINFO</tt>オプションでFSINFOを無視して初回はフルFATスキャンをするように設定することもできます。</p> <p>論理ドライブ上の空き領域のサイズをクラスタ単位で取得します。返されたファイル システム オブジェクトの<tt>csize</tt>メンバがクラスタあたりのセクタ数を示しているので、これを元にセクタ単位の空きサイズが計算できます。FAT32ボリュームにおいては、FSINFOの情報が実際の空きクラスタ数と同期していない場合、不正確なを返す可能性があります。この問題を避けるため、<tt><a href="config.html#fs_nofsinfo">_FS_NOFSINFO</a></tt>オプションでマウント後の初回は必ずフルFATスキャンをするように構成することもできます。</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<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>
</div> </div>
<div class="para use"> <div class="para use">
<h4>使用例</h4> <h4>使用例</h4>
<pre> <pre>
FATFS *fs; FATFS *fs;
DWORD fre_clust, fre_sect, tot_sect; DWORD fre_clust, fre_sect, tot_sect;
<span class="c">/* ドライブ1のボリューム情報と空きクラスタ数を得る */</span> <span class="c">/* ドライブ1のボリューム情報と空きクラスタ数を得る */</span>
res = f_getfree("1:", &amp;fre_clust, &amp;fs); res = f_getfree("1:", &amp;fre_clust, &amp;fs);
if (res) die(res); if (res) die(res);
<span class="c">/* 全セクタ数と空きセクタ数を計算 */</span> <span class="c">/* 全セクタ数と空きセクタ数を計算 */</span>
tot_sect = (fs->n_fatent - 2) * fs->csize; tot_sect = (fs->n_fatent - 2) * fs->csize;
fre_sect = fre_clust * fs->csize; fre_sect = fre_clust * fs->csize;
<span class="c">/* ボリューム全体のサイズと空きサイズを表示 (512バイト/セクタと仮定) */</span> <span class="c">/* ボリュームのサイズと空きサイズを表示 (512バイト/セクタと仮定) */</span>
printf("%10lu KiB total drive space.\n%10lu KiB available.\n", printf("%10lu KiB total drive space.\n%10lu KiB available.\n",
tot_sect / 2, fre_sect / 2); tot_sect / 2, fre_sect / 2);
</pre> </pre>
@@ -86,10 +86,10 @@ FRESULT f_getfree (
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<tt><a href="sfatfs.html">FATFS</a></tt> <tt><a href="sfatfs.html">FATFS</a></tt>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+19 -19
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/getlabel.html"> <link rel="alternate" hreflang="en" title="English" href="../en/getlabel.html">
@@ -13,31 +13,31 @@
<div class="para func"> <div class="para func">
<h2>f_getlabel</h2> <h2>f_getlabel</h2>
<p>ボリュームラベルを取得します。</p> <p>ボリューム ラベルを取得します。</p>
<pre> <pre>
FRESULT f_getlabel ( FRESULT f_getlabel (
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 対象ドライブ */</span> const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 対象ドライブ */</span>
TCHAR* <span class="arg">name</span>, <span class="c">/* [OUT] ボリューム名を格納するバッファ */</span> TCHAR* <span class="arg">label</span>, <span class="c">/* [OUT] ボリューム名を格納するバッファ */</span>
DWORD* <span class="arg">sn</span> <span class="c">/* [OUT] ボリュームシリアル番号を格納する変数 */</span> DWORD* <span class="arg">vsn</span> <span class="c">/* [OUT] ボリューム シリアル番号を格納する変数 */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<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>name</dt> <dt>label</dt>
<dd>ボリューム名を格納する配列へのポインタを指定します。少なくとも12要素のサイズが必要です。ボリューム名がない場合はヌル文字列が返されます。この情報が不要なときはヌルポインタを指定してください。</dd> <dd>ボリューム名を格納する配列へのポインタを指定します。<tt>_LFN_UNICODE == 0</tt>では少なくとも24バイト、<tt>_LFN_UNICODE == 1</tt>では少なくとも12文字のサイズが必要です。ボリューム名がない場合はヌル文字列が返されます。この情報が不要なときはヌル ポインタを指定してください。</dd>
<dt>sn</dt> <dt>vsn</dt>
<dd>ボリュームシリアル番号を格納する<tt>DWORD</tt>変数へのポインタを指定します。この情報が不要なときはヌルポインタを指定してください。</dd> <dd>ボリューム シリアル番号を格納する<tt>DWORD</tt>変数へのポインタを指定します。この情報が不要なときはヌル ポインタを指定してください。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p> <p>
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
@@ -52,31 +52,31 @@ FRESULT f_getlabel (
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p><tt>_USE_LABEL == 1</tt>のときに使用可能です。</p> <p><tt>_USE_LABEL == 1</tt>のときに使用可能です。</p>
</div> </div>
<div class="para use"> <div class="para use">
<h4>使用例</h4> <h4>使用例</h4>
<pre> <pre>
char str[12]; char str[12];
<span class="c">/* デフォルトドライブのボリューム名を得る */</span> <span class="c">/* デフォルト ドライブのボリューム名を得る */</span>
f_getlabel("", str, 0); f_getlabel("", str, 0);
<span class="c">/* ドライブ2のボリューム名を得る */</span> <span class="c">/* ドライブ2のボリューム名を得る */</span>
f_getlabel("2:", str, 0); f_getlabel("2:", str, 0);
</pre> </pre>
</div> </div>
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<tt><a href="setlabel.html">f_setlabel</a></tt> <tt><a href="setlabel.html">f_setlabel</a></tt>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+18 -18
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/gets.html"> <link rel="alternate" hreflang="en" title="English" href="../en/gets.html">
@@ -13,53 +13,53 @@
<div class="para func"> <div class="para func">
<h2>f_gets</h2> <h2>f_gets</h2>
<p>ファイルから文字列を読み出します。</p> <p>ファイルから文字列を読み出します。</p>
<pre> <pre>
TCHAR* f_gets ( TCHAR* f_gets (
TCHAR* <span class="arg">buff</span>, <span class="c">/* [OUT] バッファ */</span> TCHAR* <span class="arg">buff</span>, <span class="c">/* [OUT] バッファ */</span>
int <span class="arg">len</span>, <span class="c">/* [IN] バッファのサイズ */</span> int <span class="arg">len</span>, <span class="c">/* [IN] バッファのサイズ */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイルオブジェクト */</span> FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル オブジェクト */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>buff</dt> <dt>buff</dt>
<dd>文字列を読み出すバッファを指すポインタを指定します。</dd> <dd>文字列を読み出すバッファを指すポインタを指定します。</dd>
<dt>len</dt> <dt>len</dt>
<dd>バッファのサイズを要素数で指定します。</dd> <dd>バッファのサイズを要素数で指定します。</dd>
<dt>fp</dt> <dt>fp</dt>
<dd>ファイルオブジェクト構造体へのポインタを指定します。</dd> <dd>ファイル オブジェクト構造体へのポインタを指定します。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p>関数が成功すると<tt>buff</tt>が返されます。</p> <p>関数が成功すると<tt class="arg">buff</tt>が返されます。</p>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>この関数は<a href="read.html"><tt>f_read()</tt></a>のラッパー関数です。読み出し動作は、最初の<tt>'\n'</tt>を読み込むか、ファイル終端に達するか、<tt>len - 1</tt>文字を読み出すまで続きます。読み込まれた文字列の終端には<tt>'\0'</tt>が付加されます。既にファイル終端で1文字も読み込まれなかったとき、または何らかのエラーが発生したときは関数は失敗しヌルポインタを返します。ファイル終端かエラーかは<tt>f_eof()</tt>,<tt>f_error()</tt>マクロで調べられます。</p> <p>読み出し動作は、最初の<tt>'\n'</tt>を読み込むか、ファイル終端に達するか、<tt class="arg">len</tt> - 1文字を読み出すまで続きます。読み込まれた文字列の終端には<tt>'\0'</tt>が付加されます。既にファイル終端で1文字も読み込まれなかったとき、または何らかのエラーが発生したときは関数は失敗しヌル ポインタを返します。ファイル終端かエラーかは<tt>f_eof/f_error</tt>関数で調べられます。</p>
<p>APIにUnicodeが選択(<tt>_LFN_UNICODE</tt>が1)されているときは、<span class="arg">buff</span>はUTF-16文字列になりますが、ファイル上のエンコードは、<tt>_STRF_ENCODE</tt>オプションで選択できます。それ以外の時は無変換(1バイト/1文字)で読み出します。</p> <p>Unicode API構成(<tt>_LFN_UNICODE == 1</tt>)が選択されているときは、<tt class="arg">buff</tt>はUTF-16文字列になりますが、ファイル上のエンコードは、<tt>_STRF_ENCODE</tt>オプションで選択できます。それ以外の時は無変換(1バイト/1文字)で読み出します。</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p><tt>_USE_STRFUNC</tt>が1または2のとき使用可能です。2のときは、ファイルに含まれる<tt>'\r'</tt>が取り除かれてバッファに読み込まれます。</p> <p>この関数は<a href="read.html"><tt>f_read</tt></a>関数のラッパー関数です。<tt>_USE_STRFUNC</tt>が1または2のとき使用可能です。2のときは、ファイルに含まれる<tt>'\r'</tt>が取り除かれてバッファに読み込まれます。</p>
</div> </div>
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<p><tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="putc.html">f_putc</a>, <a href="puts.html">f_puts</a>, <a href="printf.html">f_printf</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p> <p><tt><a href="open.html">f_open</a>, <a href="read.html">f_read</a>, <a href="putc.html">f_putc</a>, <a href="puts.html">f_puts</a>, <a href="printf.html">f_printf</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+41 -40
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/lseek.html"> <link rel="alternate" hreflang="en" title="English" href="../en/lseek.html">
@@ -13,33 +13,32 @@
<div class="para func"> <div class="para func">
<h2>f_lseek</h2> <h2>f_lseek</h2>
<p>ファイルのリード/ライトポインタを移動します。また、高速シーク機能使用時にはCLMT(後述)の作成にも使用します。</p> <p>ファイルのリード/ライト ポインタを移動します。また、高速シーク機能使用時にはCLMT(後述)の作成にも使用します。</p>
<pre> <pre>
FRESULT f_lseek ( FRESULT f_lseek (
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] ファイルオブジェクト構造体へのポインタ */</span> FIL* <span class="arg">fp</span>, <span class="c">/* [IN] ファイル オブジェクト構造体へのポインタ */</span>
DWORD <span class="arg">ofs</span> <span class="c">/* [IN] 移動先オフセット */</span> FSIZE_t <span class="arg">ofs</span> <span class="c">/* [IN] 移動先オフセット */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>fp</dt> <dt>fp</dt>
<dd>対象となるファイルオブジェクト構造体へのポインタを指定します。</dd> <dd>対象となるファイル オブジェクト構造体へのポインタを指定します。</dd>
<dt>ofs</dt> <dt>ofs</dt>
<dd>移動先のオフセット(リード/ライトポインタ)値。ファイル先頭からのオフセットをバイト単位で指定します。</dd> <dd>移動先のオフセット(リード/ライト ポインタ)値。ファイル先頭からのオフセットをバイト単位で指定します。データ型<tt>FSIZE_t</tt>は、<tt>DWORD</tt>(32-bit)または<tt>QWORD</tt>(64-bit)のエリアスで、exFATサポートの有無により切り替わります。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p> <p>
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>, <a href="rc.html#ie">FR_INT_ERR</a>,
<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>, <a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#tm">FR_TIMEOUT</a>, <a href="rc.html#tm">FR_TIMEOUT</a>,
<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a> <a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
@@ -48,82 +47,84 @@ FRESULT f_lseek (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>ファイルのリード/ライトポインタ(次に読み出し・書き込みされるバイトのオフセット)を移動します。オフセットの原点はファイル先頭です。書き込みモードでファイルサイズより大きな値を指定すると、そこまでファイルサイズが拡張され、拡張された部分のデータは未定義となります。データを遅延無く高速に書き込みたいときは、予めこの関数で必要なサイズまでファイルサイズを拡張しておくと良いでしょう。<tt>f_lseek()</tt>が正常終了したあとは、リード/ライトポインタが正しく移動したかチェックするべきです。リード/ライトポインタが指定より小さいときは、次の原因が考えられます。</p> <p>ファイルのリード/ライト ポインタ(次に読み出し・書き込みされるバイトのオフセット)を移動します。オフセットの原点はファイル先頭です。書き込みモードでファイル サイズより大きな値を指定すると、そこまでファイル サイズが拡張され、拡張された部分のデータは未定義となります。データを遅延無く高速に書き込みたいときは、予めこの関数で必要なサイズまでファイル サイズを拡張しておくと良いでしょう。ファイルに連続したデータ領域を割り当てる必要があるときは、<tt>f_expand</tt>関数を使用してください。<tt>f_lseek</tt>関数が正常終了したあとは、リード/ライト ポインタが正しく移動したかチェックするべきです。リード/ライト ポインタが指定より小さいときは、次の原因が考えられます。</p>
<ul> <ul>
<li>非書き込みモードまたは高速シークモードのため、ファイルサイズでクリップされた。</li> <li>非書き込みモードまたは高速シーク モードのため、ファイル サイズでクリップされた。</li>
<li>ファイル拡張中にディスクが満杯になった。</li> <li>ファイル拡張中にディスクが満杯になった。</li>
</ul> </ul>
<p><tt>_USE_FASTSEEK</tt>が1で、且つファイル・オブジェクトの<tt>cltbl</tt>メンバがNULL以外(<tt>f_open()</tt>でNULLに設定される)のとき、高速シークモードになります。これはファイルのクラスタ配置情報(CLMT)をメモリ上に保持しておくことにより、FATにアクセスすることなく後方シークやロングシークを高速に行う機能です。高速シーク・モードは、<tt>f_read()/f_wtite()</tt>の動作にも適用されます。高速シークモード<tt>f_wtite()/f_lseek()</tt>によるファイルサイズの拡張はできません。</p> <p>高速シーク モードはファイルのクラスタ配置情報(CLMT)をメモリ上に保持しておくことにより、FATにアクセスすることなく後方シークやロング シークを高速に行う機能で、シーク動作のほか<tt>f_read/f_wtite</tt>関数の動作にも適用されます。ファイルが高速シーク モードの間<tt>f_wtite/f_lseek</tt>関数によるファイル サイズの拡張はできません。</p>
<p>高速シーク動作を行う前に、CLMTを作成しておく必要があります。これを作成するには、まずCLMT格納バッファ(<tt>DWORD</tt>型配列)を準備し、<tt>cltbl</tt>メンバにそのポインタをセットします。そして、配列の先頭要素にその配列のサイズ(要素数)を入れ、<tt>f_lseek()</tt><tt class="arg">ofs</tt><tt>CREATE_LINKMAP</tt>を指定して呼び出します。関数が成功するとCLMTが作成され、以降の<tt>f_read()/f_write()/f_lseek()</tt>ではFATへのアクセスは発生しません。<tt>FR_NOT_ENOUGH_CORE</tt>で失敗したときは配列サイズが不足で、先頭要素には実際に必要となる要素数が返されます。必要な要素数は、(ファイルの分割数 + 1) * 2 です。たとえば、ファイルが5つのフラグメントに分断されているときに必要な要素数は、12となります。</p> <p>高速シーク モードは、ファイル オブジェクトのメンバ<tt>cltbl</tt>(<tt>f_open</tt>関数でNULLになる)にNULL以外を設定したとき有効になるので、まずCLMTを作成しておく必要があります。これを作成するには、まずCLMT格納バッファ(<tt>DWORD</tt>型配列)を準備し、<tt>cltbl</tt>にそのポインタをセットします。そして、配列の先頭要素にその配列のサイズ(要素数)を入れ、<tt>f_lseek</tt>関数<tt class="arg">ofs</tt><tt>CREATE_LINKMAP</tt>を指定して呼び出します。関数が成功するとCLMTが作成され、以降の<tt>f_read/f_write/f_lseek</tt>関数ではFATへのアクセスは発生しません。CLMTの先頭要素には実際に使用した(または必要となる)要素数が返されます。使用される要素数は、(ファイルの分割数 + 1) * 2 です。たとえば、ファイルが5つのフラグメントに分断されているときは、12要素が使用されます。<tt>FR_NOT_ENOUGH_CORE</tt>で失敗したときは、配列サイズが不足です。</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p><tt>_FS_MINIMIZE &lt; 3</tt>のとき使用可能です。</p> <p><tt>_FS_MINIMIZE &lt; 3</tt>のとき使用可能です。高速シーク モードを利用するときは、<tt><a href="config.html#use_fastseek">_USE_FASTSEEK</a> == 1</tt>である必要があります。</p>
</div> </div>
<div class="para use"> <div class="para use">
<h4>使用例</h4> <h4>使用例</h4>
<pre> <pre>
<span class="c">/* ファイルを開く */</span> <span class="c">/* ファイルを開く */</span>
fp = malloc(sizeof (FIL)); fp = malloc(sizeof (FIL));
res = f_open(fp, "file.dat", FA_READ|FA_WRITE); res = f_open(fp, "file.dat", FA_READ|FA_WRITE);
if (res) ... if (res) ...
<span class="c">/* ファイルオフセット5000へ移動 */</span> <span class="c">/* ファイル オフセット5000へ移動 */</span>
res = f_lseek(fp, 5000); res = f_lseek(fp, 5000);
<span class="c">/* ファイル終端へ移動(ファイル追記の準備) */</span> <span class="c">/* ファイル終端へ移動(ファイル追記の準備) */</span>
res = f_lseek(fp, f_size(fp)); res = f_lseek(fp, f_size(fp));
<span class="c">/* 3000バイト進める */</span> <span class="c">/* 3000バイト進める */</span>
res = f_lseek(fp, f_tell(fp) + 3000); res = f_lseek(fp, f_tell(fp) + 3000);
<span class="c">/* 2000バイト戻す (ラップアラウンドに注意) */</span> <span class="c">/* 2000バイト戻す (ラップアラウンドに注意) */</span>
res = f_lseek(fp, f_tell(fp) - 2000); res = f_lseek(fp, f_tell(fp) - 2000);
</pre> </pre>
<pre> <pre>
<span class="c">/* クラスタ先行割り当て (ストリーミングライト時のバッファオーバーラン防止) */</span> <span class="c">/* クラスタ先行割り当て (ストリーミング ライト時のバッファ オーバーラン防止) */</span>
res = f_open(fp, "record.wav", FA_CREATE_NEW | FA_WRITE); <span class="c">/* ファイル作成 */</span> res = f_open(fp, "record.wav", FA_CREATE_NEW | FA_WRITE); <span class="c">/* ファイル作成 */</span>
res = f_lseek(fp, MAX_SIZE); <span class="c">/* 十分なクラスタの先行割り当て */</span> res = f_lseek(fp, MAX_SIZE); <span class="c">/* 十分なクラスタの先行割り当て */</span>
if (res || f_tell(fp) != PRE_SIZE) ... <span class="c">/* 正しくファイルが拡張されたかチェック */</span> if (res || f_tell(fp) != PRE_SIZE) ... <span class="c">/* 正しくファイルが拡張されたかチェック */</span>
res = f_lseek(fp, DATA_START); <span class="c">/* データストリームの記録(アロケーションディレイ無し) */</span> res = f_lseek(fp, DATA_START); <span class="c">/* データ ストリームの記録(アロケーションディレイ無し) */</span>
... ...
res = f_truncate(fp); <span class="c">/* 不要領域の切り捨て */</span> res = f_truncate(fp); <span class="c">/* 不要領域の切り捨て */</span>
res = f_lseek(fp, 0); <span class="c">/* ヘッダの記録 */</span> res = f_lseek(fp, 0); <span class="c">/* ヘッダの記録 */</span>
... ...
res = f_close(fp); res = f_close(fp);
</pre> </pre>
<pre> <pre>
<span class="c">/* 高速シーク機能を使う */</span> <span class="c">/* 高速シーク機能を使う */</span>
DWORD clmt[SZ_TBL]; <span class="c">/* リンクマップテーブル格納バッファ */</span> DWORD clmt[SZ_TBL]; <span class="c">/* リンク マップ テーブル格納バッファ */</span>
res = f_lseek(fp, ofs1); <span class="c">/* 通常シーク (オープン時、cltblはNULLに初期化される) */</span> res = f_open(fp, fname, FA_READ | FA_WRITE); <span class="c">/* ファイルを開く */</span>
fp-&gt;cltbl = clmt; <span class="c">/* 高速シーク機能の有効化 */</span> res = f_lseek(fp, ofs1); <span class="c">/* 通常シーク (オープン時、cltblはNULLに初期化される) */</span>
clmt[0] = SZ_TBL; <span class="c">/* 先頭要素に配列要素数をセット */</span>
res = f_lseek(fp, CREATE_LINKMAP); <span class="c">/* CLMTの作成 */</span> fp-&gt;cltbl = clmt; <span class="c">/* 高速シーク機能の有効化 */</span>
clmt[0] = SZ_TBL; <span class="c">/* 先頭要素に配列要素数をセット */</span>
res = f_lseek(fp, CREATE_LINKMAP); <span class="c">/* CLMTの作成 */</span>
... ...
res = f_lseek(fp, ofs2); <span class="c">/* 以降、f_read/f_write/f_lseekでFATアクセスは発生しない */</span> res = f_lseek(fp, ofs2); <span class="c">/* 以降、f_read/f_write/f_lseekでFATアクセスは発生しない */</span>
</pre> </pre>
</div> </div>
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<p><tt><a href="open.html">f_open</a>, <a href="sfile.html">FIL</a></tt></p> <p><tt><a href="open.html">f_open</a>, <a href="truncate.html">f_truncate</a>, <a href="expand.html">f_expand</a>, <a href="sfile.html">FIL</a></tt></p>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+12 -12
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/mkdir.html"> <link rel="alternate" hreflang="en" title="English" href="../en/mkdir.html">
@@ -13,25 +13,25 @@
<div class="para func"> <div class="para func">
<h2>f_mkdir</h2> <h2>f_mkdir</h2>
<p>ディレクトリを作成します。</p> <p>サブ ディレクトリを作成します。</p>
<pre> <pre>
FRESULT f_mkdir ( FRESULT f_mkdir (
const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] 作成するディレクトリ名へのポインタ */</span> const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] 作成するディレクトリ名へのポインタ */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<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>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p> <p>
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
@@ -52,19 +52,19 @@ FRESULT f_mkdir (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>空のディレクトリを作成します。</p> <p>空のサブ ディレクトリを作成します。ディレクトリを削除するときは<a href="unlink.html"><tt>f_unlink</tt></a>関数を使用してください。</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<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>
</div> </div>
<div class="para use"> <div class="para use">
<h4>使用例</h4> <h4>使用例</h4>
<pre> <pre>
res = f_mkdir("sub1"); res = f_mkdir("sub1");
if (res) die(res); if (res) die(res);
@@ -75,6 +75,6 @@ FRESULT f_mkdir (
</pre> </pre>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+58 -21
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/mkfs.html"> <link rel="alternate" hreflang="en" title="English" href="../en/mkfs.html">
@@ -13,30 +13,30 @@
<div class="para func"> <div class="para func">
<h2>f_mkfs</h2> <h2>f_mkfs</h2>
<p>論理ドライブ上にFATボリュームを作成(フォーマット)します。</p> <p>論理ドライブ上にFATボリュームを作成します。</p>
<pre> <pre>
FRESULT f_mkfs ( FRESULT f_mkfs (
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 論理ドライブ番号 */</span> const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 論理ドライブ番号 */</span>
BYTE <span class="arg">sfd</span>, <span class="c">/* [IN] 区画作成方法 */</span> BYTE <span class="arg">sfd</span>, <span class="c">/* [IN] 区画作成方法 */</span>
UINT <span class="arg">au</span> <span class="c">/* [IN] クラスタサイズ */</span> UINT <span class="arg">au</span> <span class="c">/* [IN] クラス タサイズ */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<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>sfd</dt> <dt>sfd</dt>
<dd>パーテーション形式。(0(FDISK) または 1(SFD))</dd> <dd>パーテーション形式。(0(FDISK) または 1(SFD))</dd>
<dt>au</dt> <dt>au</dt>
<dd>クラスタサイズをバイト単位で指定します。対象ドライブのセクタ・サイズのn倍(n = 1~128で、2の累乗)でなければなりません。0を指定した場合、ボリュームのサイズに応じたデフォルトのクラスタサイズが選択されます。</dd> <dd>クラスタ サイズをバイト数またはセクタ数で指定します。値が1~128の範囲場合は、セクタ数を示します。値が<tt>_MIN_SS</tt>以上の場合は、バイト数を示します。無効値(0または2の累乗でない値など)を指定した場合、ボリュームのサイズに応じたデフォルトのクラスタ サイズが自動選択されます。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p> <p>
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
@@ -48,26 +48,63 @@ FRESULT f_mkfs (
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>説明</h4> <h4>説明</h4>
<p>物理ドライブ上にFATボリュームを作成します。FDISK形式が指定された場合は、物理ドライブ全体を占める基本区画(パーテーション)が作成され、その中にFATボリュームが作成されます。SFD形式では、FATボリューム物理ドライブの先頭セクタからベタで作成されます。</p> <p>物理ドライブ上にFATボリュームを作成(フォーマット)します。FDISK形式が指定された場合は、物理ドライブ全体を占める基本区画(パーテーション)が作成され、その中にFATボリュームが作成されます。SFD形式では、FATボリューム物理ドライブの先頭セクタからベタで作成されます。</p>
<p>マルチパーテーション機能(<tt>_MULTI_PARTITION</tt>)により、指定された論理ドライブが特定の区画(1~4)に結び付けられている場合、その区画の中にFATボリュームが作成されます。この場合、<tt class="arg">sfd</tt>は無視され、また対応する物理ドライブはこれに先立ち、<tt>f_fdisk()</tt>または他のツールで適切に区画設定されている必要があります。</p> <p>マルチ パーテーション機能(<tt><a href="config.html#multi_partition">_MULTI_PARTITION</a></tt>)により、フォーマット対象の論理ドライブが特定の区画(1~4)に結び付けられている場合、その区画の中にFATボリュームが作成されます。<tt class="arg">sfd</tt>は無視され、その物理ドライブはこれに先立ち、<tt>f_fdisk</tt>関数または他のツールで適切に区画設定されている必要があります。</p>
<p>パーテーション形式には、FDISK形式とSFD形式の二通りあります。FDISK形式は、ハードディスク、MMC、SDC、CFC、U Diskなどで標準的に使用されます。FDISK形式では一台の物理ドライブ上に一つまたは複数の区画を作成することができます。管理情報はMBR(物理ドライブの先頭セクタ)に記録されます。SFD形式は単に何の分割も行わない形式で、ボリュームは物理ドライブの先頭セクタから開始します。SFD形式は、フロッピーディスク、マイクロドライブ、光学ディスク、およびその他スーパーフロッピーメディアで標準的に使用されています。</p> <p>パーテーション形式には、FDISK形式とSFD形式の二通りあります。FDISK形式は、ハードディスク、MMC、SDC、CFC、U Diskなどで標準的に使用されます。FDISK形式では一台の物理ドライブ上に一つまたは複数の区画を作成することができます。区画管理情報はMBR(物理ドライブの先頭セクタ)に記録されます。SFD形式は単に何の分割も行わない形式で、ボリュームは物理ドライブの先頭セクタから開始します。SFD形式は、フロッピー ディスク、マイクロドライブ、光学ディスク、およびその他スーパー フロッピー メディアで標準的に使用されています。</p>
<p>FATタイプ(FAT12/FAT16/FAT32)は、その論理ドライブ上の<em>クラスタ数によってのみ決定</em>される決まり[FAT仕様書より]になっていて、それ以外の要因はありません。したがって、どのFATタイプになるかはドライブ・サイズとクラスタサイズに依存します。クラスタサイズは大きくするほど性能が上がり、ディスク利用効率は落ちます。</p> <p>FATタイプ(FAT12/FAT16/FAT32)は、そのボリューム上の<em>クラスタ数によってのみ決定</em>される決まり[FAT仕様書より]になっていて、それ以外の要因はありません。したがって、どのFATタイプになるかはボリューム サイズとクラスタ サイズに依存します。クラスタ サイズは大きくするほど性能が上がります。クラスタ数がFATタイプの境界に近くなるときは、<tt>FR_MKFS_ABORTED</tt>で関数が失敗する可能性があります。</p>
<p>クラスタ数がFATタイプの境界に近くなるときは、<tt>FR_MKFS_ABORTED</tt>で関数が失敗する可能性があります。</p> <p><em>現リビジョン(R0.12)では、exFATボリュームの作成はサポートされません。</em></p>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_MKFS == 1</tt>のとき使用可能です。</p> <p><tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_MKFS == 1</tt>のとき使用可能です。</p>
</div>
<div class="para use">
<h4>使用例</h4>
<pre>
<span class="c">/* Format default drive and create a file */</span>
int main (void)
{
FATFS fs; <span class="c">/* File system object (volume work area) */</span>
FIL fil; <span class="c">/* File object */</span>
FRESULT res; <span class="c">/* API result code */</span>
UINT bw; <span class="c">/* Bytes written */</span>
<span class="c">/* Register work area (do not care about error) */</span>
f_mount(&amp;fs, "", 0);
<span class="c">/* Create FAT volume with default cluster size */</span>
res = f_mkfs("", 0, 0);
if (res) ...
<span class="c">/* Create a file as new */</span>
res = f_open(&amp;fil, "hello.txt", FA_CREATE_NEW | FA_WRITE);
if (res) ...
<span class="c">/* Write a message */</span>
f_write(&amp;fil, "Hello, World!\r\n", 15, &amp;bw);
if (bw != 15) ...
<span class="c">/* Close the file */</span>
f_close(&amp;fil);
<span class="c">/* Unregister work area */</span>
f_mount(0, "", 0);
</pre>
</div> </div>
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<p><tt><a href="filename.html#vol">ボリューム管理</a>, <a href="fdisk.html">f_fdisk</a></tt></p> <p><tt><a href="filename.html#vol">ボリューム管理</a>, <a href="fdisk.html">f_fdisk</a></tt></p>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
<p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+26 -26
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/mount.html"> <link rel="alternate" hreflang="en" title="English" href="../en/mount.html">
@@ -13,30 +13,30 @@
<div class="para func"> <div class="para func">
<h2>f_mount</h2> <h2>f_mount</h2>
<p>論理ドライブにファイルシステムオブジェクトを登録・抹消します。</p> <p>論理ドライブにファイル システム オブジェクトを登録・抹消します。</p>
<pre> <pre>
FRESULT f_mount ( FRESULT f_mount (
FATFS* <span class="arg">fatfs</span>, <span class="c">/* [IN] ファイルシステムオブジェクト */</span> FATFS* <span class="arg">fs</span>, <span class="c">/* [IN] ファイル システム オブジェクト */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 論理ドライブ番号 */</span> const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] 論理ドライブ番号 */</span>
BYTE <span class="arg">opt</span> <span class="c">/* [IN] オプション */</span> BYTE <span class="arg">opt</span> <span class="c">/* [IN] 動作オプション */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>fatfs</dt> <dt>fs</dt>
<dd>登録するファイルシステムオブジェクトへのポインタ</dd> <dd>登録するファイル システム オブジェクトへのポインタ、またはヌル ポインタ</dd>
<dt>path</dt> <dt>path</dt>
<dd>対象となる論理ドライブの<a href="filename.html">パス名</a>を示すヌル文字'\0'終端の文字列へのポインタを指定します。ドライブ番号含まない場合は、デフォルトドライブを指定したことになります。</dd> <dd>対象となる論理ドライブの<a href="filename.html">パス名</a>を示すヌル文字'\0'終端の文字列へのポインタを指定します。パス名にドライブ番号含まない場合は、デフォルト ドライブを指定したことになります。</dd>
<dt>opt</dt> <dt>opt</dt>
<dd>ファイルシステムオブジェクトの登録と同時にマウント動作を行うかどうかを指定するフラグ。登録抹消のときは意味を持ちません。</dd> <dd>ファイル システム オブジェクトの登録と同時にマウント動作を行うかどうかを指定するフラグ。登録抹消のときは意味を持ちません。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p> <p>
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#id">FR_INVALID_DRIVE</a>, <a href="rc.html#id">FR_INVALID_DRIVE</a>,
@@ -48,35 +48,35 @@ FRESULT f_mount (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>FatFsモジュールでは、それぞれの論理ドライブに<em>ファイルシステムオブジェクト</em>というワークエリアが必要です。この関数は論理ドライブにファイルシステムオブジェクトを登録したり抹消したりします。何らかのファイル関数を使用する前に、この関数でその論理ドライブのファイルシステムオブジェクトを与えておかなければなりません。<tt class="arg">fatfs</tt>にヌルポインタを指定すると、その論理ドライブのファイルシステムオブジェクトの登録は抹消されるだけです。登録抹消されたファイルシステムオブジェクトのメモリは解放できます。操作対象の論理ドライブ上に開かれているファイルやディレクトリがあった場合、それらは全て無効になります。この関数の内部処理は次のような順に行われます。</p> <p>FatFsモジュールでは、それぞれの論理ドライブに<em>ファイル システム オブジェクト</em>というワーク エリアが必要です。この関数は論理ドライブにファイル システム オブジェクトを登録したり抹消したりします。何らかのファイル関数を使用する前に、この関数でその論理ドライブのファイル システム オブジェクトを与えておかなければなりません。<tt class="arg">fs</tt>にヌル ポインタを指定すると、その論理ドライブのファイル システム オブジェクトの登録は抹消されるだけです。登録抹消されたファイル システム オブジェクトのメモリは解放できます。操作対象の論理ドライブ上に開かれたままのファイルやディレクトリがあった場合、それらに対して作成された構造体は全て無効になります。この関数の内部処理は次のような順に行われます。</p>
<ol> <ol>
<li>対象の論理ドライブを<tt class="arg">path</tt>から得る。</li> <li>対象の論理ドライブを<tt class="arg">path</tt>から得る。</li>
<li>既に登録されているファイルシステムオブジェクトはクリアし、登録を解除する。</li> <li>既に登録されているファイル システム オブジェクトはクリア(無効化)し、登録を解除する。</li>
<li><tt class="arg">fatfs</tt>が有効なポインタのときは、そのファイルシステムオブジェクトをクリアし登録する。</li> <li><tt class="arg">fs</tt>が有効なポインタのときは、そのファイル システム オブジェクトをクリアし登録する。</li>
<li>マウント動作が指定されているときは、それを実行する。</li> <li>マウント動作が指定されているときは、それを実行する。</li>
</ol> </ol>
<p><tt class="arg">opt</tt>に0を指定すると、マウント動作(物理ドライブの初期化、FATボリュームの検索、BPBを解析しファイルシステムオブジェクトを初期化)は行われず、関数は物理ドライブの状態に関わらず常に成功します。関数内では下位レイヤへのアクセスは発生せず、指定されたファイルシステムオブジェクトをクリア(無効化)し、そのアドレスを内部配列に登録するだけです。単に登録済みのファイルシステムオブジェクトをクリアする目的にも使えます。そして、続いてボリュームへのアクセスが行われたとき次のうちいずれかでも真の場合は、実際のマウント動作が行われます。</p> <p><tt class="arg">opt</tt>に0を指定すると、マウント動作(物理ドライブの初期化、FATボリュームの検索、BPBを解析しファイル システム オブジェクトを初期化)は行われず、関数は物理ドライブの状態に関わらず常に成功します。関数内では下位レイヤへのアクセスは発生せず、指定されたファイル システム オブジェクトをクリア(無効化)し、そのアドレスを内部配列に登録するだけです。単に登録済みのファイル システム オブジェクトをクリアする目的にも使えます。実際のマウント動作は、ボリュームへのアクセス(パス名を渡すもの全て)が行われたときに、次のうちいずれかの条件が真の場合に行われます。</p>
<ul> <ul>
<li>ファイルシステムオブジェクトがクリア(無効)状態(<tt>f_mount()</tt>の実行による)</li> <li>ファイル システム オブジェクトがクリア(無効)状態(<tt>f_mount</tt>関数の実行による)</li>
<li>物理ドライブが未初期化状態(システムリセットやメディアの交換による)</li> <li>物理ドライブが未初期化状態(システム リセットやメディアの交換による)</li>
</ul> </ul>
<p><tt class="arg">opt</tt>に1を指定すると、登録に続いてマウント動作が行われます。マウントに失敗すると対応するエラーを返しますが、登録は有効なので続ボリュームへのアクセス再びマウント動作が実行されます。<p> <p><tt class="arg">opt</tt>に1を指定すると、ファイル システムオブジェクトの登録に続マウント動作が行われます。メディアが無いなどの理由でマウント動作に失敗すると対応するエラーを返しファイル システム オブジェクトはクリア状態のままになりますが、登録自体は有効なので続いてボリュームへのアクセスがあれば再びマウント動作が実行されます。</p>
<p>下位レイヤの実装上メディア交換の検出がサポートされない(<tt>disk_status()</tt>に反映されない)ときは、アプリケーションはメディア交換の後この関数でファイルシステムオブジェクトを明示的にクリアして再マウントが正常に行えるようにする必要があります。</p> <p>下位レイヤの実装上メディア交換の検出がサポートされない(<tt>disk_status</tt>関数に反映されない)ときは、アプリケーションはメディア交換の後この関数でファイル システム オブジェクトを明示的にクリアしマウント動作が正常に行えるようにする必要があります。</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p>全ての構成で使用可能です。</p> <p>全ての構成で使用可能です。</p>
</div> </div>
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<p><tt><a href="open.html">f_open</a></tt>, <tt><a href="sfatfs.html">FATFS</a></tt></p> <p><tt><a href="open.html">f_open</a></tt>, <tt><a href="sfatfs.html">FATFS</a></tt></p>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+51 -51
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/open.html"> <link rel="alternate" hreflang="en" title="English" href="../en/open.html">
@@ -13,33 +13,33 @@
<div class="para func"> <div class="para func">
<h2>f_open</h2> <h2>f_open</h2>
<p>ファイルをオープンまたは作成します。</p> <p>ファイルをオープンまたは作成します。</p>
<pre> <pre>
FRESULT f_open ( FRESULT f_open (
FIL* <span class="arg">fp</span>, <span class="c">/* [OUT] 空のファイルオブジェクト構造体へのポインタ */</span> FIL* <span class="arg">fp</span>, <span class="c">/* [OUT] 空のファイル オブジェクト構造体へのポインタ */</span>
const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] ファイルのフルパス名へのポインタ */</span> const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] ファイル名へのポインタ */</span>
BYTE <span class="arg">mode</span> <span class="c">/* [IN] モードフラグ */</span> BYTE <span class="arg">mode</span> <span class="c">/* [IN] モードフラグ */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>fp</dt> <dt>fp</dt>
<dd>新しく作成するファイルオブジェクト構造体へのポインタを指定します。以降、そのファイルを閉じるまでこのファイルオブジェクトを使用してファイル操作をします。</dd> <dd>新しく作成するファイル オブジェクト構造体へのポインタを指定します。以降、そのファイルを閉じるまでこのファイル オブジェクトを使用してファイル操作をします。</dd>
<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>mode</dt> <dt>mode</dt>
<dd>ファイルのアクセス方法やオープン方法を決めるフラグです。このパラメータには次の組み合わせを指定します。<br> <dd>ファイルのアクセス方法やオープン方法を決めるフラグです。このパラメータには次の組み合わせを指定します。<br>
<table class="lst"> <table class="lst">
<tr><th></th><th>意味</th></tr> <tr><th></th><th>意味</th></tr>
<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>既存のファイルを開きます。ファイルが無いときはファイルを作成します。追記の場合は、この方法でオープンした後、<a href="lseek.html"><tt>f_lseek()</tt></a>でファイルの最後尾に移動してください。</td></tr> <tr><td>FA_OPEN_ALWAYS</td><td>既存のファイルを開きます。ファイルが無いときはファイルを作成します。追記の場合は、この方法でオープンした後、<a href="lseek.html"><tt>f_lseek</tt></a>関数でファイルの最後尾に移動してください。</td></tr>
<tr><td>FA_CREATE_NEW</td><td>ファイルを作成します。同名のファイルがある場合は、<tt>FR_EXIST</tt>で失敗します。</td></tr> <tr><td>FA_CREATE_NEW</td><td>ファイルを作成します。同名のファイルがある場合は、<tt>FR_EXIST</tt>で失敗します。</td></tr>
<tr><td>FA_CREATE_ALWAYS</td><td>ファイルを作成します。同名のファイルがある場合は、サイズを0にしてから開きます。</td></tr> <tr><td>FA_CREATE_ALWAYS</td><td>ファイルを作成します。同名のファイルがある場合は、サイズを0にしてから開きます。</td></tr>
</table> </table>
</dd> </dd>
</dl> </dl>
@@ -47,7 +47,7 @@ FRESULT f_open (
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p> <p>
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
@@ -72,86 +72,86 @@ FRESULT f_open (
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>既存のファイルを開いたり、新しいファイルを作成します。関数が成功するとファイルオブジェクトが作成され、以降そのファイルに対するアクセスに使用します。ファイルを閉じるときは、<a href="close.html"><tt>f_close()</tt></a>を使用します。何らかの変更が行われたファイルがその後正しく閉じられなかった場合、そのファイルが破損する場合があります。</p> <p>既存のファイルを開いたり、新しいファイルを作成します。関数が成功するとファイル オブジェクトが作成され、以降そのファイルに対するアクセスに使用します。ファイルを閉じるときは、<a href="close.html"><tt>f_close</tt></a>関数を使用します。何らかの変更が行われたファイルがその後正しく閉じられなかった場合、そのファイルが破損する場合があります。</p>
<p>既に開かれているファイルを開く必要がある場合は、<a href="appnote.html#dup">多重アクセス制御</a>を参照してください。しかし、一つのファイルに対する書き込みモードを含む重複オープンは常に禁止です。</p> <p>既に開かれているファイルを開く必要がある場合は、<a href="appnote.html#dup">多重アクセス制御</a>を参照してください。しかし、一つのファイルに対する書き込みモードを含む重複オープンは常に禁止です。</p>
<p>ファイルアクセスを開始する前に、<a href="mount.html"><tt>f_mount()</tt></a>を使ってそれぞれの論理ドライブにワークエリア(ファイルシステムオブジェクト)を与える必要があります。この初期化の後、その論理ドライブに対して全てのファイル関数が使えるようになります。</p> <p>ファイル アクセスを開始する前に、<a href="mount.html"><tt>f_mount</tt></a>関数を使ってそれぞれの論理ドライブにワーク エリア(ファイル システム オブジェクト)を与える必要があります。この初期化の後、その論理ドライブに対して全てのファイル関数が使えるようになります。</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p>全ての構成で使用可能です。<tt>_FS_READONLY == 1</tt>のときは、<tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>の各フラグはサポートされません。</p> <p>全ての構成で使用可能です。<tt>_FS_READONLY == 1</tt>のときは、<tt>FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS</tt>の各フラグはサポートされません。</p>
</div> </div>
<div class="para use"> <div class="para use">
<h4>使用例</h4> <h4>使用例</h4>
<pre> <pre>
<span class="c">/* テキストファイルを読み出して表示 */</span> <span class="c">/* テキストファイルを読み出して表示 */</span>
FATFS FatFs; <span class="c">/* 論理ドライブのワークエリア(ファイルシステムオブジェクト) */</span> FATFS FatFs; <span class="c">/* 論理ドライブのワーク エリア(ファイル システム オブジェクト) */</span>
int main (void) int main (void)
{ {
FIL fil; <span class="c">/* ファイルオブジェクト */</span> FIL fil; <span class="c">/* ファイル オブジェクト */</span>
char line[82]; <span class="c">/* 行バッファ */</span> char line[82]; <span class="c">/* 行バッファ */</span>
FRESULT fr; <span class="c">/* 戻り値 */</span> FRESULT fr; <span class="c">/* 戻り値 */</span>
<span class="c">/* デフォルトドライブにワークエリアを与える */</span> <span class="c">/* デフォルト ドライブにワークエリアを与える */</span>
f_mount(&amp;FatFs, "", 0); f_mount(&amp;FatFs, "", 0);
<span class="c">/* テキストファイルを開く */</span> <span class="c">/* テキスト ファイルを開く */</span>
fr = f_open(&fil, "message.txt", FA_READ); fr = f_open(&amp;fil, "message.txt", FA_READ);
if (fr) return (int)fr; if (fr) return (int)fr;
<span class="c">/* 1行ずつ読み出して表示 */</span> <span class="c">/* 1行ずつ読み出して表示 */</span>
while (f_gets(line, sizeof line, &fil)) while (f_gets(line, sizeof line, &amp;fil))
printf(line); printf(line);
<span class="c">/* ファイルを閉じる */</span> <span class="c">/* ファイルを閉じる */</span>
f_close(&fil); f_close(&amp;fil);
return 0; return 0;
} }
</pre> </pre>
<pre> <pre>
<span class="c">/* ドライブ1のファイル "file.bin" をドライブ0へコピー */</span> <span class="c">/* ドライブ1のファイル "file.bin" をドライブ0へコピー */</span>
int main (void) int main (void)
{ {
FATFS fs[2]; <span class="c">/* 論理ドライブのワークエリア(ファイルシステムオブジェクト) */</span> FATFS fs[2]; <span class="c">/* 論理ドライブのワークエリア(ファイル システム オブジェクト) */</span>
FIL fsrc, fdst; <span class="c">/* ファイルオブジェクト */</span> FIL fsrc, fdst; <span class="c">/* ファイル オブジェクト */</span>
BYTE buffer[4096]; <span class="c">/* File copy buffer */</span> BYTE buffer[4096]; <span class="c">/* File copy buffer */</span>
FRESULT fr; <span class="c">/* FatFs function common result code */</span> FRESULT fr; <span class="c">/* FatFs function common result code */</span>
UINT br, bw; <span class="c">/* File R/W count */</span> UINT br, bw; <span class="c">/* File R/W count */</span>
<span class="c">/* ドライブ0,1にワークエリアを与える */</span> <span class="c">/* ドライブ0,1にワーク エリアを与える */</span>
f_mount(&amp;fs[0], "0:", 0); f_mount(&amp;fs[0], "0:", 0);
f_mount(&amp;fs[1], "1:", 0); f_mount(&amp;fs[1], "1:", 0);
<span class="c">/* ドライブ1のコピー元ファイルを開く */</span> <span class="c">/* ドライブ1のコピー元ファイルを開く */</span>
res = f_open(&amp;fsrc, "1:file.dat", FA_OPEN_EXISTING | FA_READ); res = f_open(&amp;fsrc, "1:file.dat", FA_OPEN_EXISTING | FA_READ);
if (fr) return (int)fr; if (fr) return (int)fr;
<span class="c">/* ドライブ0にコピー先ファイルを作成する */</span> <span class="c">/* ドライブ0にコピー先ファイルを作成する */</span>
res = f_open(&amp;fdst, "0:file.dat", FA_CREATE_ALWAYS | FA_WRITE); res = f_open(&amp;fdst, "0:file.dat", FA_CREATE_ALWAYS | FA_WRITE);
if (fr) return (int)fr; if (fr) return (int)fr;
<span class="c">/* コピー元からコピー先にデータ転送する */</span> <span class="c">/* コピー元からコピー先にデータ転送する */</span>
for (;;) { for (;;) {
res = f_read(&amp;fsrc, buffer, sizeof buffer, &amp;br); <span class="c">/* コピー元からから読み出す */</span> res = f_read(&amp;fsrc, buffer, sizeof buffer, &amp;br); <span class="c">/* コピー元からから読み出す */</span>
if (res || br == 0) break; <span class="c">/* エラーかファイル終端 */</span> if (res || br == 0) break; <span class="c">/* エラーかファイル終端 */</span>
res = f_write(&amp;fdst, buffer, br, &amp;bw); <span class="c">/* それをコピー先に書き込む */</span> res = f_write(&amp;fdst, buffer, br, &amp;bw); <span class="c">/* それをコピー先に書き込む */</span>
if (res || bw &lt; br) break; <span class="c">/* エラーかディスク満杯 */</span> if (res || bw &lt; br) break; <span class="c">/* エラーかディスク満杯 */</span>
} }
<span class="c">/* 全てのファイルを閉じる */</span> <span class="c">/* 全てのファイルを閉じる */</span>
f_close(&amp;fsrc); f_close(&amp;fsrc);
f_close(&amp;fdst); f_close(&amp;fdst);
<span class="c">/* ワークエリアを開放する */</span> <span class="c">/* ワーク エリアを開放する */</span>
f_mount(NULL, "0:", 0); f_mount(NULL, "0:", 0);
f_mount(NULL, "1:", 0); f_mount(NULL, "1:", 0);
@@ -162,10 +162,10 @@ int main (void)
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<p><tt><a href="read.html">f_read</a>, <a href="write.html">f_write</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a>, <a href="sfatfs.html">FATFS</a></tt></p> <p><tt><a href="read.html">f_read</a>, <a href="write.html">f_write</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a>, <a href="sfatfs.html">FATFS</a></tt></p>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+14 -15
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/opendir.html"> <link rel="alternate" hreflang="en" title="English" href="../en/opendir.html">
@@ -13,28 +13,28 @@
<div class="para func"> <div class="para func">
<h2>f_opendir</h2> <h2>f_opendir</h2>
<p>ディレクトリを開きます。</p> <p>ディレクトリを開きます。</p>
<pre> <pre>
FRESULT f_opendir ( FRESULT f_opendir (
DIR* <span class="arg">dp</span>, <span class="c">/* [OUT] ディレクトリブジェクト構造体へのポインタ */</span> DIR* <span class="arg">dp</span>, <span class="c">/* [OUT] ディレクトリ ブジェクト構造体へのポインタ */</span>
const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] ディレクトリ名へのポインタ */</span> const TCHAR* <span class="arg">path</span> <span class="c">/* [IN] ディレクトリ名へのポインタ */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>dp</dt> <dt>dp</dt>
<dd>空のディレクトリオブジェクト構造体へのポインタを指定します。</dd> <dd>空のディレクトリ オブジェクト構造体へのポインタを指定します。</dd>
<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>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p> <p>
<a href="rc.html#ok">FR_OK</a>, <a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>, <a href="rc.html#de">FR_DISK_ERR</a>,
@@ -50,27 +50,26 @@ FRESULT f_opendir (
<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>, <a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>,
<a href="rc.html#tf">FR_TOO_MANY_OPEN_FILES</a> <a href="rc.html#tf">FR_TOO_MANY_OPEN_FILES</a>
</p> </p>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>ディレクトリを開きます。正常終了したら、作成された<tt>DIR</tt>構造体を使ってこのディレクトリの項目を順次読み出せます。</p> <p>ディレクトリを開きます。正常終了したら、作成されたディレクトリ オブジェクト構造体を使ってこのディレクトリの項目を順次読み出せます。</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<h4>対応情報</h4> <h4>対応情報</h4>
<p><tt>_FS_MINIMIZE &lt;= 1</tt>のとき使用可能になります。</p> <p><tt>_FS_MINIMIZE &lt;= 1</tt>のとき使用可能になります。</p>
</div> </div>
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<p><tt><a href="readdir.html">f_readdir</a>, <a href="closedir.html">f_closedir</a>, <a href="sdir.html">DIR</a></tt></p> <p><tt><a href="readdir.html">f_readdir</a>, <a href="closedir.html">f_closedir</a>, <a href="sdir.html">DIR</a></tt></p>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+30 -27
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/printf.html"> <link rel="alternate" hreflang="en" title="English" href="../en/printf.html">
@@ -13,78 +13,81 @@
<div class="para func"> <div class="para func">
<h2>f_printf</h2> <h2>f_printf</h2>
<p>ファイルに書式化文字列を書き込みます。</p> <p>ファイルに書式化文字列を書き込みます。</p>
<pre> <pre>
int f_printf ( int f_printf (
FIL* <span class="arg">fp</span>, <span class="c">/* [IN] ファイルオブジェクト */</span> FIL* <span class="arg">fp</span>, <span class="c">/* [IN] ファイル オブジェクト */</span>
const TCHAR* <span class="arg">fmt</span>, <span class="c">/* [IN] 書式制御文字列 */</span> const TCHAR* <span class="arg">fmt</span>, <span class="c">/* [IN] 書式制御文字列 */</span>
... ...
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>fp</dt> <dt>fp</dt>
<dd>ファイルオブジェクト構造体へのポインタを指定します。</dd> <dd>ファイル オブジェクト構造体へのポインタを指定します。</dd>
<dt>fmt</dt> <dt>fmt</dt>
<dd>ヌル文字<tt>'\0'</tt>終端の書式制御文字列を指すポインタを指定します。ヌル文字は書き込まれません。</dd> <dd>ヌル文字<tt>'\0'</tt>終端の書式制御文字列を指すポインタを指定します。ヌル文字は書き込まれません。</dd>
<dt>...</dt> <dt>...</dt>
<dd>オプションの引数。</dd> <dd>オプションの引数。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p>文字列が正常に書き込まれると、書き込まれた文字数が返されます。ディスクが満杯またはその他エラーにより正常に書き込まれなかったときは、関数は失敗し<tt>EOF (-1)</tt>が返されます。</p> <p>文字列が正常に書き込まれると、書き込まれた文字数が返されます。ディスクが満杯またはその他エラーにより正常に書き込まれなかったときは、関数は失敗し<tt>EOF (-1)</tt>が返されます。</p>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>この関数は、<a href="putc.html"><tt>f_putc()</tt></a>および<a href="puts.html"><tt>f_puts()</tt></a>のラッパー関数です。書式制御機能はC標準ライブラリのサブセットとなっていて、書式制御文字は次に示すものが使用可能です。</p> <p>書式制御機能はC標準ライブラリのサブセットとなっていて、書式制御文字は次に示すものが使用可能です。</p>
<ul> <ul>
<li>タイプ: <tt>c C s S d D u U x X b B</tt></li> <li>タイプ: <tt>c C s S d D u U x X b B</tt></li>
<li>精度指定: <tt>l L</tt></li> <li>精度指定: <tt>l L</tt></li>
<li>フラグ: <tt>0 -</tt></li> <li>フラグ: <tt>0 -</tt></li>
</ul> </ul>
</div> </div>
<div class="para comp"> <div class="para comp">
<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>この関数は、<a href="putc.html"><tt>f_putc</tt></a>関数および<a href="puts.html"><tt>f_puts</tt></a>関数のラッパー関数です。<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)されているときは、<span class="arg">fmt</span>はUnicode文字列になりますが、ファイル上のエンコードは、<tt>_STRF_ENCODE</tt>オプションで選択できます。それ以外の時は無変換(1バイト/1文字)で書き込みます。</p> <p>APIにUnicodeが選択(<tt>_LFN_UNICODE</tt>が1)されているときは、<tt class="arg">fmt</tt>はUnicode文字列になりますが、ファイル上のエンコードは、<tt>_STRF_ENCODE</tt>オプションで選択できます。それ以外の時は無変換(1バイト/1文字)で書き込みます。</p>
</div> </div>
<div class="para use"> <div class="para use">
<h4>使用例</h4> <h4>使用例</h4>
<pre> <pre>
f_printf(&amp;fil, "%d", 1234); <span class="c">/* "1234" */</span> f_printf(&amp;fil, "%d", 1234); <span class="c">/* "1234" */</span>
f_printf(&amp;fil, "%6d,%3d%%", -200, 5); <span class="c">/* " -200, 5%" */</span> f_printf(&amp;fil, "%6d,%3d%%", -200, 5); <span class="c">/* " -200, 5%" */</span>
f_printf(&amp;fil, "%-6u", 100); <span class="c">/* "100 " */</span> f_printf(&amp;fil, "%ld", 12345L); <span class="c">/* "12345" */</span>
f_printf(&amp;fil, "%ld", 12345678L); <span class="c">/* "12345678" */</span> f_printf(&amp;fil, "%06d", 25); <span class="c">/* "000025" */</span>
f_printf(&amp;fil, "%04x", 0xAB); <span class="c">/* "00ab" */</span> f_printf(&amp;fil, "%06d", -25); <span class="c">/* "000-25" */</span>
f_printf(&amp;fil, "%-6d", 25); <span class="c">/* "25 " */</span>
f_printf(&amp;fil, "%u", -1); <span class="c">/* "65535" or "4294967295" */</span>
f_printf(&amp;fil, "%04x", 0xAB3); <span class="c">/* "0ab3" */</span>
f_printf(&amp;fil, "%08LX", 0x123ABCL); <span class="c">/* "00123ABC" */</span> f_printf(&amp;fil, "%08LX", 0x123ABCL); <span class="c">/* "00123ABC" */</span>
f_printf(&amp;fil, "%016b", 0x550F); <span class="c">/* "0101010100001111" */</span> f_printf(&amp;fil, "%016b", 0x550F); <span class="c">/* "0101010100001111" */</span>
f_printf(&amp;fil, "%s", "String"); <span class="c">/* "String" */</span> f_printf(&amp;fil, "%s", "String"); <span class="c">/* "String" */</span>
f_printf(&amp;fil, "%5s", "abc"); <span class="c">/* " abc" */</span> f_printf(&amp;fil, "%8s", "abc"); <span class="c">/* " abc" */</span>
f_printf(&amp;fil, "%-5s", "abc"); <span class="c">/* "abc " */</span> f_printf(&amp;fil, "%-8s", "abc"); <span class="c">/* "abc " */</span>
f_printf(&amp;fil, "%c", 'a'); <span class="c">/* "a" */</span> f_printf(&amp;fil, "%c", 'a'); <span class="c">/* "a" */</span>
f_printf(&amp;fil, "%f", 10.0); <span class="c">/* 浮動小数点は未サポート */</span> f_printf(&amp;fil, "%f", 10.0); <span class="c">/* 浮動小数点は未サポート */</span>
</pre> </pre>
</div> </div>
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<p><tt><a href="open.html">f_open</a>, <a href="putc.html">f_putc</a>, <a href="puts.html">f_puts</a>, <a href="gets.html">f_gets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p> <p><tt><a href="open.html">f_open</a>, <a href="putc.html">f_putc</a>, <a href="puts.html">f_puts</a>, <a href="gets.html">f_gets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>
+16 -16
View File
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="ja"> <html lang="ja">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"> <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/putc.html"> <link rel="alternate" hreflang="en" title="English" href="../en/putc.html">
@@ -13,50 +13,50 @@
<div class="para func"> <div class="para func">
<h2>f_putc</h2> <h2>f_putc</h2>
<p>ファイルに文字を書き込みます。</p> <p>ファイルに文字を書き込みます。</p>
<pre> <pre>
int f_putc ( int f_putc (
TCHAR <span class="arg">chr</span>, <span class="c">/* [IN] 書き込む文字 */</span> TCHAR <span class="arg">chr</span>, <span class="c">/* [IN] 書き込む文字 */</span>
FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイルオブジェクト */</span> FIL* <span class="arg">fp</span> <span class="c">/* [IN] ファイル オブジェクト */</span>
); );
</pre> </pre>
</div> </div>
<div class="para arg"> <div class="para arg">
<h4>引数</h4> <h4>引数</h4>
<dl class="par"> <dl class="par">
<dt>chr</dt> <dt>chr</dt>
<dd>書き込む文字を指定します。</dd> <dd>書き込む文字を指定します。</dd>
<dt>fp</dt> <dt>fp</dt>
<dd>ファイルオブジェクト構造体へのポインタを指定します。</dd> <dd>ファイル オブジェクト構造体へのポインタを指定します。</dd>
</dl> </dl>
</div> </div>
<div class="para ret"> <div class="para ret">
<h4>戻り値</h4> <h4>戻り値</h4>
<p>文字が正常に書き込まれると書き込んだ文字数が返されます。ディスクが満杯またはエラーにより書き込まれなかったときは<tt>EOF (-1)</tt>が返されます。</p> <p>文字が正常に書き込まれると書き込んだ文字数が返されます。ディスクが満杯またはエラーにより書き込まれなかったときは<tt>EOF (-1)</tt>が返されます。</p>
<p>APIにUnicodeが選択(<tt>_LFN_UNICODE</tt>が1)されているときは、<span class="arg">chr</span>はUTF-16文字になりますが、ファイル上のエンコードは、<tt>_STRF_ENCODE</tt>オプションで選択できます。それ以外の時は無変換(1バイト/1文字)で書き込みます。</p> <p>APIにUnicodeが選択(<tt>_LFN_UNICODE</tt>が1)されているときは、<tt class="arg">chr</tt>はUTF-16文字になりますが、ファイル上のエンコードは、<tt>_STRF_ENCODE</tt>オプションで選択できます。それ以外の時は無変換(1バイト/1文字)で書き込みます。</p>
</div> </div>
<div class="para desc"> <div class="para desc">
<h4>解説</h4> <h4>解説</h4>
<p>1文字をファイルに書き込みます。この関数は<a href="write.html"><tt>f_write()</tt></a>のラッパー関数です。</p> <p>1文字をファイルに書き込みます。</p>
</div> </div>
<div class="para comp"> <div class="para comp">
<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>この関数は<a href="write.html"><tt>f_write</tt></a>関数のラッパー関数です。<tt>_FS_READONLY == 0</tt>で、且つ<tt>_USE_STRFUNC</tt>が 1または 2のとき使用可能です。2を指定すると、<tt>'\n'</tt><tt>'\r'+'\n'</tt>に展開されてファイルに書き込まれます。</p>
</div> </div>
<div class="para ref"> <div class="para ref">
<h4>参照</h4> <h4>参照</h4>
<p><tt><a href="open.html">f_open</a>, <a href="puts.html">f_puts</a>, <a href="printf.html">f_printf</a>, <a href="gets.html">f_gets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p> <p><tt><a href="open.html">f_open</a>, <a href="puts.html">f_puts</a>, <a href="printf.html">f_printf</a>, <a href="gets.html">f_gets</a>, <a href="close.html">f_close</a>, <a href="sfile.html">FIL</a></tt></p>
</div> </div>
<p class="foot"><a href="../00index_j.html">戻る</a></p> <p class="foot"><a href="../00index_j.html">戻る</a></p>
</body> </body>
</html> </html>

Some files were not shown because too many files have changed in this diff Show More