- Changed arguments of f_read, f_write. - Changed arguments of f_mkfs. (FatFs) - Fixed f_mkfs on FAT32 creates incorrect FSInfo. (FatFs) - Fixed f_mkdir on FAT32 creates incorrect directory. (FatFs)
90 lines
2.6 KiB
HTML
90 lines
2.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<html lang="en">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<meta http-equiv="Content-Style-Type" content="text/css">
|
|
<link rel="up" title="FatFs" href="../00index_e.html">
|
|
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
|
|
<title>FatFs - f_readdir</title>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="para">
|
|
<h2>f_readdir</h2>
|
|
<p>The f_readdir function reads directory entries.</p>
|
|
<pre>
|
|
FRESULT f_readdir (
|
|
DIR* <em>DirObject</em>, /* Pointer to the directory object structure */
|
|
FILINFO* <em>FileInfo</em> /* Pointer to the file information structure */
|
|
);
|
|
</pre>
|
|
</div>
|
|
|
|
<div class="para">
|
|
<h4>Parameters</h4>
|
|
<dl class="par">
|
|
<dt>DirObject</dt>
|
|
<dd>Pointer to the open directory strcture.</dd>
|
|
<dt>FileInfo</dt>
|
|
<dd>Pointer to the file information structure to store the read item.</dd>
|
|
</dl>
|
|
</div>
|
|
|
|
|
|
<div class="para">
|
|
<h4>Return Values</h4>
|
|
<dl class="ret">
|
|
<dt>FR_OK (0)</dt>
|
|
<dd>The function succeeded.</dd>
|
|
<dt>FR_NOT_READY</dt>
|
|
<dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd>
|
|
<dt>FR_RW_ERROR</dt>
|
|
<dd>The function failed due to a disk error or an internal error.</dd>
|
|
<dt>FR_INVALID_OBJECT</dt>
|
|
<dd>The directory object is invalid.</dd>
|
|
</dl>
|
|
</div>
|
|
|
|
|
|
<div class="para">
|
|
<h4>Description</h4>
|
|
<p>The f_readdir function reads directory entries in sequence. All items in the directory can be read by calling f_readdir function repeatedly. When all directory items have been read and no item to read, the function returns a null string into <tt>f_name[]</tt> member without any error. For details of the file informations, refer to the <tt>FILINFO</tt>. This function is not supported in minimization level of >=2.</p>
|
|
</div>
|
|
|
|
|
|
<div class="para">
|
|
<h4>Sample Code</h4>
|
|
<pre>
|
|
void scan_files (char* path)
|
|
{
|
|
FILINFO finfo;
|
|
DIR dirs;
|
|
int i;
|
|
|
|
if (f_opendir(&dirs, path) == FR_OK) {
|
|
i = strlen(path);
|
|
while ((f_readdir(&dirs, &finfo) == FR_OK) && finfo.fname[0]) {
|
|
if (finfo.fattrib & AM_DIR) {
|
|
sprintf(&path[i], "/%s", &finfo.fname[0]);
|
|
scan_files(path);
|
|
path[i] = 0;
|
|
} else {
|
|
printf("%s/%s\n", path, &finfo.fname[0]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</pre>
|
|
</div>
|
|
|
|
|
|
<div class="para">
|
|
<h4>References</h4>
|
|
<p><tt><a href="opendir.html">f_opendir</a>, <a href="stat.html">f_stat</a>, <a href="sfileinfo.html">FILINFO</a>, <a href="sdir.html">DIR</a></tt></p>
|
|
</div>
|
|
|
|
<p class="foot"><a href="../00index_e.html">Return</a></p>
|
|
</body>
|
|
</html>
|