Skip to content

Commit 07b5582

Browse files
committed
AudioSourceSdFat - move checks to getFileByPos
1 parent 414470f commit 07b5582

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/AudioTools/AudioPlayer.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,14 @@ namespace audio_tools {
307307
if (sd.exists(dirStr)){
308308
LOGI("directory: '%s'", dirStr);
309309
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+
}
314318
} else {
315319
LOGE("Could not open direcotry: '%s'", dirStr);
316320
}
@@ -327,10 +331,6 @@ namespace audio_tools {
327331
char file_name_act[MAX_FILE_LEN];
328332
dir.getName(file_name_act, MAX_FILE_LEN);
329333
LOGD("-> processing directory: %s ", file_name_act);
330-
if (!dir.isDir()) {
331-
LOGE("'%s' is not a directory!", file_name_act);
332-
return;
333-
}
334334
AudioFile file;
335335
dir.rewind();
336336
while (!result && file.openNext(&dir, O_RDONLY)) {

0 commit comments

Comments
 (0)