mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-18 14:48:28 -04:00
GCS_MAVLINK: cope with dirent not having dtype
This commit is contained in:
parent
c2e52af1e2
commit
64ed86a82e
@ -588,16 +588,23 @@ void GCS_MAVLINK::ftp_worker(void) {
|
|||||||
|
|
||||||
// calculates how much string length is needed to fit this in a list response
|
// calculates how much string length is needed to fit this in a list response
|
||||||
int GCS_MAVLINK::gen_dir_entry(char *dest, size_t space, const char *path, const struct dirent * entry) {
|
int GCS_MAVLINK::gen_dir_entry(char *dest, size_t space, const char *path, const struct dirent * entry) {
|
||||||
|
#if AP_FILESYSTEM_HAVE_DIRENT_DTYPE
|
||||||
const bool is_file = entry->d_type == DT_REG || entry->d_type == DT_LNK;
|
const bool is_file = entry->d_type == DT_REG || entry->d_type == DT_LNK;
|
||||||
|
#else
|
||||||
|
// assume true initially, then handle below
|
||||||
|
const bool is_file = true;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (space < 3) {
|
if (space < 3) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
dest[0] = 0;
|
dest[0] = 0;
|
||||||
|
|
||||||
|
#if AP_FILESYSTEM_HAVE_DIRENT_DTYPE
|
||||||
if (!is_file && entry->d_type != DT_DIR) {
|
if (!is_file && entry->d_type != DT_DIR) {
|
||||||
return -1; // this just forces it so we can't send this back, it's easier then sending skips to a GCS
|
return -1; // this just forces it so we can't send this back, it's easier then sending skips to a GCS
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (is_file) {
|
if (is_file) {
|
||||||
#ifdef MAX_NAME_LEN
|
#ifdef MAX_NAME_LEN
|
||||||
@ -612,6 +619,12 @@ int GCS_MAVLINK::gen_dir_entry(char *dest, size_t space, const char *path, const
|
|||||||
if (AP::FS().stat(full_path, &st)) {
|
if (AP::FS().stat(full_path, &st)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !AP_FILESYSTEM_HAVE_DIRENT_DTYPE
|
||||||
|
if (S_ISDIR(st.st_mode)) {
|
||||||
|
return hal.util->snprintf(dest, space, "D%s%c", entry->d_name, (char)0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return hal.util->snprintf(dest, space, "F%s\t%u%c", entry->d_name, (unsigned)st.st_size, (char)0);
|
return hal.util->snprintf(dest, space, "F%s\t%u%c", entry->d_name, (unsigned)st.st_size, (char)0);
|
||||||
} else {
|
} else {
|
||||||
return hal.util->snprintf(dest, space, "D%s%c", entry->d_name, (char)0);
|
return hal.util->snprintf(dest, space, "D%s%c", entry->d_name, (char)0);
|
||||||
|
Loading…
Reference in New Issue
Block a user