[comp.sys.amiga.tech] Anybody have

greg@noel.CTS.COM (J. Gregory Noel) (01/14/90)

I'm trying to do some directory manipulation, and I find that the utilities
provided by Aztec C are, shall we say, limited in that area.  So does anyone
have a POSIX-compliant implementation of opendir/readdir/closedir that I can
add to my toolkit?  It would make a lot of things much easier....

While I'm at it, does anyone have an implementation of mkdir for the Amiga?
I could use that, as well.  I've written a hack that executes C:makedir, but
that won't be adequate as a long-term solution....

Tks,
-- 
J. Gregory Noel, UNIX Guru         greg@noel.cts.com  or  greg@noel.uucp

ccplumb@lion.waterloo.edu (Colin Plumb) (01/16/90)

In article <1157.AA1157@noel> greg@noel.CTS.COM (J. Gregory Noel) writes:
>I'm trying to do some directory manipulation, and I find that the utilities
>provided by Aztec C are, shall we say, limited in that area.  So does anyone
>have a POSIX-compliant implementation of opendir/readdir/closedir that I can
>add to my toolkit?  It would make a lot of things much easier....

I don't have one, but I can tell you how to write it.
opendir() should get a new lock on the desired directory (using Lock())
and a FileInfoBlock that's used to store state information.  Examine()
the lock, passing the address of the FileInfoBlock to be filled in.
You should check the type of the object you've just locked and return
an error if it's not a directory, since AmigaDOS lets you get a lock on
any object.

readdir() is just an ExNext(), passing the FileInfoBlock and getting new values
written into it.

closedir() involves dropping (Unlock()) the lock on the directory.  You don't
really need to use a fresh lock and drop it afterwards, the way the semantics
of ExNext() are designed, but file system implementors hate the guts of the
guy who designed ExNext() that way and if you drop the lock as a hint that
no more directory scanning is going to be done, it's appreciated and will
get you the best performance.


>While I'm at it, does anyone have an implementation of mkdir for the Amiga?
>I could use that, as well.  I've written a hack that executes C:makedir, but
>that won't be adequate as a long-term solution....

I don't have my manual with me, but I'm pretty sure there's a MakeDir() call
in the dos.library which maps pretty obviously...
-- 
	-Colin

doug@xdos.UUCP (Doug Merritt) (01/16/90)

In article <19806@watdragon.waterloo.edu> ccplumb@lion.waterloo.edu (Colin Plumb) writes:
>In article <1157.AA1157@noel> greg@noel.CTS.COM (J. Gregory Noel) writes:
>>have a POSIX-compliant implementation of opendir/readdir/closedir that I can
>>add to my toolkit?  It would make a lot of things much easier....
>
>I don't have one, but I can tell you how to write it.

There's an Ndir() in Fish #92, written by Mike Meyer in response to a
call by Rich Salz to have portable dir libraries available on all machines.
Mike's comment says it is 4BSD compatible. I don't know whether POSIX
is the same or not, but hey, opendir/etc were *invented* on 4BSD so
that should be close enough.
	Doug
-- 
Doug Merritt		{pyramid,apple}!xdos!doug
Member, Crusaders for a Better Tomorrow		Professional Wildeyed Visionary