🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #10185

Re: Manx help

#10185
From: Randell Jesup
Date: Wed, 02 Nov 1988 05:10
52 lines
2525 bytes
In article <7517@well.UUCP> ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) writes:
>In article <679@ardent.UUCP> rap@ardent.UUCP (Rob Peck) writes:
>>main()  
>>{
>>	/* CORRECT METHOD */
>>
>>	struct FileLock *testlock, *aarrgghh;
>>	testlock = Lock("RAM:",ACCESS_READ);
>>	aarrgghh = CurrentDir(testlock);
>>
>>	/* aarrgghh is a pointer to the lock on the
>>	 * directory that the CLI started from...
>>	 * it may still need that lock sometime later.
>>	 * If we free it by UnLock, we mess things up.
>>	 */
>>
>>	UnLock(testlock);
>>	/* Did nothing more than move current CLI's
>>	 * current directory to ram:
>>	 */
>>}
>	It strikes me that, if you UnLock() the lock you handed to
>CurrentDir() (and therefore the system), you'll pull the rug out from under
>the CLI's feet when it tries to access that lock.

	You're right, Leo: the above code is wrong.  If that last UnLock
line read: UnLock(CurrentDir(aarrgghh)), it would be correct.  Note that
all programs run from WB currently must restore the original lock via
CurrentDir before exiting (I think some compiler startups may do this for
you.)

>	I thought, as another Net person said (name forgotten; sorry), that
>CurrentDir() trades locks with you.  You hand CurrentDir() a lock on the
>directory you want to go to.  CurrentDir() takes it away from you, and
>gives you posession of a lock on the directory you used to be in.  This is
>how I do it in Onion, and I haven't had any problems yet.

	You have it exactly right (though PLEASE use CurrentDir(), don't
just trade them yourselves, for future compatiblity.

>	What is the final story?  Naturally, the DOS docs obfuscate this
>point.

	The DOS docs (amigados users, tech ref, and programmers manuals)
should be read 15 times apiece, left under your pillow so you can absorb
them by osmosis, read 5 more times, and consantly referred to.  :-)

>Leo L. Schwab -- The Guy in The Cape	INET: well!ewhac@ucbvax.Berkeley.EDU

-- 
You've heard of CATS? Well, I'm a member of DOGS: Developers Of Great Software.
Randell Jesup, Commodore Engineering {uunet|rutgers|allegra}!cbmvax!jesup
Technical Details
Message-ID: <5171@cbmvax.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cbmvax!jesup
References: <5918@killer.DALLAS.TX.US> <679@ardent.UUCP> <7517@well.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cbmvax!jesup
From: jesup@cbmvax.UUCP (Randell Jesup)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Manx help
Message-ID: <5171@cbmvax.UUCP>
Date: 2 Nov 88 05:10:54 GMT
References: <5918@killer.DALLAS.TX.US> <679@ardent.UUCP> <7517@well.UUCP>
Reply-To: jesup@cbmvax.UUCP (Randell Jesup)
Organization: Commodore Technology, West Chester, PA
Lines: 52