Walking Through File Directory
|Top Previous Next|
At times it is necessary to get the list of all files stored on the flash disk. Most operating systems provide this feature in the form of a DIR command. The fd. object offers two methods — fd.resetdirpointer and fd.getnextdirmember — that allow you to get the names of all stored files one by one.
An imaginary "directory pointer" walks through the file record table (FRT) of the flash disk. The fd.resetdirpointer method resets the directory pointer to 0, i.e. to the very first directory record. The fd.getnextdirmember returns the next file name and advances the pointer. Only file names are returned, attributes are excluded.
Calling the fd.getnextdirmember repeatedly will get you all the file names. When there are no more names left to go through, the method will return an empty string. You can use this to end your directory walk:
Alternatively, you can use a for-next cycle, since the number of currently stored files can be checked through the fd.getnumfiles method: