\r
<div class="para desc">\r
<h4>Description</h4>\r
-<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
+<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
</div>\r
\r
\r
</div>\r
\r
\r
+<div class="para use">\r
+<h4>Example</h4>\r
+<pre>\r
+ FRESULT fr;\r
+ FILINFO fno;\r
+\r
+\r
+ printf("Test for 'file.txt'...\n");\r
+\r
+ fr = f_stat("file.txt", &fno);\r
+ switch (fr) {\r
+\r
+ case FR_OK:\r
+ printf("Size: %lu\n", fno.fsize);\r
+ printf("Timestamp: %u/%02u/%02u, %02u:%02u\n",\r
+ (fno.fdate >> 9) + 1980, fno.fdate >> 5 & 15, fno.fdate & 31,\r
+ fno.ftime >> 11, fno.ftime >> 5 & 63);\r
+ printf("Attributes: %c%c%c%c%c\n",\r
+ (fno.fattrib & AM_DIR) ? 'D' : '-',\r
+ (fno.fattrib & AM_RDO) ? 'R' : '-',\r
+ (fno.fattrib & AM_HID) ? 'H' : '-',\r
+ (fno.fattrib & AM_SYS) ? 'S' : '-',\r
+ (fno.fattrib & AM_ARC) ? 'A' : '-');\r
+ break;\r
+\r
+ case FR_NO_FILE:\r
+ printf("It is not exist.\n");\r
+ break;\r
+\r
+ default:\r
+ printf("An error occured. (%d)\n", fr);\r
+ }\r
+</pre>\r
+</div>\r
+\r
+\r
<div class="para ref">\r
<h4>References</h4>\r
<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