Path: utzoo!utgpu!watserv1!watdragon!lion!ccplumb From: ccplumb@lion.waterloo.edu (Colin Plumb) Newsgroups: comp.sys.amiga.tech Subject: Re: Anybody have (open|read|close)dir for the Amiga? Message-ID: <19806@watdragon.waterloo.edu> Date: 15 Jan 90 19:17:07 GMT References: <1157.AA1157@noel> Sender: daemon@watdragon.waterloo.edu Reply-To: ccplumb@lion.waterloo.edu (Colin Plumb) Organization: U. of Waterloo, Ontario Lines: 33 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