Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Aug 1996 21:10:47 -0400
From:      Gary Chrysler <>
To:        FreeBSD-Questions <>
Subject:   Reading directory entrys.
Message-ID:  <>

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) {
    return 1;
  next_entry = telldir(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.

Improve America's Knowledge... Share yours
The Borg... Where minds meet
(207) 929-3848

Want to link to this message? Use this URL: <>