AP_Filesystem: don't show directory entries for empty @ filesystems

This commit is contained in:
Peter Barker 2024-02-27 14:56:34 +11:00 committed by Andrew Tridgell
parent 21edc6aee1
commit 2cb5f434fd
1 changed files with 8 additions and 0 deletions

View File

@ -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++;