Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: File list SD card runs only 3 times on: January 13, 2013, 08:18:20 pm
There is a bug in the SD library for opening root that causes the position of root to not be at the beginning.

Add a dir.seek(0) to your printDirectory function like this:
Code:
void printDirectory(File dir, int numTabs)
{
  int nEntries = 0;
  char buf[32];
  dir.seek(0);
   while(true) {
     
     File entry =  dir.openNextFile();
     if (! entry) {
       // no more files
       //Serial.println("**nomorefiles**");
       entry.close(); // Added
       break;
     }
     for (uint8_t i=0; i<numTabs; i++) {
       Serial.print('\t');
     }
     Serial.print(entry.name());
     if (entry.isDirectory()) {
       //Serial.println("/");
       //printDirectory(entry, numTabs+1); // no recursion
     } else {
       // files have sizes, directories do not
       Serial.print("\t\t");
       Serial.println(entry.size(), DEC);
       nEntries++;
     }
     entry.close(); // Added
   }
   
   sprintf( buf, "%d", nEntries );
   
   Serial.println( "" );
   Serial.print( buf );
   Serial.println( " entries found." );
   
}
2  Using Arduino / Storage / Re: How can you find file attributes on SD card? on: January 05, 2013, 10:32:13 pm
never mind,  I found something here :
http://arduino.cc/forum/index.php?topic=38150.0

I hope it helps someone else too.
3  Using Arduino / Storage / How can you find file attributes on SD card? on: January 05, 2013, 09:48:25 pm
Hello,

I am using the standard SD library (http://arduino.cc/en/Reference/SD) for one of my projects.
Is it possible to find out the file attributes on the SD card  (i.e. date created ) similar to how you find out the size of the file (myFile.size()) ?

Thanks!
Pages: [1]