Skip to content

Commit

Permalink
AP_Filesystem: don't show directory entries for empty @ filesystems
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker authored and tridge committed Feb 28, 2024
1 parent 21edc6a commit 2cb5f43
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libraries/AP_Filesystem/AP_Filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,14 @@ struct dirent *AP_Filesystem::readdir(DirHandle *dirp)
if (prefix[0] != '@') {
continue;
}

// only return @ entries in root if we can successfully opendir them:
auto *d = backends[virtual_dirent.backend_ofs].fs.opendir("");
if (d == nullptr) {
continue;
}
backends[virtual_dirent.backend_ofs].fs.closedir(d);

// found a virtual directory we haven't returned yet
strncpy_noterm(virtual_dirent.de.d_name, prefix, sizeof(virtual_dirent.de.d_name));
virtual_dirent.d_off++;
Expand Down

0 comments on commit 2cb5f43

Please sign in to comment.