]> cloudbase.mooo.com Git - z180-stamp.git/blame_incremental - fatfs/documents/doc/findfirst.html
Adaptions for fatfs R0.15
[z180-stamp.git] / fatfs / documents / doc / findfirst.html
... / ...
CommitLineData
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/findfirst.html">\r
8<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">\r
9<title>FatFs - f_findfirst</title>\r
10</head>\r
11\r
12<body>\r
13\r
14<div class="para func">\r
15<h2>f_findfirst</h2>\r
16<p>The f_findfirst function searches a directroy for an item.</p>\r
17<pre>\r
18FRESULT f_findfirst (\r
19 DIR* <span class="arg">dp</span>, <span class="c">/* [OUT] Poninter to the directory object */</span>\r
20 FILINFO* <span class="arg">fno</span>, <span class="c">/* [OUT] Pointer to the file information structure */</span>\r
21 const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Pointer to the directory name to be opened */</span>\r
22 const TCHAR* <span class="arg">pattern</span> <span class="c">/* [IN] Pointer to the matching pattern string */</span>\r
23);\r
24</pre>\r
25</div>\r
26\r
27<div class="para arg">\r
28<h4>Parameters</h4>\r
29<dl class="par">\r
30<dt>dp</dt>\r
31<dd>Pointer to the blank directory object.</dd>\r
32<dt>fno</dt>\r
33<dd>Pointer to the <a href="sfileinfo.html">file information structure</a> to store the information about the found item.</dd>\r
34<dt>path</dt>\r
35<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">directory name</a> to be opened.</dd>\r
36<dt>pattern</dt>\r
37<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>\r
38</dl>\r
39</div>\r
40\r
41\r
42<div class="para ret">\r
43<h4>Return Values</h4>\r
44<p>\r
45<a href="rc.html#ok">FR_OK</a>,\r
46<a href="rc.html#de">FR_DISK_ERR</a>,\r
47<a href="rc.html#ie">FR_INT_ERR</a>,\r
48<a href="rc.html#nr">FR_NOT_READY</a>,\r
49<a href="rc.html#np">FR_NO_PATH</a>,\r
50<a href="rc.html#in">FR_INVALID_NAME</a>,\r
51<a href="rc.html#io">FR_INVALID_OBJECT</a>,\r
52<a href="rc.html#id">FR_INVALID_DRIVE</a>,\r
53<a href="rc.html#ne">FR_NOT_ENABLED</a>,\r
54<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,\r
55<a href="rc.html#tm">FR_TIMEOUT</a>,\r
56<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>,\r
57<a href="rc.html#tf">FR_TOO_MANY_OPEN_FILES</a>\r
58</p>\r
59</div>\r
60\r
61\r
62<div class="para desc">\r
63<h4>Description</h4>\r
64<p>After the directory specified by <tt class="arg">path</tt> could be opened, it starts to search the directory for items with the matching pattern specified by <tt class="arg">pattern</tt>. If the first item is found, the information about the item is stored into the file information structure <tt class="arg">fno</tt>. If not found, <tt>fno-&gt;fname[]</tt> has a null string.</p>\r
65<p>The matching pattern string can contain wildcards. For example:</p>\r
66<ul>\r
67<li><tt>?</tt> - An any character.</li>\r
68<li><tt>???</tt> - An any string in length of three characters.</li>\r
69<li><tt>*</tt> - An any string in length of zero or longer.</li>\r
70<li><tt>????*</tt> - An any string in length of four characters or longer.</li>\r
71</ul>\r
72<p>Since the matching algorithm uses recursion, number of wildcards in the matching pattern is limited to four to limit the stack usage. Any pattern with too many wildcards does not match any name. In LFN configuration, only <tt>fname[]</tt> is tested when <tt>FF_USE_FIND == 1</tt> and also <tt>altname[]</tt> is tested when <tt>FF_USE_FIND == 2</tt>. There are some differences listed below between FatFs and standard systems in matching condition.</p>\r
73<ul>\r
74<li><tt>"*.*"</tt> does not match any name without extension while it matches any name with or without extension in standard systems.</li>\r
75<li>Any pattern terminated with a dot does not match any name while it matches the name without extensiton in standard systems.</li>\r
76<li><a href="filename.html#case">DBCS extended characters</a> are compared in case-sensitive when LFN is enabled with <tt>!FF_LFN_UNICODE</tt>.</li>\r
77</ul>\r
78</div>\r
79\r
80\r
81<div class="para comp">\r
82<h4>QuickInfo</h4>\r
83<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><a href="config.html#use_find">FF_USE_FIND</a> &gt;= 1</tt> and <tt><a href="config.html#fs_minimize">FF_FS_MINIMIZE</a> &lt;= 1</tt>.</p>\r
84</div>\r
85\r
86\r
87<div class="para use">\r
88<h4>Examples</h4>\r
89<pre>\r
90<span class="c">/* Search a directory for objects and display it */</span>\r
91\r
92void find_image_file (void)\r
93{\r
94 FRESULT fr; <span class="c">/* Return value */</span>\r
95 DIR dj; <span class="c">/* Directory object */</span>\r
96 FILINFO fno; <span class="c">/* File information */</span>\r
97\r
98 fr = <em>f_findfirst</em>(&amp;dj, &amp;fno, "", "????????.JPG"); <span class="c">/* Start to search for photo files */</span>\r
99\r
100 while (fr == FR_OK &amp;&amp; fno.fname[0]) { <span class="c">/* Repeat while an item is found */</span>\r
101 printf("%s\n", fno.fname); <span class="c">/* Print the object name */</span>\r
102 fr = f_findnext(&amp;dj, &amp;fno); <span class="c">/* Search for next item */</span>\r
103 }\r
104\r
105 f_closedir(&amp;dj);\r
106}\r
107</pre>\r
108</div>\r
109\r
110\r
111<div class="para ref">\r
112<h4>See Also</h4>\r
113<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>\r
114</div>\r
115\r
116<p class="foot"><a href="../00index_e.html">Return</a></p>\r
117</body>\r
118</html>\r