fatfs v0.07a Apr 14, 2009:
- Separated out OS dependent code on reentrant cfg. - Added multiple sector size support.
This commit is contained in:
1 parent
b94c8f3bf3
commit
3bb1c09ac4
88 files changed
+33446
-3894
No files matched your search
+37
-14
@@ -15,7 +15,7 @@
|
||||
<p>The f_readdir function reads directory entries.</p>
|
||||
<pre>
|
||||
FRESULT f_readdir (
|
||||
DIR* <em>DirObject</em>, /* Pointer to the directory object structure */
|
||||
DIR* <em>DirObject</em>, /* Pointer to the open directory object */
|
||||
FILINFO* <em>FileInfo</em> /* Pointer to the file information structure */
|
||||
);
|
||||
</pre>
|
||||
@@ -25,7 +25,7 @@ FRESULT f_readdir (
|
||||
<h4>Parameters</h4>
|
||||
<dl class="par">
|
||||
<dt>DirObject</dt>
|
||||
<dd>Pointer to the open directory strcture.</dd>
|
||||
<dd>Pointer to the open directory object.</dd>
|
||||
<dt>FileInfo</dt>
|
||||
<dd>Pointer to the file information structure to store the read item.</dd>
|
||||
</dl>
|
||||
@@ -39,8 +39,10 @@ FRESULT f_readdir (
|
||||
<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_DISK_ERR</dt>
|
||||
<dd>The function failed due to an error in the disk function.</dd>
|
||||
<dt>FR_INT_ERR</dt>
|
||||
<dd>The function failed due to a wrong FAT structure or an internal error.</dd>
|
||||
<dt>FR_INVALID_OBJECT</dt>
|
||||
<dd>The directory object is invalid.</dd>
|
||||
</dl>
|
||||
@@ -49,31 +51,52 @@ FRESULT f_readdir (
|
||||
|
||||
<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>
|
||||
<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. When a null pointer is given to the <tt>FileInfo</tt>, the read index of the directory object will be 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 calling the f_readdir function. The <tt>lfname</tt> is a pointer to the string buffer to return the long file name. The <tt>lfsize</tt> is the size of the string buffer. When either the size of specified buffer or LFN working buffer is insufficient to store the LFN or LFN is not exist, a null string will be returned. When <tt>lfname</tt> is a NULL, nothing is returned.</p>
|
||||
<p>For details on 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)
|
||||
FRESULT scan_files (char* path)
|
||||
{
|
||||
FILINFO finfo;
|
||||
DIR dirs;
|
||||
FRESULT res;
|
||||
FILINFO fno;
|
||||
DIR dir;
|
||||
int i;
|
||||
char *fn;
|
||||
#if _USE_LFN
|
||||
static char lfn[_MAX_LFN * (_DF1S ? 2 : 1) + 1];
|
||||
fno.lfname = lfn;
|
||||
fno.lfsize = sizeof(lfn);
|
||||
#endif
|
||||
|
||||
if (f_opendir(&dirs, path) == FR_OK) {
|
||||
|
||||
res = f_opendir(&dir, path);
|
||||
if (res == 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);
|
||||
for (;;) {
|
||||
res = f_readdir(&dir, &fno);
|
||||
if (res != FR_OK || fno.fname[0] == 0) break;
|
||||
#if _USE_LFN
|
||||
fn = *fno.lfname ? fno.lfname : fno.fname;
|
||||
#else
|
||||
fn = fno.fname;
|
||||
#endif
|
||||
if (fno.fattrib & AM_DIR) {
|
||||
sprintf(&path[i], "/%s", fn);
|
||||
res = scan_files(path);
|
||||
if (res != FR_OK) break;
|
||||
path[i] = 0;
|
||||
} else {
|
||||
printf("%s/%s\n", path, &finfo.fname[0]);
|
||||
printf("%s/%s\n", path, fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user