@@ -451,7 +451,7 @@ Print data, followed by a carriage return and newline, to the File, which must h
451
451
```
452
452
file.println()
453
453
file.println(data)
454
- file.print (data, BASE)
454
+ file.println (data, BASE)
455
455
```
456
456
457
457
#### Parameters
@@ -669,29 +669,29 @@ void loop() {
669
669
}
670
670
671
671
void printDirectory(File dir, int numTabs) {
672
- while(true) {
673
-
674
- File entry = dir.openNextFile();
675
- if (! entry) {
676
- // No more files
677
- // Serial.println("**nomorefiles**");
678
- break;
679
- }
680
-
681
- for (uint8_t i= 0; i< numTabs; i++) {
682
- Serial.print('\t');
683
- }
684
-
685
- Serial.print(entry.name());
686
- if (entry.isDirectory()) {
687
- Serial.println("/");
688
- printDirectory(entry, numTabs+ 1);
689
- } else {
690
- // Files have sizes, directories do not
691
- Serial.print("\t\t");
692
- Serial.println(entry.size(), DEC);
693
- }
694
- }
672
+ while (true) {
673
+
674
+ File entry = dir.openNextFile();
675
+ if (!entry) {
676
+ // No more files
677
+ // Serial.println("**nomorefiles**");
678
+ break;
679
+ }
680
+
681
+ for (uint8_t i = 0; i < numTabs; i++) {
682
+ Serial.print('\t');
683
+ }
684
+
685
+ Serial.print(entry.name());
686
+ if (entry.isDirectory()) {
687
+ Serial.println("/");
688
+ printDirectory(entry, numTabs + 1);
689
+ } else {
690
+ // Files have sizes, directories do not
691
+ Serial.print("\t\t");
692
+ Serial.println(entry.size(), DEC);
693
+ }
694
+ }
695
695
}
696
696
```
697
697
@@ -745,7 +745,7 @@ void setup() {
745
745
delay(2000);
746
746
747
747
Serial.println();
748
- Serial.println("Rewinding, and repeating below:" );
748
+ Serial.println("Rewinding, and repeating below:");
749
749
Serial.println();
750
750
delay(2000);
751
751
@@ -761,7 +761,7 @@ void loop() {
761
761
void printDirectory(File dir, int numTabs) {
762
762
while (true) {
763
763
File entry = dir.openNextFile();
764
- if (! entry) {
764
+ if (!entry) {
765
765
if (numTabs == 0)
766
766
Serial.println("** Done **");
767
767
return;
@@ -833,6 +833,13 @@ void setup() {
833
833
SD.begin(10);
834
834
root = SD.open("/");
835
835
printDirectory(root, 0);
836
+ Serial.println();
837
+
838
+ Serial.println("PRINT AGAIN");
839
+ Serial.println("-----------");
840
+ root.rewindDirectory(); // Return to the first file in the directory
841
+ printDirectory(root, 0);
842
+
836
843
Serial.println("Done!");
837
844
}
838
845
@@ -841,29 +848,27 @@ void loop() {
841
848
}
842
849
843
850
void printDirectory(File dir, int numTabs) {
844
- while(true) {
845
- File entry = dir.openNextFile();
846
- if (! entry) {
847
- // No more files
848
- // Return to the first file in the directory
849
- dir.rewindDirectory();
850
- break;
851
- }
852
-
853
- for (uint8_t i=0; i<numTabs; i++) {
854
- Serial.print('\t');
855
- }
856
-
857
- Serial.print(entry.name());
858
- if (entry.isDirectory()) {
859
- Serial.println("/");
860
- printDirectory(entry, numTabs+1);
861
- } else {
862
- // Files have sizes, directories do not
863
- Serial.print("\t\t");
864
- Serial.println(entry.size(), DEC);
865
- }
866
- }
851
+ while (true) {
852
+ File entry = dir.openNextFile();
853
+ if (!entry) {
854
+ // No more files
855
+ break;
856
+ }
857
+
858
+ for (uint8_t i = 0; i < numTabs; i++) {
859
+ Serial.print('\t');
860
+ }
861
+
862
+ Serial.print(entry.name());
863
+ if (entry.isDirectory()) {
864
+ Serial.println("/");
865
+ printDirectory(entry, numTabs + 1);
866
+ } else {
867
+ // Files have sizes, directories do not
868
+ Serial.print("\t\t");
869
+ Serial.println(entry.size(), DEC);
870
+ }
871
+ }
867
872
}
868
873
```
869
874
@@ -882,4 +887,4 @@ void printDirectory(File dir, int numTabs) {
882
887
* [ read()] ( #read )
883
888
* [ write()] ( #write )
884
889
* [ isDirectory()] ( #isdirectory )
885
- * [ openNextFile()] ( #opennextfile )
890
+ * [ openNextFile()] ( #opennextfile )
0 commit comments