how to list dos file system directory

Angelo Fraietta angelo_f at bigpond.com
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");
}
else
{
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 yahoo.com.cn 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
>cpukit/libcsupport/src/open.c
>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=
>=C9=E3=CF=F1=CD=B7+=D1=C5=BB=A2=CD=A8=B5=F7=C6=B5=CA=D5=D2=F4=BB=FA=
>=B5=C8=C4=E3=C0=B4=C4=C3
>http://cn.rd.yahoo.com/mail_cn/tag/?http://cn.promo.yahoo.com/minisit=
>e/messenger1/
>
>
>
>
>
>  
>

-- 
Angelo Fraietta

PO Box 859
Hamilton NSW 2303

Home Page


http://www.users.bigpond.com/angelo_f/

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