[net.micro.amiga] AmigaDOS problem

crunch@well.UUCP (John Draper) (08/18/86)

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)".   

FLAME ON:

 BULL BULL AND MORE BULL PILED HIGHER AND
 DEEPER!!

  Nothing can be further from the truth.   After EACH AND EVERY ExNext call
I get the ERROR_NO_MORE_ENTRIES returned values.

FLAME OFF:

  If anyone from Amiga cares to comment on this,  I would appreciate an
answer.   This is not only MY problem,  but a dozen other programmers from
the Programmers Net also would like the answers. 

  

daveh@cbmvax.cbm.UUCP (Dave Haynie) (08/18/86)

> 
> 
> 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)".   
> 
> FLAME ON:
> 
>  BULL BULL AND MORE BULL PILED HIGHER AND
>  DEEPER!!
> 
>   Nothing can be further from the truth.   After EACH AND EVERY ExNext call
> I get the ERROR_NO_MORE_ENTRIES returned values.
> 
> FLAME OFF:
> 
>   If anyone from Amiga cares to comment on this,  I would appreciate an
> answer.   This is not only MY problem,  but a dozen other programmers from
> the Programmers Net also would like the answers. 
> 
>   
I'm not from Amiga, but I wrote a program for the Amiga, called LD (List
Directory) many, many moons ago that used ExNext() and several other AmigaDOS
calls without any problems at all.  This program was simply a cheap demo,
not intended to do anything real significant other than demonstrate AmigaDOS
calls (I actually wrote it in an attempt to create a faster DIR command, 
prior to my knowlege that that's impossible with the 1.1 disk block 
allocation routines).  This was on one of the early Fred Fish disks, I don't
recall which one.

Now for the BAD NEWS.  I heard last week that this program won't run under
1.2 for some reason.  If you're using 1.2, you may have hit the bug that's
causing LD (and about 4 descendents of LD written by other folks) to die.
I'm planning to dig out the source for LD and look at it myself, and I may
pass it onto the Amiga folks here if it proves to contain bugs I can't
figure out.  If you are using 1.1 instead, all I can say is check out the
LD program and see what you're doing differently.  I'm not sure if its doing
all the checks that the Developer's Manual prescribes, only that under
1.1 it DOES work fine.  

The LD name come from the command of the same name on the Apollo computer's
UN*X-like operating system Aegis.  It has nothing to do with the UN*X linker
called LD; several UN*X folks flamed me on this when I first posted the
program last winter.

-- 
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Dave Haynie    {caip,ihnp4,allegra,seismo}!cbmvax!daveh

	"I gained nothing at all from Supreme Enlightenment, and
	 for that very reason it is called Supreme Enlightenment."
							-Gotama Buddha

	These opinions are my own, though for a small fee they be yours too.
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

rokicki@navajo.STANFORD.EDU (Tomas Rokicki) (08/18/86)

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---

rokicki@navajo.STANFORD.EDU (Tomas Rokicki) (08/20/86)

In article <788@navajo.STANFORD.EDU>, rokicki@navajo.STANFORD.EDU (I) write:
> 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
> (My program which tests this and shows things work under 1.1)

Well, I just tested it under 1.2, and yes, ioerr() does return 232 all
the time.  However, ExNext() only returns with NULL the last time, as
it should; the rest of the time, I don't think ioerr() really matters,
as no error was detected.  (Although one would think that calling it
would set it to zero so one might test for errors just by checking
this one routine.)  Sorry about the mistake, John.

-tom rokicki

hamilton@uiucuxc.CSO.UIUC.EDU (08/21/86)

/* Written  8:53 pm  Aug 17, 1986 by crunch@well.UUCP in uiucuxc:net.micro.amiga */
/* ---------- "AmigaDOS 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)".   

FLAME ON:

 BULL BULL AND MORE BULL PILED HIGHER AND
 DEEPER!!

  Nothing can be further from the truth.   After EACH AND EVERY ExNext call
I get the ERROR_NO_MORE_ENTRIES returned values.

FLAME OFF:

  If anyone from Amiga cares to comment on this,  I would appreciate an
answer.   This is not only MY problem,  but a dozen other programmers from
the Programmers Net also would like the answers. 
/* End of text from uiucuxc:net.micro.amiga */

    john, the behavior you describe, suboptimal as it may be, does not
conflict with the documentation.  note that they did _NOT_ say:

	"[IoErr] returns [232] _ONLY_ after the last entry"

    it doesn't take that careful a reading to see that end-of-directory
is indicated by the conjunction (ExNext() == 0) _AND_ (IoErr() == 232).
the manual goes on to describe the procedure for walking a directory:

	"keep calling ExNext _until it fails_ with error code [==232]".

    i have written several programs that successfully walk the file system.
i just now modified one of them to print IoErr() after successful ExNext()s,
and i get a variety of values (232, 212, 205) even as correct results are
coming back (ie, the file info block stuff is right).  i'll post my code
if there's interest.

	wayne hamilton
	U of Il and US Army Corps of Engineers CERL
UUCP:	{ihnp4,pur-ee,convex}!uiucdcs!uiucuxc!hamilton
ARPA:	hamilton%uiucuxc@a.cs.uiuc.edu	USMail:	Box 476, Urbana, IL 61801
CSNET:	hamilton%uiucuxc@uiuc.csnet	Phone:	(217)333-8703
CIS:    [73047,544]			PLink: w hamilton