[comp.sys.mac.programmer] finding system folder and MPW C

jim@b-mrda.UUCP (Jim Sadler) (11/30/88)

Where do I find the information to have a program find the system folder that
is currently active, when the system folder is on a diffent volume than the 
application.  I want to do this using MPW C.  Any info would be appreciated.

	Thanks

		jim sadler
		206-234-5422
		hpubvwa!b-mrda!jim
		P.O. Box 3707 MS 6R-24
		Seattle, Wa. USA 98124

	Any opinions expressed are mine and mine only and not that of my
	employer.  Also add in whatever else should be said at this point.

drc@claris.com (Dennis Cohen) (12/02/88)

In article <7800002@b-mrda.UUCP>, jim@b-mrda.UUCP (Jim Sadler) writes:
> 
> Where do I find the information to have a program find the system folder that
> is currently active, when the system folder is on a diffent volume than the 
> application.  I want to do this using MPW C.  Any info would be appreciated.
> 

You can get the information you need from the SysEnvRec (the sysVRefNum
field).  It contains the wdRefnum of the currently active system folder.

Dennis Cohen
Claris Corp.
------------
Disclaimer:  Any opinions expressed above are _MINE_!

han@Apple.COM (Byron Han, Architect) (12/02/88)

In article <7800002@b-mrda.UUCP> jim@b-mrda.UUCP (Jim Sadler) writes:
>
>Where do I find the information to have a program find the system folder that
>is currently active, when the system folder is on a diffent volume than the 
>application.  I want to do this using MPW C.  Any info would be appreciated.
>
Technical Note 67.  "Finding the <<BlessedFolder>>"

FUNCTION GetBlessed(vRefNum: INTEGER; VAR blessed: LONGINT): OSErr;
VAR
    myHPB: HParamBlockRec;
    error: OSErr;

BEGIN
    blessed := 0;
    WITH myHPB DO BEGIN
        ioNamePtr := NIL;
        ioVRefNum := vRefNum;
        ioVolIndex := 0;
        error := PBHGetVInfo(@myHPB, FALSE);
        IF error = noErr THEN
            blessed := ioVFndrInfo[1];
    END; {with}
    GetBlessed := error;
END;

It is easy to convert to MPW C.

Please check the tecnical note for to see if I made any typos.


+-----------------------------------------------------------------------------+
| Disclaimer: Apple has no connection with my postings.                       |
+-----------------------------------------------------------------------------+
Byron Han, Communications Architect      Macintosh xxx: The Next Generation...
Apple Computer, Inc.                     -------------------------------------
20525 Mariani Ave, MS27Y                 Internet: han@apple.COM
Cupertino, CA 95014                      UUCP:{sun,voder,nsc,decwrl}!apple!han
--------------------------------------   GENIE: BYRONHAN
ATTnet: 408-974-6450   Applelink: HAN1   CompuServe: 72167,1664
------------------------------------------------------------------------------

dgold@Apple.COM (David Goldsmith) (12/03/88)

In article <21532@apple.Apple.COM> han@Apple.COM (Byron Han, Architect) writes:
>In article <7800002@b-mrda.UUCP> jim@b-mrda.UUCP (Jim Sadler) writes:
>>
>>Where do I find the information to have a program find the system folder that
>>is currently active, when the system folder is on a diffent volume than the 
>>application.  I want to do this using MPW C.  Any info would be appreciated.
>>
>Technical Note 67.  "Finding the <<BlessedFolder>>"
>

This is no longer the preferred way to find the system folder.  Call
SysEnvirons instead; the wdRefNum of the system folder will be returned
as part of the information.
-- 
David Goldsmith                                           Apple Computer, Inc.
AppleLink: GOLDSMITH1    BIX: dgoldsmith         20525 Mariani Avenue, MS: 46B
UUCP: {nsc,dual,sun,voder,ucbvax!mtxinu}!apple!dgold       Cupertino, CA 95014
CSNET: dgold@apple.com

leonardr@uxe.cso.uiuc.edu (12/03/88)

>In article <7800002@b-mrda.UUCP>, jim@b-mrda.UUCP (Jim Sadler) writes:
>> 
>> Where do I find the information to have a program find the system folder that
>> is currently active, when the system folder is on a diffent volume than the 
>> application.  I want to do this using MPW C.  Any info would be appreciated.
>> 
>
>You can get the information you need from the SysEnvRec (the sysVRefNum
>field).  It contains the wdRefnum of the currently active system folder.
>
	Just to clarify what Dennis said...You should call SysEnvirons which will
return to you a SysEnvRec.  One of the fields of the SysEnvRec is sysVRefNum
which contains that wdRefnum of the current System Folder (blessed folder).
Code wise (in C) this looks like:

myOSErr = SysEnvirons(version, &myEnvirons);
sysVRef = myEnvirons.sysVRefNum;

(version is an integer (short) which defines what version of SysEnvirons you
want (currently highest version is 2))

+---------------------------------+-----------------------------------+
+                                 +  Any thing I say may be taken as  +
+   Leonard Rosenthol             +  fact, then again you might decide+
+   President, LazerWare, inc.    +  that it really isn't, so you     +
+                                 +  never know, do you??             +
+   leonardr@uxe.cso.uiuc.edu     +                                   +
+   GEnie:  MACgician             +  MacNET: MACgician                +
+   Delphi: MACgician             +  AppleLink: D0025                 +
+                                 +                                   +
+---------------------------------+-----------------------------------+

holland@m2.csc.ti.com (Fred Hollander) (12/05/88)

In article <21532@apple.Apple.COM> han@Apple.COM (Byron Han, Architect) writes:
>In article <7800002@b-mrda.UUCP> jim@b-mrda.UUCP (Jim Sadler) writes:
>>
>>Where do I find the information to have a program find the system folder that
>>is currently active, when the system folder is on a diffent volume than the 
>>application.  I want to do this using MPW C.  Any info would be appreciated.
>>
>Technical Note 67.  "Finding the <<BlessedFolder>>"
>
>FUNCTION GetBlessed(vRefNum: INTEGER; VAR blessed: LONGINT): OSErr;
[function deleted]
TN 67 also says that this method is used for finding the blessed folder on
arbitrary volumes.  To be sure to get the blessed folder for the currently
active system, use SysEnvirons.

Fred Hollander
Computer Science Center
Texas Instruments, Inc.
holland%ti-csl@csnet-rela

The above statements are my own and not representative of Texas Instruments.