Directory enumeration now working.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15140 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2021-11-27 06:44:44 +00:00
parent aaf5fd78ad
commit fc7e00365d
2 changed files with 8 additions and 6 deletions

View File

@ -57,6 +57,7 @@ static msg_t scan_nodes(BaseSequentialStream *chp, char *path) {
vfs_directory_node_t *dirp;
static vfs_node_info_t ni;
chprintf(chp, "%s\r\n", path);
res = vfsOpenDirectory(path, &dirp);
if (res == VFS_RET_SUCCESS) {
size_t i = strlen(path);
@ -70,15 +71,15 @@ static msg_t scan_nodes(BaseSequentialStream *chp, char *path) {
fn = ni.name;
if (ni.attr & VFS_NODE_ATTR_ISDIR) {
*(path + i) = '/';
strcpy(path + i + 1U, fn);
strcat(path + i, fn);
strcat(path + i, "/");
res = scan_nodes(chp, path);
if (res != VFS_RET_SUCCESS) {
break;
}
}
else {
chprintf(chp, "%s/%s\r\n", path, fn);
chprintf(chp, "%s%s\r\n", path, fn);
}
}

View File

@ -234,7 +234,8 @@ static msg_t node_dir_next(void *instance, vfs_node_info_t *nip) {
if (rdnp->index < VFS_CFG_MAX_DRIVERS) {
nip->attr = VFS_NODE_ATTR_ISDIR | VFS_NODE_ATTR_READONLY;
nip->size = (vfs_offset_t)0;
strcpy(nip->name, rdnp->driver->rootname);
strcpy(nip->name,
((vfs_root_driver_t *)rdnp->driver)->drivers[rdnp->index]->rootname);
rdnp->index++;
@ -256,8 +257,8 @@ static msg_t node_dir_next(void *instance, vfs_node_info_t *nip) {
*/
void vfsInit(void) {
vfs.vmt = &root_driver_vmt;
vfs.vmt = &root_driver_vmt;
vfs.rootname = "";
vfs.next_driver = &vfs.drivers[0];
chPoolObjectInit(&vfs.dir_nodes_pool,