]> cloudbase.mooo.com Git - z180-stamp.git/blame_incremental - fatfs/documents/doc/stat.html
Adaptions for fatfs R0.15
[z180-stamp.git] / fatfs / documents / doc / stat.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/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
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
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 this information 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
57<p>The <tt>f_stat</tt> function checks the existence of a file or sub-directory in the directory. If it is not exist, the function returns with <tt>FR_NO_FILE</tt>. If it is exist, the function returns with <tt>FR_OK</tt> and the informations about the object, size, timestamp and attribute, is 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
58<p>Note that the file information comes from the meta data in the directory. If the file has been opend and modified, the file will need to be synched or closed in order to obtain the latest file information.</p>\r
59</div>\r
60\r
61\r
62<div class="para comp">\r
63<h4>QuickInfo</h4>\r
64<p>Available when <tt><a href="config.html#fs_minimize">FF_FS_MINIMIZE</a> == 0</tt>.</p>\r
65</div>\r
66\r
67\r
68<div class="para use">\r
69<h4>Example</h4>\r
70<pre>\r
71 FRESULT fr;\r
72 FILINFO fno;\r
73 const char *fname = "file.txt";\r
74\r
75\r
76 printf("Test for \"%s\"...\n", fname);\r
77\r
78 fr = <em>f_stat</em>(fname, &amp;fno);\r
79 switch (fr) {\r
80\r
81 case FR_OK:\r
82 printf("Size: %lu\n", fno.fsize);\r
83 printf("Timestamp: %u-%02u-%02u, %02u:%02u\n",\r
84 (fno.fdate &gt;&gt; 9) + 1980, fno.fdate &gt;&gt; 5 &amp; 15, fno.fdate &amp; 31,\r
85 fno.ftime &gt;&gt; 11, fno.ftime &gt;&gt; 5 &amp; 63);\r
86 printf("Attributes: %c%c%c%c%c\n",\r
87 (fno.fattrib &amp; AM_DIR) ? 'D' : '-',\r
88 (fno.fattrib &amp; AM_RDO) ? 'R' : '-',\r
89 (fno.fattrib &amp; AM_HID) ? 'H' : '-',\r
90 (fno.fattrib &amp; AM_SYS) ? 'S' : '-',\r
91 (fno.fattrib &amp; AM_ARC) ? 'A' : '-');\r
92 break;\r
93\r
94 case FR_NO_FILE:\r
95 printf("\"%s\" is not exist.\n", fname);\r
96 break;\r
97\r
98 default:\r
99 printf("An error occured. (%d)\n", fr);\r
100 }\r
101</pre>\r
102</div>\r
103\r
104\r
105<div class="para ref">\r
106<h4>References</h4>\r
107<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
108</div>\r
109\r
110<p class="foot"><a href="../00index_e.html">Return</a></p>\r
111</body>\r
112</html>\r