Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!genrad!panda!talcott!harvard!seismo!ut-sally!pyramid!amiga!robp From: robp@amiga.UUCP (Robert A. Peck) Newsgroups: net.micro.amiga Subject: Re: Finding the current directory... Message-ID: <749@amiga.amiga.UUCP> Date: Tue, 25-Feb-86 22:08:27 EST Article-I.D.: amiga.749 Posted: Tue Feb 25 22:08:27 1986 Date-Received: Fri, 28-Feb-86 21:36:37 EST References: <102@druca.UUCP> Reply-To: robp@dudley.UUCP (Robert A. Peck) Organization: Commodore-Amiga Inc., 983 University Ave #D, Los Gatos CA 95030 Lines: 97 Keywords: AmigaDOS,current directory In response to questions about: cd something cd "" cd cd ram:something cd "" cd FIRST, an answer: YES, there is a bug in the RAM: handler that will not execute the ParentDir command correctly. The bug exists in version 1.0 and 1.1, ... wasnt found till 1.1, and is being fixed now. Also, the null-string handling of the 'cd' command is different when executed from df0:anything or from ram:. Again this is being addressed for the next release. The only proper workaround for RAM: files is to proceed down from the top, rather than up from the bottom. Sorry. Re other questions about the current directory.... here are some tidbits for your consideration. The items shown here are described in the AmigaDOS Developers' Manual, though do not include this sample code. The current directory under AmigaDOS can be found by one of several different means, not always relying on side effects. Here are three different methods, all of which yield the same result, that is, the value of the lock on the current directory. The difference between the first one and the other two is that the first one provides the lock value but does not actually lock the directory itself, thus is less desireable. NOTE: CODE FRAGMENTS, NOT NECESSARILY COMPLETE EXAMPLES /* doesnt_lock.c */ #include "libraries/dosextens.h" extern struct Task *FindTask(); struct Lock *cdlockvalue; /* actually is a BPTR */ struct Process *myprocess; myprocess = (struct Process *)FindTask(0); /* where is my own * process control * block? */ cdlockvalue = (struct Lock *)myprocess->pr_CurrentDir; fragment? #2: /* GetCurrentDir.c */ #include "libraries/dosextens.h" struct Lock *GetCurrentDir() { struct Lock *oldlock, *currentlock; /* make the root directory the current one, returns a lock to * the current directory that you were in before */ currentlock = CurrentDir(0); /* now you can use this value for anything that a lock can * do, such as Examine and so on. */ rootlock = CurrentDir(currentlock); /* change back to the current directory again, getting the * lock value on the root as you do so. (side effect). Notice * that this side effect is appropriate when moving around in a * hierarchical file system. */ Unlock(rootlock); /* undo the side effect */ return(currentlock); } /* notice that you have to Unlock() the value you receive * when you are finished with it. */ fragment? #3 #define GetCurrentDir() {(struct Lock *)Lock("",ACCESS_READ)} struct Lock *currentlock; currentlock = GetCurrentDir(); /* again, unlock whatever you lock */ and thats about all there is to it.