From owner-freebsd-questions Sun Aug 18 18:09:15 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id SAA26765 for questions-outgoing; Sun, 18 Aug 1996 18:09:15 -0700 (PDT) Received: from ime.net (ime.net [204.97.248.4]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id SAA26753 for ; Sun, 18 Aug 1996 18:09:13 -0700 (PDT) Received: from kimiko.tcguy.net (buxton-4.ime.net [206.231.148.133]) by ime.net (8.7.4/8.6.12) with SMTP id VAA17815 for ; Sun, 18 Aug 1996 21:09:10 -0400 (EDT) Message-ID: <3217BF17.3F0C@ime.net> Date: Sun, 18 Aug 1996 21:10:47 -0400 From: Gary Chrysler Reply-To: tcg@ime.net Organization: The Computer Guy X-Mailer: Mozilla 3.0b6 (Win95; I) MIME-Version: 1.0 To: FreeBSD-Questions Subject: Reading directory entrys. Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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 #include 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