@@ -588,16 +588,23 @@ void GCS_MAVLINK::ftp_worker(void) {
588
588
589
589
// calculates how much string length is needed to fit this in a list response
590
590
int GCS_MAVLINK::gen_dir_entry (char *dest, size_t space, const char *path, const struct dirent * entry) {
591
+ #if AP_FILESYSTEM_HAVE_DIRENT_DTYPE
591
592
const bool is_file = entry->d_type == DT_REG || entry->d_type == DT_LNK;
593
+ #else
594
+ // assume true initially, then handle below
595
+ const bool is_file = true ;
596
+ #endif
592
597
593
598
if (space < 3 ) {
594
599
return -1 ;
595
600
}
596
601
dest[0 ] = 0 ;
597
602
603
+ #if AP_FILESYSTEM_HAVE_DIRENT_DTYPE
598
604
if (!is_file && entry->d_type != DT_DIR) {
599
605
return -1 ; // this just forces it so we can't send this back, it's easier then sending skips to a GCS
600
606
}
607
+ #endif
601
608
602
609
if (is_file) {
603
610
#ifdef MAX_NAME_LEN
@@ -612,6 +619,12 @@ int GCS_MAVLINK::gen_dir_entry(char *dest, size_t space, const char *path, const
612
619
if (AP::FS ().stat (full_path, &st)) {
613
620
return -1 ;
614
621
}
622
+
623
+ #if !AP_FILESYSTEM_HAVE_DIRENT_DTYPE
624
+ if (S_ISDIR (st.st_mode )) {
625
+ return hal.util ->snprintf (dest, space, " D%s%c" , entry->d_name , (char )0 );
626
+ }
627
+ #endif
615
628
return hal.util ->snprintf (dest, space, " F%s\t %u%c" , entry->d_name , (unsigned )st.st_size , (char )0 );
616
629
} else {
617
630
return hal.util ->snprintf (dest, space, " D%s%c" , entry->d_name , (char )0 );
0 commit comments