bfsStatNext()
PROTOTYPE
#include <bfs.h>
int bfsStatNext(BfsStat *buf);
DESCRIPTION
bfsStatNext() moves to the next file in the volume’s file list and outputs its information. Which file is selected depends on the number of bfsStatNext() calls since the last bfsStatFirst() call. buf points to a BfsStat structure, defined in “bfs.h” and reproduced below, that the file information is written to.
typedef struct
{
char *fname; /* null-terminated file name */
ui32 size; /* file size in bytes */
ui32 rd_cnt; /* number times read since last boot */
ui32 wr_seq; /* f-node sequence # when file written */
ui8 num_ext; /* current number of extents used */
ui8 max_ext; /* maximum number of extents used */
ui8 flags; /* may contain RECYCLE_REQ (NAND only) */
} BfsStat;
If successful, bfsStatNext() returns 0. Otherwise, it sets errno and returns -1.
ERROR CODES
| EFAULT | buf equals NULL. |
| EMFILE | A file is open or a fatal error has occurred. |
| ENOENT | There is no next file or there was no prior call to bfsStatFirst(). |
EXAMPLE
/*-------------------------------------------------------------------*/
/* Get statistics for first file. Return if none or not ready. */
/*-------------------------------------------------------------------*/
if (bfsStatFirst(&stat))
{
puts("No files to delete");
return;
}
/*-------------------------------------------------------------------*/
/* Loop to list each file. */
/*-------------------------------------------------------------------*/
do
{
/*-----------------------------------------------------------------*/
/* Output entry name and size. */
/*-----------------------------------------------------------------*/
n = printf(" bfs/%s", stat.fname);
Spaces(BFS_FNAME_LEN + 2 - n);
printf("%8u bytes\n", stat.size);
/*-----------------------------------------------------------------*/
/* Read statistics for the next file. */
/*-----------------------------------------------------------------*/
rc = bfsStatNext(&stat);
}
while (rc == 0);