]> cloudbase.mooo.com Git - z180-stamp.git/blame - fatfs/documents/doc/stat.html
Merge branch 'chan-fatfs' into fatfs-integration
[z180-stamp.git] / fatfs / documents / doc / stat.html
CommitLineData
53668523
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
289f6a14 4<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\r
53668523
L
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/stat.html">\r
8<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">\r
9<title>FatFs - f_stat</title>\r
10</head>\r
11\r
12<body>\r
13\r
14<div class="para func">\r
15<h2>f_stat</h2>\r
16<p>The f_stat function checks the existence of a file or sub-directory.</p>\r
17<pre>\r
18FRESULT f_stat (\r
19 const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Object name */</span>\r
20 FILINFO* <span class="arg">fno</span> <span class="c">/* [OUT] FILINFO structure */</span>\r
21);\r
22</pre>\r
23</div>\r
24\r
25<div class="para arg">\r
26<h4>Parameters</h4>\r
27<dl class="par">\r
28<dt>path</dt>\r
289f6a14 29<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">object</a> to get its information. The object must not be the root direcotry.</dd>\r
53668523
L
30<dt>fno</dt>\r
31<dd>Pointer to the blank <tt>FILINFO</tt> structure to store the information of the object. Set null pointer if it is not needed.</dd>\r
32</dl>\r
33</div>\r
34\r
35\r
36<div class="para ret">\r
37<h4>Return Values</h4>\r
38<p>\r
39<a href="rc.html#ok">FR_OK</a>,\r
40<a href="rc.html#de">FR_DISK_ERR</a>,\r
41<a href="rc.html#ie">FR_INT_ERR</a>,\r
42<a href="rc.html#nr">FR_NOT_READY</a>,\r
43<a href="rc.html#ok">FR_NO_FILE</a>,\r
44<a href="rc.html#np">FR_NO_PATH</a>,\r
45<a href="rc.html#in">FR_INVALID_NAME</a>,\r
46<a href="rc.html#id">FR_INVALID_DRIVE</a>,\r
47<a href="rc.html#ne">FR_NOT_ENABLED</a>,\r
48<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,\r
49<a href="rc.html#tm">FR_TIMEOUT</a>,\r
50<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>\r
51</p>\r
52</div>\r
53\r
54\r
55<div class="para desc">\r
56<h4>Description</h4>\r
70702af1 57<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 and attribute, 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>\r
53668523
L
58</div>\r
59\r
60\r
61<div class="para comp">\r
62<h4>QuickInfo</h4>\r
289f6a14 63<p>Available when <tt><a href="config.html#fs_minimize">FF_FS_MINIMIZE</a> == 0</tt>.</p>\r
53668523
L
64</div>\r
65\r
66\r
7b78a5a2
L
67<div class="para use">\r
68<h4>Example</h4>\r
69<pre>\r
70 FRESULT fr;\r
71 FILINFO fno;\r
72\r
73\r
74 printf("Test for 'file.txt'...\n");\r
75\r
7b78a5a2
L
76 fr = f_stat("file.txt", &amp;fno);\r
77 switch (fr) {\r
78\r
79 case FR_OK:\r
70702af1 80 printf("Size: %lu\n", fno.fsize);\r
7b78a5a2
L
81 printf("Timestamp: %u/%02u/%02u, %02u:%02u\n",\r
82 (fno.fdate &gt;&gt; 9) + 1980, fno.fdate &gt;&gt; 5 &amp; 15, fno.fdate &amp; 31,\r
83 fno.ftime &gt;&gt; 11, fno.ftime &gt;&gt; 5 &amp; 63);\r
84 printf("Attributes: %c%c%c%c%c\n",\r
70702af1
L
85 (fno.fattrib &amp; AM_DIR) ? 'D' : '-',\r
86 (fno.fattrib &amp; AM_RDO) ? 'R' : '-',\r
87 (fno.fattrib &amp; AM_HID) ? 'H' : '-',\r
88 (fno.fattrib &amp; AM_SYS) ? 'S' : '-',\r
89 (fno.fattrib &amp; AM_ARC) ? 'A' : '-');\r
7b78a5a2
L
90 break;\r
91\r
92 case FR_NO_FILE:\r
93 printf("It is not exist.\n");\r
94 break;\r
95\r
96 default:\r
97 printf("An error occured. (%d)\n", fr);\r
98 }\r
99</pre>\r
100</div>\r
101\r
102\r
53668523
L
103<div class="para ref">\r
104<h4>References</h4>\r
105<p><tt><a href="opendir.html">f_opendir</a>, <a href="readdir.html">f_readdir</a>, <a href="sfileinfo.html">FILINFO</a></tt></p>\r
106</div>\r
107\r
108<p class="foot"><a href="../00index_e.html">Return</a></p>\r
109</body>\r
110</html>\r