home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!usc!hela.iti.org!cs.widener.edu!dsinc!bagate!cbmvax!jesup
- From: jesup@cbmvax.commodore.com (Randell Jesup)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: AmigaDos Assign command
- Message-ID: <37922@cbmvax.commodore.com>
- Date: 15 Dec 92 21:30:23 GMT
- References: <ianm.03r4@laghey.UUCP>
- Reply-To: jesup@cbmvax.commodore.com (Randell Jesup)
- Organization: Commodore, West Chester, PA
- Lines: 84
-
- ianm@laghey.UUCP (Ian Moran) writes:
- >I have noticed strange behaviour with the 'assign' command under 2.04 and
- >above. If I take advantage of the multiple assign facility thus :
- >
- > assign rexx: s: dh0:turbotext/rexx
- >
- >Then Arexx macros will not be located under Turbotext which is contrary to
- >what I would expect, only s: is searched.
-
- Instead of trying to Lock() or Open() "rexx:<file>", it's Lock()ing
- rexx:, CurrentDir()ing to it, then trying to Open() <file>. Lock() will
- give you a lock on the first directory. If searching for a specific item,
- use AddPart() to build a full path first.
-
- >Also, why do few (if any) file requesters follow multiple assigned
- >paths similar to the above. If I enter rexx: in the C= requester then I will
- >get only the contents of s:
-
- How I would handle doing something to each entry in an assign (multi-
- assign or not):
-
- BOOL do_something_to_all (char *path, BOOL (*function)(BPTR lock))
- {
- struct DeviceProc *dp = NULL;
- struct MsgPort *old_fsport;
- BPTR lock, old_curdir;
- char *remainder;
- LONG err;
-
- // NOTE: not strrchr - PathMan has files with ':'s in them
- remainder = strchr(path,':');
- if (remainder == NULL)
- remainder = path;
- else
- remainder++; /* point past ':' */
-
- while (1) {
- dp = GetDeviceProc(path,dp);
- if (!dp)
- { /* getdevproc freed dp for us */
- // NOTE: 2.04 and 3.0 have a bug, and never return
- // ERROR_NO_MORE_ENTRIES. Accept 0 as no error as well
- // This will be fixed next release.
- err = IoErr();
- if (err == 0 || err == ERROR_NO_MORE_ENTRIES)
- return TRUE; // all done
- else
- return FALSE; // never found anything
- }
- /* save filesystem port pointer, set default FS to target */
- old_fsport = SetFileSysTask(dp->dvp_Port);
- old_curdir = CurrentDir(dp->dvp_Lock); // may be NULL
-
- /* we have an entry, get a lock on the remainder of path */
- lock = Lock(remainder,SHARED_LOCK);
-
- /* reset filesystem port and current dir */
- (void) SetFileSysTask(old_fsport);
- (void) CurrentDir(old_curdir);
-
- /* we got a lock on it, call user function. Function can */
- /* return FALSE to stop the scan. */
- if (!lock || !(*function)(lock))
- {
- UnLock(lock); // NULL is safe
- FreeDeviceProc(dp);
- return FALSE;
- }
- UnLock(lock);
- }
- }
-
- Warning: that was written off the top of my head, but I do have the
- source code for reference. Also, at least one developer has used this and
- it works.
-
- The person keeping the FAQ might want to add this...
-
- --
- To be or not to be = 0xff
- -
- Randell Jesup, Jack-of-quite-a-few-trades, Commodore Engineering.
- {uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.cbm.commodore.com BIX: rjesup
- Disclaimer: Nothing I say is anything other than my personal opinion.
-