AP_ROMFS: added directory listing interface
This commit is contained in:
parent
6360c67858
commit
98542d0c0b
@ -113,3 +113,21 @@ void AP_ROMFS::free(const uint8_t *data)
|
||||
::free(const_cast<uint8_t *>(data));
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
directory listing interface. Start with ofs=0. Returns pathnames
|
||||
that match dirname prefix. Ends with nullptr return when no more
|
||||
files found
|
||||
*/
|
||||
const char *AP_ROMFS::dir_list(const char *dirname, uint16_t &ofs)
|
||||
{
|
||||
const size_t dlen = strlen(dirname);
|
||||
for ( ; ofs < ARRAY_SIZE(files); ofs++) {
|
||||
if (strncmp(dirname, files[ofs].filename, dlen) == 0 &&
|
||||
files[ofs].filename[dlen] == '/') {
|
||||
// found one
|
||||
return files[ofs++].filename;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -16,6 +16,13 @@ public:
|
||||
// free returned data
|
||||
static void free(const uint8_t *data);
|
||||
|
||||
/*
|
||||
directory listing interface. Start with ofs=0. Returns pathnames
|
||||
that match dirname prefix. Ends with nullptr return when no more
|
||||
files found
|
||||
*/
|
||||
static const char *dir_list(const char *dirname, uint16_t &ofs);
|
||||
|
||||
private:
|
||||
// find an embedded file
|
||||
static const uint8_t *find_file(const char *name, uint32_t &size);
|
||||
|
Loading…
Reference in New Issue
Block a user