Arduino: save file name / directory in variable with SdFat

0

In the SdFat documentation, there is a "getFilename (char *)" method that you can assign the file / directory name to an array of char. However, at the time of compiling, this method does not exist! I have already installed all versions of SdFat and none have this method.

Thecodeisasfollows:

#include<SPI.h>#include"SdFat.h"

SdFat sd;
SdFile file;
SdFile dirFile;

// Number of files found.
uint16_t numberOfFiles = 0;

// Position of file's directory entry.
uint16_t dirIndex[300];
//**Is there a way I make an array without allocating the size here?
//------------------------------------------------------------------------------
void setup()
{
  Serial.begin(9600);
  while (!Serial) {}

  if (!sd.begin())
    //  if (!sd.begin(NULL, SD_SCK_MHZ(50)))
  {
    sd.initErrorHalt();
  }
  if (dirFile.open("/controle", O_READ))
  {
    Serial.print("Reading: ");
    Serial.println();
    printDirectory(&dirFile);
  }
}
void printDirectory (SdFile* CFile)
{
  char tmp[13];

  while (file.openNext(CFile, O_READ))
  {
    if (file.isSubDir())
    {
//Serial.print("dir:");
//file.getFilename(tmp,13);
//Serial.println(tmp);
      file.printName();
    }
    else
    {
      Serial.print("file:");
      file.printName();
      Serial.println("");
//      file.getFilename(tmp,13);
//      Serial.println(tmp);
    }

    file.close();
  }

}

void loop() {}

If I uncomment the following lines:

//Serial.print("dir:");
//file.getFilename(tmp,13);
//Serial.println(tmp);

I see the following error in compiling

    
asked by anonymous 21.12.2018 / 17:56

0 answers