summaryrefslogtreecommitdiff
path: root/fatfs/doc/en/readdir.html
diff options
context:
space:
mode:
Diffstat (limited to 'fatfs/doc/en/readdir.html')
-rw-r--r--fatfs/doc/en/readdir.html64
1 files changed, 34 insertions, 30 deletions
diff --git a/fatfs/doc/en/readdir.html b/fatfs/doc/en/readdir.html
index bf83ebe..235beee 100644
--- a/fatfs/doc/en/readdir.html
+++ b/fatfs/doc/en/readdir.html
@@ -13,7 +13,7 @@
<div class="para func">
<h2>f_readdir</h2>
-<p>The f_readdir function reads directory entries.</p>
+<p>The f_readdir function reads an item of the directory.</p>
<pre>
FRESULT f_readdir (
DIR* <span class="arg">dp</span>, <span class="c">/* [IN] Directory object */</span>
@@ -26,9 +26,9 @@ FRESULT f_readdir (
<h4>Parameters</h4>
<dl class="par">
<dt>dp</dt>
-<dd>Pointer to the open directory object.</dd>
+<dd>Pointer to the open directory object or null pointer.</dd>
<dt>fno</dt>
-<dd>Pointer to the file information structure to store the read item.</dd>
+<dd>Pointer to the <a href="sfileinfo.html">file information structure</a> to store the information about read item.</dd>
</dl>
</div>
@@ -39,7 +39,6 @@ FRESULT f_readdir (
<a href="rc.html#ok">FR_OK</a>,
<a href="rc.html#de">FR_DISK_ERR</a>,
<a href="rc.html#ie">FR_INT_ERR</a>,
-<a href="rc.html#nr">FR_NOT_READY</a>,
<a href="rc.html#io">FR_INVALID_OBJECT</a>,
<a href="rc.html#tm">FR_TIMEOUT</a>,
<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
@@ -49,14 +48,14 @@ FRESULT f_readdir (
<div class="para desc">
<h4>Description</h4>
-<p>The <tt>f_readdir()</tt> function reads directory items, file and directory, in sequence. All items in the directory can be read by calling <tt>f_readdir()</tt> function repeatedly. When relative path feature is enabled (<tt>_FS_RPATH &gt;= 1</tt>), dot entries ("." and "..") are not filtered out and they will appear in the read items. When all directory items have been read and no item to read, a null string is returned into the <tt>fname[]</tt> without any error. When a null pointer is given to the <tt class="arg">fno</tt>, the read index of the directory object is rewinded.</p>
-<p>When LFN feature is enabled, <tt>lfname</tt> and <tt>lfsize</tt> in the file information structure must be initialized with valid value prior to use it. The <tt>lfname</tt> is a pointer to the LFN read buffer. The <tt>lfsize</tt> is size of the LFN read buffer in unit of <tt>TCHAR</tt>. If the LFN is not needed, set a null pointer to the <tt>lfname</tt> and the LFN is not returned. A null string will be returned into the LFN read buffer in case of following conditions.</p>
+<p>The <tt>f_readdir</tt> function reads a directory item, informations about the object. All items in the directory can be read in sequence by <tt>f_readdir</tt> function calls. Dot entries (<tt>"."</tt> and <tt>".."</tt>) in the sub-directory are filtered out and they will never appear in the read items. When all directory items have been read and no item to read, a nul string is stored into the <tt>fno-&gt;fname[]</tt> without any error. When a null pointer is given to the <tt class="arg">fno</tt>, the read index of the directory object is rewinded.</p>
+<p>When support of long file name (LFN) is enabled, a member <tt>altname[]</tt> is defined in the file information structure to store the short file name of the object. In case of the some conditions listed below, short file name is stored into the <tt>fname[]</tt> and <tt>altname[]</tt> has a null string.</p>
<ul>
-<li>The directory item has no LFN information.</li>
-<li>Either the size of read buffer or LFN working buffer is insufficient for the LFN.</li>
-<li>The LFN contains any Unicode character that cannot be converted to OEM code. (not the case at Unicode API cfg.)</li>
+<li>The item has no long file name. (Not the case at exFAT volume)</li>
+<li>Setting of <tt>_MAX_LFN</tt> is insufficient for the long file name. (Not the case at <tt>_MAX_LFN == 255</tt>)</li>
+<li>The long file name contains any character not allowed in ANSI/OEM code. (Not the case at <tt>_LFN_UNICODE == 1</tt>)</li>
</ul>
-<p>When the directory item has no LFN information, lower case characters can be contained in the <tt>fname[]</tt>.</p>
+<p>There is a problem on reading a directory of exFAT volume. The exFAT does not support short file name. This means no name can be returned on the condition above. If it is the case, a "?" is returned as file name to indicate that the object is not accessible. To avoid this problem, configure FatFs <tt>_LFN_UNICODE = 1</tt> and <tt>_MAX_LFN = 255</tt> to support the full feature of LFN specification.</p>
</div>
@@ -70,40 +69,28 @@ FRESULT f_readdir (
<h4>Sample Code</h4>
<pre>
FRESULT scan_files (
- char* path <span class="c">/* Start node to be scanned (also used as work area) */</span>
+ char* path <span class="c">/* Start node to be scanned (***also used as work area***) */</span>
)
{
FRESULT res;
- FILINFO fno;
DIR dir;
- int i;
- char *fn; <span class="c">/* This function assumes non-Unicode configuration */</span>
-<span class="k">#if</span> _USE_LFN
- static char lfn[_MAX_LFN + 1]; <span class="c">/* Buffer to store the LFN */</span>
- fno.lfname = lfn;
- fno.lfsize = sizeof lfn;
-<span class="k">#endif</span>
+ UINT i;
+ static FILINFO fno;
res = f_opendir(&amp;dir, path); <span class="c">/* Open the directory */</span>
if (res == FR_OK) {
- i = strlen(path);
for (;;) {
res = f_readdir(&amp;dir, &amp;fno); <span class="c">/* Read a directory item */</span>
if (res != FR_OK || fno.fname[0] == 0) break; <span class="c">/* Break on error or end of dir */</span>
- if (fno.fname[0] == '.') continue; <span class="c">/* Ignore dot entry */</span>
-<span class="k">#if</span> _USE_LFN
- fn = *fno.lfname ? fno.lfname : fno.fname;
-<span class="k">#else</span>
- fn = fno.fname;
-<span class="k">#endif</span>
if (fno.fattrib &amp; AM_DIR) { <span class="c">/* It is a directory */</span>
- sprintf(&amp;path[i], "/%s", fn);
- res = scan_files(path);
- path[i] = 0;
+ i = strlen(path);
+ sprintf(&amp;path[i], "/%s", fno.fname);
+ res = scan_files(path); <span class="c">/* Enter the directory */</span>
if (res != FR_OK) break;
+ path[i] = 0;
} else { <span class="c">/* It is a file. */</span>
- printf("%s/%s\n", path, fn);
+ printf("%s/%s\n", path, fno.fname);
}
}
f_closedir(&amp;dir)
@@ -111,6 +98,23 @@ FRESULT scan_files (
return res;
}
+
+
+int main (void)
+{
+ FATFS fs;
+ FRESULT res;
+ char buff[256];
+
+
+ res = f_mount(&amp;fs, "", 1);
+ if (res == FR_OK) {
+ strcpy(buff, "/");
+ res = scan_files(buff);
+ }
+
+ return res;
+}
</pre>
</div>