Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ll-xn!nike!oliveb!glacier!navajo!rokicki From: rokicki@navajo.STANFORD.EDU (Tomas Rokicki) Newsgroups: net.micro.amiga Subject: Re: AmigaDOS problem Message-ID: <788@navajo.STANFORD.EDU> Date: Mon, 18-Aug-86 14:59:49 EDT Article-I.D.: navajo.788 Posted: Mon Aug 18 14:59:49 1986 Date-Received: Wed, 20-Aug-86 00:00:32 EDT References: <1646@well.UUCP> Organization: Stanford University Lines: 79 Summary: Huh? In article <1646@well.UUCP>, crunch@well.UUCP (John Draper) writes: > AMIGADOG PROBLEM > ---------------- > I am trying to whip up a simple directory display program and want to > be able to detect when the last file has been displayed. According > to the manual which is INCORRECT and INACCURATE (Thank you, MetaCompco, > take a bow), I quote from page 2-5 of the developers DOS (dog?) > manual: > "ExNext gives a return code of zero if it fails for some reason. One > reason for failure is reaching the last entry of the directory. However, > IoErr() holds a code that may give more information on the exact cause of > a failure. WHEN ExNext FINISHES AFTER THE LAST ENTRY, IT RETURNS: > ERROR_NO_MORE_ENTRIES (232)". Well, I just tested this, and wrote the following code fragment, which seems to work as documented under 1.1. The code is at the end of the article. (Compile under Manx without +l). When run on the directory it was created in, it outputs: df0:tdir entrytype 2 tdir ioerr() 205 tdir.c ioerr() 205 tdir.o ioerr() 205 Exited with ioerr() 232 205 is couldn't find object; I don't know where this came from. But it does finish with a zero result from ExNext() and an IoErr() of NoMoreEntries. Enjoy! -tom rokicki ---cut here--- /* * Test of the directory finding functions. Written by * Tomas Rokicki of Radical Eye Software; feel free to * use in any way you see fit. */ #include "stdio.h" #include "libraries/dos.h" struct FileInfoBlock fib ; main(argc, argv) int argc ; char *argv[] ; { long lock = 0 ; extern long CurrentDir(), ExNext(), Examine(), IoErr(), Lock() ; if (argc > 1) { argc-- ; argv++ ; } else { argc = 1 ; **argv = 0 ; } for (; argc > 0; argc--, argv++) { lock = Lock(*argv, ACCESS_READ) ; if (lock == 0) { printf("Error locking %s\n", *argv) ; } else { Examine(lock, &fib) ; printf("%s entrytype %ld\n", *argv, fib.fib_EntryType) ; if (fib.fib_EntryType > 0) { int fc = 0 ; while (ExNext(lock, &fib) != 0) { printf(" %s ioerr() %ld\n", fib.fib_FileName, IoErr()) ; fc++ ; } if (fc == 0) printf(" (empty)\n") ; printf("Exited with ioerr() %ld\n", IoErr()) ; } else { printf(" (file)\n") ; } UnLock(lock) ; } } } ---cut here---