R0.15a
Nov 22, 2024 Fixed a complie error when FF_FS_LOCK != 0. (appeared at R0.15) Fixed a potential issue when work FatFs concurrency with FF_FS_REENTRANT, FF_VOLUMES >= 2 and FF_FS_LOCK > 0. Made f_setlabel accept a volume label with Unix style volume ID when FF_STR_VOLUME_ID == 2. Made FatFs update PercInUse field in exFAT VBR. (A preceding f_getfree is needed for the accuracy)
This commit is contained in:
+46
-12
@@ -3,8 +3,6 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
<link rel="up" title="FatFs" href="../00index_e.html">
|
||||
<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/readdir.html">
|
||||
<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
|
||||
<title>FatFs - f_readdir</title>
|
||||
</head>
|
||||
@@ -53,19 +51,19 @@ FRESULT f_rewinddir (
|
||||
|
||||
<div class="para desc">
|
||||
<h4>Description</h4>
|
||||
<p>The <tt>f_readdir</tt> function reads a directory item, informations about the object, from the open directory. Items in the directory can be read in sequence by <tt>f_readdir</tt> function calls. When all items in the directory have been read and no item to read, a null string is stored into the <tt>fno->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. The <tt>f_rewinddir</tt> function is implemented as a macro.</p>
|
||||
<p>The <tt>f_readdir</tt> function reads a directory item, informations about the object, from the open directory. Items in the directory can be read by <tt>f_readdir</tt> function calls in order of the directory table. When all items in the directory have been read and no item to read any more, a null string in <tt>fno->fname[]</tt> will be returned without an error. If a null pointer is given to the <tt class="arg">fno</tt>, the read index of the directory object will be rewound. The <tt>f_rewinddir</tt> function is implemented as a macro.</p>
|
||||
<pre>
|
||||
#define <em>f_rewinddir</em>(dp) f_readdir((dp), 0)
|
||||
</pre>
|
||||
<p>When LFN is enabled, a member <tt>altname[]</tt> is defined in the file information structure to store the short file name of the object. If the long file name is not accessible due to a reason listed below, short file name is stored to the <tt>fname[]</tt> and the <tt>altname[]</tt> has a null string.</p>
|
||||
<p>When LFN is enabled, a member <tt>altname[]</tt> is defined in the file information structure to store the short file name of the object. If the long file name is not accessible due to any reason listed below, short file name is stored to the <tt>fname[]</tt> and the <tt>altname[]</tt> has a null string.</p>
|
||||
<ul>
|
||||
<li>The item has no LFN. (Not the case in exFAT volume)</li>
|
||||
<li><a href="config.html#max_lfn"><tt>FF_MAX_LFN</tt></a> is insufficient to handle the LFN. (Not the case in <tt>FF_MAX_LFN == 255</tt>)</li>
|
||||
<li>The item has no LFN. (Not the case on the exFAT volume)</li>
|
||||
<li><a href="config.html#max_lfn"><tt>FF_MAX_LFN</tt></a> is insufficient to handle the LFN. (Not the case when <tt>FF_MAX_LFN == 255</tt>)</li>
|
||||
<li><a href="config.html#lfn_buf"><tt>FF_LFN_BUF</tt></a> is insufficient to store the LFN.</li>
|
||||
<li>The LFN contains some character not defined in current CP. (Not the case in <tt>FF_LFN_UNICODE != 0</tt>)</li>
|
||||
<li>The LFN contains some character not defined in current CP. (Not the case when <tt>FF_LFN_UNICODE != 0</tt>)</li>
|
||||
</ul>
|
||||
<p>There is an issue on read directories in 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, "?" is returned as the file name to indicate that the object is not accessible. To avoid this problem, configure FatFs <tt><a href="config.html#lfn_unicode">FF_LFN_UNICODE</a> != 0</tt> and <tt>FF_MAX_LFN == 255</tt> to support the full feature of LFN specification.</p>
|
||||
<p>Dot entries (<tt>"."</tt> and <tt>".."</tt>) in the sub-directory of FAT volume are filtered out and they will never appear in the read items because exFAT lacks dot entries in the sub-directory.</p>
|
||||
<p>There is an issue on read the directories on the 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, "?" is returned as the file name to indicate that the object is not accessible. To avoid this problem, configure FatFs <tt><a href="config.html#lfn_unicode">FF_LFN_UNICODE</a> != 0</tt> and <tt>FF_MAX_LFN == 255</tt> to support the full feature of LFN specification.</p>
|
||||
<p>Dot entries (<tt>"."</tt> and <tt>".."</tt>) in the sub-directory of FAT volume are filtered out and they will never appear in the read items because of the consistency with exFAT which lacks dot entries in the sub-directory.</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -78,6 +76,41 @@ FRESULT f_rewinddir (
|
||||
<div class="para use">
|
||||
<h4>Sample Code</h4>
|
||||
<pre>
|
||||
<span class="c">/* List contents of a directory */</span>
|
||||
|
||||
FRESULT list_dir (const char *path)
|
||||
{
|
||||
FRESULT res;
|
||||
DIR dir;
|
||||
FILINFO fno;
|
||||
int nfile, ndir;
|
||||
|
||||
|
||||
res = <em>f_opendir</em>(&dir, path); <span class="c">/* Open the directory */</span>
|
||||
if (res == FR_OK) {
|
||||
nfile = ndir = 0;
|
||||
for (;;) {
|
||||
res = <em>f_readdir</em>(&dir, &fno); <span class="c">/* Read a directory item */</span>
|
||||
if (res != FR_OK || fno.fname[0] == 0) break; <span class="c">/* Error or end of dir */</span>
|
||||
if (fno.fattrib & AM_DIR) { <span class="c">/* Directory */</span>
|
||||
printf(" <DIR> %s\n", fno.fname);
|
||||
ndir++;
|
||||
} else { <span class="c">/* File */</span>
|
||||
printf("%10u %s\n", fno.fsize, fno.fname);
|
||||
nfile++;
|
||||
}
|
||||
}
|
||||
<em>f_closedir</em>(&dir);
|
||||
printf("%d dirs, %d files.\n", ndir, nfile);
|
||||
} else {
|
||||
printf("Failed to open \"%s\". (%u)\n", path, res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
</pre>
|
||||
<pre>
|
||||
<span class="c">/* Recursive scan of all items in the directory */</span>
|
||||
|
||||
FRESULT scan_files (
|
||||
char* path <span class="c">/* Start node to be scanned (***also used as work area***) */</span>
|
||||
)
|
||||
@@ -88,7 +121,7 @@ FRESULT scan_files (
|
||||
static FILINFO fno;
|
||||
|
||||
|
||||
res = f_opendir(&dir, path); <span class="c">/* Open the directory */</span>
|
||||
res = <em>f_opendir</em>(&dir, path); <span class="c">/* Open the directory */</span>
|
||||
if (res == FR_OK) {
|
||||
for (;;) {
|
||||
res = <em>f_readdir</em>(&dir, &fno); <span class="c">/* Read a directory item */</span>
|
||||
@@ -103,7 +136,7 @@ FRESULT scan_files (
|
||||
printf("%s/%s\n", path, fno.fname);
|
||||
}
|
||||
}
|
||||
f_closedir(&dir);
|
||||
<em>f_closedir</em>(&dir);
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -117,7 +150,7 @@ int main (void)
|
||||
char buff[256];
|
||||
|
||||
|
||||
res = f_mount(&fs, "", 1);
|
||||
res = <em>f_mount</em>(&fs, "", 1);
|
||||
if (res == FR_OK) {
|
||||
strcpy(buff, "/");
|
||||
res = scan_files(buff);
|
||||
@@ -134,6 +167,7 @@ int main (void)
|
||||
<p><tt><a href="opendir.html">f_opendir</a>, <a href="closedir.html">f_closedir</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>
|
||||
|
||||
Reference in New Issue
Block a user