Reference.FileOpenNextFile History

Hide minor edits - Show changes to markup

July 02, 2015, at 09:47 AM by Arturo -
Deleted line 24:
Deleted line 28:
Deleted line 29:
Deleted line 30:
Changed lines 32-33 from:
  Serial.println("done!");
to:
  delay(2000);
  Serial.println();
  Serial.println("Rewinding, and repeating below:" );
  Serial.println();
  delay(2000);
  root.rewindDirectory();
  printDirectory(root, 0);
  root.close();
Changed lines 47-67 from:

void printDirectory(File dir, int numTabs) {

   while(true) {

     File entry =  dir.openNextFile();
     if (! entry) {
       // no more files
       Serial.println("**nomorefiles**");
     }
     for (uint8_t i=0; i<numTabs; i++) {
       Serial.print('\t');
     }
     Serial.print(entry.name());
     if (entry.isDirectory()) {
       Serial.println("/");
       printDirectory(entry, numTabs+1);
     } else {
       // files have sizes, directories do not
       Serial.print("\t\t");
       Serial.println(entry.size(), DEC);
     }
   }
to:

void printDirectory(File dir, int numTabs) {

  while (true)
  {
    File entry = dir.openNextFile();
    if (! entry)
    {
      if (numTabs == 0)
        Serial.println("** Done **");
      return;
    }
    for (uint8_t i = 0; i < numTabs; i++)
      Serial.print('\t');
    Serial.print(entry.name());
    if (entry.isDirectory())
    {
      Serial.println("/");
      printDirectory(entry, numTabs + 1);
    }
    else
    {
      Serial.print("\t\t");
      Serial.println(entry.size(), DEC);
    }
    entry.close();
  }
November 06, 2011, at 12:07 AM by Scott Fitzgerald -
Changed lines 51-52 from:
       //Serial.println("**nomorefiles**");
       break;
to:
       Serial.println("**nomorefiles**");
November 02, 2011, at 01:59 PM by Scott Fitzgerald -
Changed lines 73-74 from:
to:
November 02, 2011, at 01:56 PM by Scott Fitzgerald -
Changed lines 13-14 from:

file: an instance of the File class (returned by file.open()

to:

file: an instance of the File class that is a directory

November 02, 2011, at 01:50 PM by Scott Fitzgerald -
Changed lines 31-32 from:

SD.begin(10

to:
  SD.begin(10);
November 02, 2011, at 01:48 PM by Scott Fitzgerald -
Changed lines 70-72 from:
to:
November 02, 2011, at 01:47 PM by Scott Fitzgerald -
Added lines 1-76:

Share