This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to recursively search/list directories in USB/uSD

Hi,

i have been trying to recursively search and list directories using ffind()but some how the nested ffind() doesn't work, i tried with static values also but no success

here is a part of the code, i am first trying to figure out how ffind works then implement recursive search

bool fileExist(char *drive, char *mask)
{ bool_t found = false; fsFileInfo fileInfo; char driveImage[5]; char concatenate[100]; char volumeToSearch[5]; fsStatus fFindStatus;

// Path, SearchString //Path = Volume + Directory Name + File Name

strcpy (driveImage, drive); sprintf(volumeToSearch,"%s*", driveImage);

fileInfo.fileID = 0;

while(ffind(volumeToSearch, &fileInfo) == fsOK) { // If item is a Directory, then search inside the directory if((fileInfo.attrib & FS_FAT_ATTR_DIRECTORY) == FS_FAT_ATTR_DIRECTORY) { sprintf(concatenate, "%s\\\\%s\\\\%s", driveImage, fileInfo.name, mask);

while(ffind(concatenate, &fileInfo) == fsOK) { found = true; } } }

if (fileInfo.fileID == 0) { SYSTEM_DEBUG_PRINT(SYS_ERROR_WARNING,"could not find %-32s", mask); } return found;
}

thank you

Parents
  • Use of fixed auto/local variables for path names, probably something to avoid. Will likely fail in the field due of naming choices on random media presented.

    Likely need to use a clean instance of fsFileInfo for secondary diversion if you expect to come back to the original search. Don't expect to randomly reuse objects.

Reply
  • Use of fixed auto/local variables for path names, probably something to avoid. Will likely fail in the field due of naming choices on random media presented.

    Likely need to use a clean instance of fsFileInfo for secondary diversion if you expect to come back to the original search. Don't expect to randomly reuse objects.

Children