Hide minor edits - Show changes to markup
//Serial.println("**nomorefiles**");
break;
Serial.println("**nomorefiles**");
file: an instance of the File class (returned by file.open()
file: an instance of the File class that is a directory
SD.begin(10
SD.begin(10);
(:sourceend:)
SD : File class
Reports the next file or folder in a directory.
file.openNextFile()
file: an instance of the File class (returned by file.open()
char : the next file or folder in the path
(:source lang=arduino:)
File root;
void setup() {
Serial.begin(9600); pinMode(10, OUTPUT);
SD.begin(10
root = SD.open("/");
printDirectory(root, 0);
Serial.println("done!");
}
void loop() {
// nothing happens after setup finishes.
}
void printDirectory(File dir, int numTabs) {
while(true) {
File entry = dir.openNextFile();
if (! entry) {
// no more files
//Serial.println("**nomorefiles**");
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);
} else {
// files have sizes, directories do not
Serial.print("\t\t");
Serial.println(entry.size(), DEC);
}
}
} (:sourceend:)
(:sourceend:)