Open subdirectory
Posted: Mon Aug 16, 2021 1:30 pm
Hey there!
Ok, so, I know this sounds very stupid, but I can't for the life of me figure out how to open a subdirectory. I've mounted an SD-card which I can succesfully use to play and serve files. Furthermore, I have the following function.
When I call this function like everything works and I'm presented with the names of all files in my terminal. Calling (which is an existing directory that contains files), however, results in opendir returning a NULL-pointer.
Am I overseeing something?
Kind regards,
Jochem
Ok, so, I know this sounds very stupid, but I can't for the life of me figure out how to open a subdirectory. I've mounted an SD-card which I can succesfully use to play and serve files. Furthermore, I have the following function.
Code: Select all
void list_files(const char * dirpath){
struct dirent *ep;
DIR *dp = opendir(dirpath);
if (dp != NULL){
while ((ep = readdir(dp)) != NULL) {
ESP_LOGI(TAG, "Found %s.", ep->d_name);
}
(void) closedir (dp);
} else {
ESP_LOGE(TAG, "Failed to open directory \'%s\'!", dirpath);
}
}
Code: Select all
list_files("/sdcard/")
Code: Select all
list_files("/sdcard/questions")
Am I overseeing something?
Kind regards,
Jochem