Traverse files and directories on SD card

20 Aug 2012

I'm currently working with files on an SD card and I can open, read and write files as well as list a directory and make directories. The more I get into it though the more complex things seem to be getting. For instance what is best practice for opening a second directory and then listing those files and then going back to the parent directory? At the moment I'm trying to construct a string that keeps track of what directory your in, but surely you should be able to use CWD or some such thing?

I've searched lots of c++ forums but it seems a lot of people use the boost library which I don't think is possible on mbed – and seems like overkill. Also neither can I use <sys/stat.h> to test whether a file is a directory.

Does anyone know of a file navigation library in existence that will work on the mbed?

Thanks in advance.