how to list dos file system directory

Angelo Fraietta angelo_f at
Thu Aug 7 03:07:37 UTC 2003

I cut this from my own code

#include <ctype.h>
#include <dirent.h>

void ListDir(void)
DIR *dir;
struct dirent *ent;
char dir_buffer [100];

strcpy (dir_buffer, hard_drive ) ;

if ((dir = opendir(dir_buffer)) == NULL)
printf ("\r\nUnable to open directory");
printf ("\r\nListing Directory %s", dir_buffer);
while ((ent = readdir(dir)) != NULL)
printf ("\r\n%s", ent->d_name);
if (closedir(dir) != 0)
printf("\r\nUnable to close directory");


Hope it helps

rtemswq at wrote:

>hi all,
>  I can open ,read,write ,close a dos file ,but how
>can i list all the files in a dir.
>  BTW,maybe i find a bug in
>the function open() shound return file descriptor(a
>int value) ....but in fact return a address-address (
>return iop - rtems_libio_iops;)
>maybe a bug....
>                                   David
>Do You Yahoo!?=20
>=CA=EE=C6=DA=B4=F3=C6=AC=C6=EB=BE=DB=D1=C5=BB=A2=CD=A8 =CD=F8=C2=E7=

Angelo Fraietta

PO Box 859
Hamilton NSW 2303

Home Page

There are those who seek knowledge for the sake of knowledge - that is CURIOSITY
There are those who seek knowledge to be known by others - that is VANITY
There are those who seek knowledge in order to serve - that is LOVE
    Bernard of Clairvaux (1090 - 1153)

More information about the users mailing list