lib/fatfs_glue.c
/*
 * scan_files - this method lists the internal file system contents
 *
 * @path - the readable location where we mount the file system
 *
 * WARNING: This method is recursive and it can blow the stack for deep
 *          directory structures. !!! FIXME
 */
this method lists the internal file system contents
@path - the readable location where we mount the file system

This method is recursive and it can blow the stack for deep
directory structures.
this method lists the internal file system contents @path - the readable location where we mount the file system This method is recursive and it can blow the stack for deep directory structures .
static FRESULT scan_files(char *path)
{
    FRESULT res;
    static FILINFO fno;
    DIR dir;
    int i;
    char *fn;
    res = f_opendir(&dir, path);
    if (res == FR_OK) {
        i = strlen(path);
        for (;;) {
            res = f_readdir(&dir, &fno);
            if (res != FR_OK || fno.fname[0] == 0) break;
            if (fno.fname[0] == '.') continue;
            fn = fno.fname;
            if (fno.fattrib & AM_DIR) {
                sprintf(&path[i], "/%s", fn);
                emit_vfs_node(g_mounted_fs->mount_path, path, VFS_TYPE_DIR);
                res = scan_files(path);
                if (res != FR_OK) break;
                path[i] = 0;
            } else {
              char *m_path = calloc(1, 80);
              if (m_path == NULL) {
                return res;
              }
              sprintf(m_path, "%s/%s", path, fn);
              emit_vfs_node(g_mounted_fs->mount_path, m_path, VFS_TYPE_FILE);
              free(m_path);
            }
        }
    }
    return res;
}
static FRESULT scan_files ( char * path ) { FRESULT res ; static FILINFO fno ; DIR dir ; int i ; char * fn ; res = f_opendir ( & dir , path ) ; if ( res == FR_OK ) { i = strlen ( path ) ; for ( ; ; ) { res = f_readdir ( & dir , & fno ) ; if ( res != FR_OK || fno . fname [ 0 ] == 0 ) break ; if ( fno . fname [ 0 ] == ' ' ) continue ; fn = fno . fname ; if ( fno . fattrib & AM_DIR ) { sprintf ( & path [ i ] , " " , fn ) ; emit_vfs_node ( g_mounted_fs -> mount_path , path , VFS_TYPE_DIR ) ; res = scan_files ( path ) ; if ( res != FR_OK ) break ; path [ i ] = 0 ; } else { char * m_path = calloc ( 1 , 80 ) ; if ( m_path == NULL ) { return res ; } sprintf ( m_path , " " , path , fn ) ; emit_vfs_node ( g_mounted_fs -> mount_path , m_path , VFS_TYPE_FILE ) ; free ( m_path ) ; } } } return res ; }
scan_files - this method lists the internal file system contents
 @path - the readable location where we mount the file system
scan_files - this method lists the internal file system contents @path - the readable location where we mount the file system
/* Open the directory */