Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!nrl-cmf!ames!ucbcad!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga Subject: Re: How can I get to the command search path? Message-ID: <8711142324.AA02569@cory.Berkeley.EDU> Date: Sat, 14-Nov-87 18:24:44 EST Article-I.D.: cory.8711142324.AA02569 Posted: Sat Nov 14 18:24:44 1987 Date-Received: Sun, 15-Nov-87 20:00:29 EST Sender: daemon@ucbvax.BERKELEY.EDU Lines: 48 >I'm trying to write a program which, among other things, will do command and >filename completion on the Amiga. What I need to know is how do I get at >the search path (given by the PATH command)? I need to be able to search >all the directories from the current dir down to C:. I thought about doing something like this, but found that it simply takes too long to sequentially search floppy directories. The Amiga is much better finding specific names (and partial names are no good because you still have to scan the directory). The IBM sequentially searches its directories, and if you have a big directories that HD really gets busy trying to find the program! I like the 'find a specific name fast' approach... it means I can search C: on 2 floppy drives, VD0:, and RAM: in the blink of an eye. What? Oh yah. The PATH is stored in the CLI structure's cli_CommandDir entry as a linked list of FileLock's. That is: (Note, construction is from memory.. untested) #include #include #include #define BTOC(bptr) ((long)(bptr) << 2) typedef struct Task TASK; typedef struct Process PROC; typedef struct CommandLineInterface CLI; typedef struct FileLock LOCK; extern TASK *FindTask(); blah() { CLI *cli; BPTR lock; /* assume we are a process */ cli = (CLI *)BTOC(((PROC *)FindTask(NULL))->pr_CLI); for (lock = cli->cli_CommandDir;lock;lock=((LOCK *)BTOC(lock))->fl_Link) { /* Search directory referenced by 'lock' */ } } Something like that, anyway. -Matt