To whom it may concern,
I am cycling through all files in a given directory, processing them, and afterwards deleting them. Is it possible, that the ff_findnext function does not work if a file in the current working directory is being deleted in between iterations?
My sequence of events is something like that:
- change working directory with ff_chdir
- allocate some memory and get the pointer for the FF_FindData_t struct
- RetVal = ff_findfirst( “”, px_FindStruct )
- if RetVal != 0 -> abort
- if it is a dot (. or …) entry or another directory skip it
- else open the file ff_open(px_FindStruct->pcFileName, “r”), send it via TCP, finally ff_close(…)
- if the TCP server on the other end responded positively, delete the file: ff_remove( px_FindStruct->pcFileName )
- RetVal = ff_findnext( px_FindStruct )
- loop back to 4 while RetVal == 0
Am I missing something? Does the FindStruct get messed up because I am deleting files while I iterate through them?
If there is only one file in the directory, it works perfectly fine. If a few files have been accumulated, the first one is being sent and removed, but then ff_findnext breaks the loop. However, I can access the very same FAT through FTP and fetch the remainng files. They are perfectly readable, the size and content is exactly as expected.
Thanks for any hints on what might be going on here.