From 14bf946fe29e3315c6c1a06eb2f600f211a31319 Mon Sep 17 00:00:00 2001 From: Michael du Breuil Date: Wed, 25 Sep 2019 20:41:43 -0700 Subject: [PATCH] AP_Filesystem: Add dir type to fatfs --- libraries/AP_Filesystem/AP_Filesystem_FATFS.cpp | 5 +++++ libraries/AP_Filesystem/AP_Filesystem_FATFS.h | 4 ++++ 2 files changed, 9 insertions(+) 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; };