@@ -307,10 +307,14 @@ namespace audio_tools {
307
307
if (sd.exists (dirStr)){
308
308
LOGI (" directory: '%s'" , dirStr);
309
309
if (dir.open (dirStr)){
310
- size_t count = 0 ;
311
- getFileAtIndex (dir, pos, count, result);
312
- result.getName (file_name, MAX_FILE_LEN);
313
- LOGD (" -> getFile: '%s': %d" , file_name, pos);
310
+ if (dir.isDir ()) {
311
+ size_t count = 0 ;
312
+ getFileAtIndex (dir, pos, count, result);
313
+ result.getName (file_name, MAX_FILE_LEN);
314
+ LOGD (" -> getFile: '%s': %d" , file_name, pos);
315
+ } else {
316
+ LOGE (" '%s' is not a directory!" , dirStr);
317
+ }
314
318
} else {
315
319
LOGE (" Could not open direcotry: '%s'" , dirStr);
316
320
}
@@ -327,10 +331,6 @@ namespace audio_tools {
327
331
char file_name_act[MAX_FILE_LEN];
328
332
dir.getName (file_name_act, MAX_FILE_LEN);
329
333
LOGD (" -> processing directory: %s " , file_name_act);
330
- if (!dir.isDir ()) {
331
- LOGE (" '%s' is not a directory!" , file_name_act);
332
- return ;
333
- }
334
334
AudioFile file;
335
335
dir.rewind ();
336
336
while (!result && file.openNext (&dir, O_RDONLY)) {
0 commit comments