]> cloudbase.mooo.com Git - z180-stamp.git/blame - fatfs/doc/en/stat.html
Import fatfs R0.10c
[z180-stamp.git] / fatfs / doc / en / 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
4<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\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.</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 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
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, 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>\r
7b78a5a2 58<p>When LFN feature is enabled, <tt>lfname</tt> in the file information structure must be NULLed prior to use it.</p>\r
53668523
L
59</div>\r
60\r
61\r
62<div class="para comp">\r
63<h4>QuickInfo</h4>\r
64<p>Available when <tt>_FS_MINIMIZE == 0</tt>.</p>\r
65</div>\r
66\r
67\r
7b78a5a2
L
68<div class="para use">\r
69<h4>Example</h4>\r
70<pre>\r
71 FRESULT fr;\r
72 FILINFO fno;\r
73\r
74\r
75 printf("Test for 'file.txt'...\n");\r
76\r
77<span class="k">#if</span> _USE_LFN\r
78 fno.lfname = 0;\r
79<span class="k">#endif</span>\r
80 fr = f_stat("file.txt", &amp;fno);\r
81 switch (fr) {\r
82\r
83 case FR_OK:\r
84 printf("Size: %u\n", fno.fsize);\r
85 printf("Timestamp: %u/%02u/%02u, %02u:%02u\n",\r
86 (fno.fdate &gt;&gt; 9) + 1980, fno.fdate &gt;&gt; 5 &amp; 15, fno.fdate &amp; 31,\r
87 fno.ftime &gt;&gt; 11, fno.ftime &gt;&gt; 5 &amp; 63);\r
88 printf("Attributes: %c%c%c%c%c\n",\r
89 (fno.fattrib & AM_DIR) ? 'D' : '-',\r
90 (fno.fattrib & AM_RDO) ? 'R' : '-',\r
91 (fno.fattrib & AM_HID) ? 'H' : '-',\r
92 (fno.fattrib & AM_SYS) ? 'S' : '-',\r
93 (fno.fattrib & AM_ARC) ? 'A' : '-');\r
94 break;\r
95\r
96 case FR_NO_FILE:\r
97 printf("It is not exist.\n");\r
98 break;\r
99\r
100 default:\r
101 printf("An error occured. (%d)\n", fr);\r
102 }\r
103</pre>\r
104</div>\r
105\r
106\r
53668523
L
107<div class="para ref">\r
108<h4>References</h4>\r
109<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
110</div>\r
111\r
112<p class="foot"><a href="../00index_e.html">Return</a></p>\r
113</body>\r
114</html>\r