Date: Sun, 18 Aug 1996 21:10:47 -0400 From: Gary Chrysler <tcg@ime.net> To: FreeBSD-Questions <questions@freebsd.org> Subject: Reading directory entrys. Message-ID: <3217BF17.3F0C@ime.net>
next in thread | raw e-mail | index | archive | help
Hiya all.
Playing around a bit and have the need for a rutine simular
to the below.
Couldn't get it to work so I whipped up this test prg.
>From what I understand of the *dir(3) rutines the below should
work. ?????
It dosn't.
Any kind soles out there willing to point out my problem.
(No I'm not an expert programer, Just dabble a bit)
#include <stdio.h>
#include <dirent.h>
int get_dirent(const unsigned char* path,
unsigned char* name,
long entry,
long next_entry)
{
DIR* dir;
struct dirent* dent;
if ((dir = opendir(path)) == NULL)
return 1;
if (entry != 0xffff)
seekdir(dir, entry);
if ((dent = readdir(dir)) == NULL) {
closedir(dir);
return 1;
}
strcpy(name,dent->d_name);
next_entry = telldir(dir);
closedir(dir);
return 0;
}
void main(void)
{
long entry = 0xffff;
long next_entry;
unsigned char filename[100];
while (get_dirent(".", filename, entry, next_entry) == 0) {
printf("%s\n", filename);
entry = next_entry;
}
}
Thanks all.
-Enjoy
Gary
~~~~~~~~~~~~~~~~
Improve America's Knowledge... Share yours
The Borg... Where minds meet
(207) 929-3848
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3217BF17.3F0C>
