We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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
http://www.keil.com/forum/tips.asp
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.
auto/local variables will also present as dirty.