FILINFO* <spanclass="arg">fno</span><spanclass="c">/* [OUT] File information structure */</span>
);
</pre>
</div>
<divclass="para arg">
<h4>Parameters</h4>
<dlclass="par">
<dt>dp</dt>
<dd>Pointer to the open directory object.</dd>
<dt>fno</dt>
<dd>Pointer to the file information structure to store the read item.</dd>
</dl>
</div>
<divclass="para ret">
<h4>Return Values</h4>
<p>
<ahref="rc.html#ok">FR_OK</a>,
<ahref="rc.html#de">FR_DISK_ERR</a>,
<ahref="rc.html#ie">FR_INT_ERR</a>,
<ahref="rc.html#nr">FR_NOT_READY</a>,
<ahref="rc.html#io">FR_INVALID_OBJECT</a>,
<ahref="rc.html#tm">FR_TIMEOUT</a>,
<ahref="rc.html#nc">FR_NOT_ENOUGH_CORE</a>
</p>
</div>
<divclass="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 >= 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 <ttclass="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>
<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>
</ul>
<p>When the directory item has no LFN information, lower case characters can be contained in the <tt>fname[]</tt>.</p>
</div>
<divclass="para comp">
<h4>QuickInfo</h4>
<p>Available when <tt>_FS_MINIMIZE <= 1</tt>.</p>
</div>
<divclass="para use">
<h4>Sample Code</h4>
<pre>
FRESULT scan_files (
char* path <spanclass="c">/* Start node to be scanned (also used as work area) */</span>
)
{
FRESULT res;
FILINFO fno;
DIR dir;
int i;
char *fn; <spanclass="c">/* This function is assuming non-Unicode cfg. */</span>
<spanclass="k">#if</span> _USE_LFN
static char lfn[_MAX_LFN + 1]; <spanclass="c">/* Buffer to store the LFN */</span>
fno.lfname = lfn;
fno.lfsize = sizeof lfn;
<spanclass="k">#endif</span>
res = f_opendir(&dir, path); <spanclass="c">/* Open the directory */</span>
if (res == FR_OK) {
i = strlen(path);
for (;;) {
res = f_readdir(&dir, &fno); <spanclass="c">/* Read a directory item */</span>
if (res != FR_OK || fno.fname[0] == 0) break; <spanclass="c">/* Break on error or end of dir */</span>
if (fno.fname[0] == '.') continue; <spanclass="c">/* Ignore dot entry */</span>
<spanclass="k">#if</span> _USE_LFN
fn = *fno.lfname ? fno.lfname : fno.fname;
<spanclass="k">#else</span>
fn = fno.fname;
<spanclass="k">#endif</span>
if (fno.fattrib & AM_DIR) { <spanclass="c">/* It is a directory */</span>
sprintf(&path[i], "/%s", fn);
res = scan_files(path);
if (res != FR_OK) break;
path[i] = 0;
} else { <spanclass="c">/* It is a file. */</span>