diff --git a/libraries/AP_Filesystem/AP_Filesystem_FATFS.cpp b/libraries/AP_Filesystem/AP_Filesystem_FATFS.cpp index 4409848b5d..b46c53a4ef 100644 --- a/libraries/AP_Filesystem/AP_Filesystem_FATFS.cpp +++ b/libraries/AP_Filesystem/AP_Filesystem_FATFS.cpp @@ -716,6 +716,11 @@ struct dirent *AP_Filesystem::readdir(DIR *dirp) len = strlen(fno.fname); strncpy(d->de.d_name,fno.fname,len); d->de.d_name[len] = 0; + if (fno.fattrib & AM_DIR) { + d->de.d_type = DT_DIR; + } else { + d->de.d_type = DT_REG; + } return &d->de; } diff --git a/libraries/AP_Filesystem/AP_Filesystem_FATFS.h b/libraries/AP_Filesystem/AP_Filesystem_FATFS.h index e6fa13c804..d047dbf768 100644 --- a/libraries/AP_Filesystem/AP_Filesystem_FATFS.h +++ b/libraries/AP_Filesystem/AP_Filesystem_FATFS.h @@ -20,6 +20,10 @@ #define MAX_NAME_LEN 13 #endif +#define DT_REG 0 +#define DT_DIR 1 + struct dirent { char d_name[MAX_NAME_LEN]; /* filename */ + uint8_t d_type; };