lerxstrulz
Well-known member
I have 5 directories on my SD card, but for some reason it only finds 4. They are all 8 characters or less. I can access it directly through the code (ex SD.open("/thedir")) but it won't show up in a list. Here is my code:
So if I have 5 directories:
The list returned is:
I've tried increasing the control loop max by 1 and I've changed the directory names and even reformatted the card. All no luck. Any help is appreciated! Thank you!
Code:
const int SETTING_ENTRY_MAX = 50;
const int MAX_FILE_COUNT = 99;
int listDirectories(const char *path, char directories[][SETTING_ENTRY_MAX])
{
int index = 0;
File dir = SD.open(path);
dir.rewindDirectory();
while(true && index < MAX_FILE_COUNT) {
File entry = dir.openNextFile();
if (! entry) {
// no more files
break;
}
if (entry.isDirectory()) {
// This is hear to print out what it finds
Serial.print("DIR: ");
Serial.println(entry.name());
// Ignore directories that have "~" in the name
char *ret = strstr(entry.name(), "~");
if (ret == NULL) {
Serial.println(entry.name());
strcpy(directories[index], entry.name());
index++;
}
}
entry.close();
}
return index;
}
char paths[MAX_FILE_COUNT][SETTING_ENTRY_MAX];
char buffer[1024];
// return a list of directories on the card
int count = listDirectories("/", paths);
So if I have 5 directories:
Code:
dir1
dir2
dir3
dir4
dir5
The list returned is:
Code:
dir1
dir2
dir3
dir4
I've tried increasing the control loop max by 1 and I've changed the directory names and even reformatted the card. All no luck. Any help is appreciated! Thank you!