opendir() call this method before start reading the list of files that are on the flash chip. The list can be accessed with readdir(), which returns true for each file, or false to indicate that there are no more files.
readdir() reads the file name and size of the next entry in the directory (see sizeInFlash())


readdir( filename, length_filename, filesize );


opendir(): none
char* filename – pointer to an array of chars where the name of the next file will be copied into
uint32_t length_filename – size of the filename-buffer
uint32_t filesize – reference to the variable that will hold the size (in bytes) that is reserved in the flash chip for this file


true: a new file name could be retrieved from the list
false: end of directory, no further files in the list

Example Code

#include "SerialFlash.h"
void setup()
  char filename[64];
  uint32_t filesize;
  while( SerialFlash.readdir(filename, sizeof(filename), filesize) ) 
    Serial.println(" - " + String(filename) + " size in flash: " + String(filesize));
void loop () 
{ }

Notes and Warnings

The file size that is returned by readdir() is the reserved size in the flash chip. If the actual size (written / readable bytes) of the file is of interest then use the Recordset-file type instead and read the size with file.size().

See also

GitHub – PaulStoffregen/SerialFlash – org. code this library is based on