Skip to content

Commit a23ede4

Browse files
committed
Speed up listing files in large directory, README.adoc typo fixed
1 parent 7a4202d commit a23ede4

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

README.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/
1010
The SD library allows for reading from and writing to SD cards.
1111

1212
For more information about this library please visit us at
13-
http://www.arduino.cc/en/Reference/repository-name}
13+
http://www.arduino.cc/en/Reference/{repository-name}

src/SD.cpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,6 @@ namespace SDLib {
587587

588588
//Serial.print("\t\treading dir...");
589589
while (_file->readDir(&p) > 0) {
590-
591590
// done if past last used entry
592591
if (p.name[0] == DIR_NAME_FREE) {
593592
//Serial.println("end");
@@ -607,14 +606,16 @@ namespace SDLib {
607606
}
608607

609608
// print file name with possible blank fill
610-
SdFile f;
611-
char name[13];
612-
_file->dirName(p, name);
613609
//Serial.print("try to open file ");
614610
//Serial.println(name);
615611

616-
if (f.open(_file, name, mode)) {
612+
SdFile f;
613+
uint16_t index = (_file->curPosition() - sizeof(dir_t) ) >> 5;
614+
615+
if (f.open(_file, index, mode)) {
617616
//Serial.println("OK!");
617+
char name[13];
618+
_file->dirName(p, name);
618619
return File(f, name);
619620
} else {
620621
//Serial.println("ugh");

0 commit comments

Comments
 (0)