Go Down

Topic: How to iterate over a directory back and forth? (Read 205 times) previous topic - next topic

Lucario448

Hello everybody. As the subject says, I'm trying to iterate over a directory (to open the files inside of it, one at a time).

Yes, I can use openNextFile(); but what if I want to go back to the previous file?
"Rewinding" and advancing again is not very efficient because... what if the directory has more than 100 files and I need to go back to the 99th one?

With this amount of files, going back (not foward) to one of the lastest this way, creates an annoying delay of nearly a second (and a lot of unnecessary I/O in the SPI port). So I need some sort of "random access" capability in the directory iteration.

I know that the library kind of indexes the directories contents (aka entries), so my final question is: can I find this feature of opening a file by index number (rather than name) in the shipped SD library? Or it's exclusive of SdFat?



I need quick back and forth file access because it's for a WAV music player project; obviously for the "next" and "previous" functions, and maybe the recursive (playing/skipping folders and subfolders) capability.





Best regards!

Go Up