]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - fatfs/doc/en/stat.html
Merge tag 'fatfs-0.10c'
[z180-stamp.git] / fatfs / doc / en / stat.html
index 8ea343b8339ccec29b9e88abee08c4733dd91706..db53c5d54b0b82a756416e48ac58adb79c9ce5d9 100644 (file)
@@ -55,6 +55,7 @@ FRESULT f_stat (
 <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>When LFN feature is enabled, <tt>lfname</tt> in the file information structure must be NULLed prior to use it.</p>\r
 </div>\r
 \r
 \r
@@ -64,6 +65,45 @@ 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
+<span class="k">#if</span> _USE_LFN\r
+    fno.lfname = 0;\r
+<span class="k">#endif</span>\r
+    fr = f_stat("file.txt", &amp;fno);\r
+    switch (fr) {\r
+\r
+    case FR_OK:\r
+        printf("Size: %u\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 & 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