]> cloudbase.mooo.com Git - z180-stamp.git/blame - fatfs/documents/doc/filename.html
Import fatfs R0.13b
[z180-stamp.git] / fatfs / documents / doc / filename.html
CommitLineData
289f6a14
L
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\r
2<html lang="en">\r
3<head>\r
4<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\r
5<meta http-equiv="Content-Style-Type" content="text/css">\r
6<link rel="up" title="FatFs" href="../00index_e.html">\r
7<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/filename.html">\r
8<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">\r
9<title>FatFs - Path Names</title>\r
10</head>\r
11\r
12<body>\r
13<h1>Path Names on the FatFs</h1>\r
14\r
15<div class="para doc" id="nam">\r
16<h3>Format of the Path Names</h3>\r
17<p>The format of path name on the FatFs module is similer to the filename specs of DOS/Windos as follows:</p>\r
18<pre>[<em>drive#</em>:][/]<em>directory</em>/<em>file</em></pre>\r
19<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">FF_USE_LFN</a> &gt;= 1</tt>. The sub directories are separated with a <tt>\</tt> or <tt>/</tt> in the same way as DOS/Windows API. Duplicated separators are skipped and ignored. Only a difference is that the heading drive prefix to specify logical drive is in a numeral + colon. When drive prefix is omitted, the drive number is assumed as <em>default drive</em> (drive 0 or current drive).</p>\r
20<p>Control characters (<tt>\0</tt> to <tt>\x1F</tt>) are recognized as end of the path name. Leading/embedded white spaces in the path name are valid as a part of the name at LFN configuration but the white space is recognized as end of the path name at non-LFN configuration. Trailing white spaces and dots are ignored at both configurations.</p>\r
21<p>In default configuration (<tt><a href="config.html#fs_rpath">FF_FS_RPATH</a> == 0</tt>), it does not have a concept of current directory like OS oriented filesystem. Every object on the volume is always specified in full path name that followed 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>\r
22<p>When relative path is enabled (<tt>FF_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"><tt>f_chdir</tt></a> function. Dot names are also allowed for the path names. The default drive is the current drive set by <a href="chdrive.html"><tt>f_chdrive</tt></a> function.</p>\r
23<table class="lst2">\r
24<tr><td>Path name</td><td>FF_FS_RPATH == 0</td><td>FF_FS_RPATH &gt;= 1</td></tr>\r
25<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>\r
26<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>\r
27<tr><td></td><td>The root directory of the drive 0</td><td>The current directory of the current drive</td></tr>\r
28<tr><td>/</td><td>The root directory of the drive 0</td><td>The root directory of the current drive</td></tr>\r
29<tr><td>2:</td><td>The root directory of the drive 2</td><td>The current directory of the drive 2</td></tr>\r
30<tr><td>2:/</td><td>The root directory of the drive 2</td><td>The root directory of the drive 2</td></tr>\r
31<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>\r
32<tr><td>../file.txt</td><td>Invalid name</td><td>A file in the parent directory</td></tr>\r
33<tr><td>.</td><td>Invalid name</td><td>This directory</td></tr>\r
34<tr><td>..</td><td>Invalid name</td><td>Parent directory of the current directory (*)</td></tr>\r
35<tr><td>dir1/..</td><td>Invalid name</td><td>The current directory</td></tr>\r
36<tr><td>/..</td><td>Invalid name</td><td>The root directory (sticks the top level)</td></tr>\r
37</table>\r
38<p>Also the drive prefix can be in pre-defined arbitrary string. When the option <tt><a href="config.html#str_volume_id">FF_STR_VOLUME_ID</a> == 1</tt>, also arbitrary string volume ID can be used as drive prefix. e.g. <tt>"flash:file1.txt"</tt>, <tt>"ram:temp.dat"</tt> or <tt>"usb:"</tt>. When <tt>FF_STR_VOLUME_ID == 2</tt>, Unix style drive prefix can be used. e.g. <tt>"/flash/file1.txt"</tt>, <tt>"/ram/temp.dat"</tt> or <tt>"/usb"</tt>. However, it cannot traverse the drives such as <tt>"/flash/../ram/temp.dat"</tt>. The Unix style drive prefix may lead a confusion in identification between volume ID and file name. For instance, which does <tt>"/flash"</tt> mean, a file <tt>"flash"</tt> on the root directory without drive prefix or a drive prefix of <tt>"flash"</tt>? If the string following a heading slash matches with any volume ID, it is treated as a drive prefix and skipped over.</p>\r
39\r
40<p><em>Remark: In this revision, double dot name <tt>".."</tt> cannot follow the parent directory on the exFAT volume. It will work as <tt>"."</tt> and stay there.</em></p>\r
41</div>\r
42\r
43<div class="para doc" id="case">\r
44<h3>Legal Characters and Case Sensitivity</h3>\r
45<p>On the FAT filesystem, legal characters for object name (file/directory name) are, <tt>0-9 A-Z ! # $ % &amp; ' ( ) - @ ^ _ ` { } ~</tt> and extended characters (<tt>\x80</tt>-<tt>\xFF</tt>). Under LFN supported system, also <tt>+ , ; = [ ]</tt> and white space are legal for the object name and the white spaces and dots can be placed anywhere in the path name except for end of the object name.</p>\r
46<p>FAT filesystem is case-insensitive to the object names on the volume. Object name on the FAT volume is compared in case-insensitive. For instance, these three names, <tt>file.txt</tt>, <tt>File.Txt</tt> and <tt>FILE.TXT</tt>, are identical. This is applied to extended charactres as well. When an object is created on the FAT volume, up converted name is recorded to the SFN entry, and the raw name is recorded to the LFN entry when LFN function is enabled.</p>\r
47<p>As for the MS-DOS and PC DOS for CJK, it was case-sensitive to the DBCS 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 the extended character (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>\r
48</div>\r
49\r
50<div class="para doc" id="uni">\r
51<h3>Unicode API</h3>\r
52<p>The path names are input/output in either ANSI/OEM code or Unicode depends on the configuration options. The type of arguments which specifies the path names is defined as <tt>TCHAR</tt>. It is an alias of <tt>char</tt> by default and the code set used for the path name string is ANSI/OEM specifid by <tt><a href="config.html#code_page">FF_CODE_PAGE</a></tt>. When <tt><a href="config.html#lfn_unicode">FF_LFN_UNICODE</a></tt> is set to 1, the type of the <tt>TCHAR</tt> is switched to <tt>WCHAR</tt> to support UTF-16 encoded Unicode string. When UTF-16 or UTF-8 is specified by this option, 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>\r
53<pre>\r
54 f_open(fp, "filename.txt", FA_READ); <span class="c">/* ANSI/OEM string (char) */</span>\r
55 f_open(fp, L"filename.txt", FA_READ); <span class="c">/* UTF-16 string (WCHAR) */</span>\r
56 f_open(fp, u8"filename.txt", FA_READ); <span class="c">/* UTF-8 string (char) */</span>\r
57 f_open(fp, U"filename.txt", FA_READ); <span class="c">/* UTF-32 string (DWORD) */</span>\r
58 f_open(fp, _T("filename.txt"), FA_READ); <span class="c">/* Changed by configuration (TCHAR) */</span>\r
59</pre>\r
60</div>\r
61\r
62<div class="para doc" id="vol">\r
63<h3>Volume Management</h3>\r
64<p>FatFs module requires dynamic work area, <em>filesystem object</em>, for each volume (logical drive). It is registered/unregistered 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 the volume mount process. It reads 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>\r
65<p>When <tt><a href="config.html#multi_partition">FF_MULTI_PARTITION = 1</a></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 needs to be defined by user to resolve the mappings of logical drives and partitions. Following code is an example of a volume management table.</p>\r
66<pre>\r
67Example: "0:", "1:" and "2:" are tied to three pri-partitions on the physical drive 0 (fixed drive)\r
68 "3:" is tied to an FAT volume on the physical drive 1 (removable drive)\r
69\r
70PARTITION VolToPart[FF_VOLUMES] = {\r
71 {0, 1}, <span class="c">/* "0:" ==> Physical drive 0, 1st partition */</span>\r
72 {0, 2}, <span class="c">/* "1:" ==> Physical drive 0, 2nd partition */</span>\r
73 {0, 3}, <span class="c">/* "2:" ==> Physical drive 0, 3rd partition */</span>\r
74 {1, 0} <span class="c">/* "3:" ==> Physical drive 1, auto detection */</span>\r
75};\r
76</pre>\r
77<div><img src="../res/f7.png" width="900" height="288" alt="relationship between logical drive and physical drive"></div>\r
78<p>There are some considerations on using multi-partition configuration.</p>\r
79<ul>\r
80<li>The physical drive that has two or more mounted partitions must be non-removable. Media change while a system operation is prohibited.</li>\r
81<li>Only four primary partitions can be specified. Extended partition is not supported.</li>\r
82<li>Windows does not support multiple volumes on the removable storage. Only first parition will be recognized.</li>\r
83</ul>\r
84</div>\r
85\r
86<p class="foot"><a href="../00index_e.html">Return</a></p>\r
87</body>\r
88</html>\r