]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - fatfs/doc/en/stat.html
Import fatfs R0.12b
[z180-stamp.git] / fatfs / doc / en / stat.html
index 8ea343b8339ccec29b9e88abee08c4733dd91706..2924660ec475335f35df2cf7b32851f9536eacb8 100644 (file)
@@ -54,7 +54,7 @@ FRESULT f_stat (
 \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
@@ -64,6 +64,42 @@ FRESULT f_stat (
 </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", &amp;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 &gt;&gt; 9) + 1980, fno.fdate &gt;&gt; 5 &amp; 15, fno.fdate &amp; 31,\r
+               fno.ftime &gt;&gt; 11, fno.ftime &gt;&gt; 5 &amp; 63);\r
+        printf("Attributes: %c%c%c%c%c\n",\r
+               (fno.fattrib &amp; AM_DIR) ? 'D' : '-',\r
+               (fno.fattrib &amp; AM_RDO) ? 'R' : '-',\r
+               (fno.fattrib &amp; AM_HID) ? 'H' : '-',\r
+               (fno.fattrib &amp; AM_SYS) ? 'S' : '-',\r
+               (fno.fattrib &amp; 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