[comp.sys.mac.programmer] How do you open your application's own data fork?

commons@Sunburn.Stanford.EDU (Peter Commons) (06/29/91)

The title says it all. I want to store and retrieve data from an application's
own data fork. How do you open it/ get a reference number for it?

Thanks in advance.


-- 
Peter Commons		
commons@cs.stanford.edu	
Computer Science Department, Stanford University

keith@Apple.COM (Keith Rollin) (07/01/91)

In article <1991Jun29.002528.4831@neon.Stanford.EDU> commons@Sunburn.Stanford.EDU (Peter Commons) writes:
>The title says it all. I want to store and retrieve data from an application's
>own data fork. How do you open it/ get a reference number for it?

Well, opening the file gets you the reference number, so that part's
easy. Now we just have to figure out how to open it.

The idea that immediately occurs to me is to get the application's
resource fork refNum by calling CurResFile() at the start of your
application. Next, find the location and name of the resource file by
calling GetFCBInfo().  That will give you the vRefNum, dirID, and file
name that you need to call HOpen().

-- 
------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc. 
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"But where the senses fail us, reason must step in."  - Galileo

mkelly@Apple.COM (Michael Kelly) (07/01/91)

In article <54493@apple.Apple.COM> keith@Apple.COM (Keith Rollin) writes:
>In article <1991Jun29.002528.4831@neon.Stanford.EDU> commons@Sunburn.Stanford.EDU (Peter Commons) writes:
>>The title says it all. I want to store and retrieve data from an application's
>>own data fork. How do you open it/ get a reference number for it?
>
>The idea that immediately occurs to me is to get the application's
>resource fork refNum by calling CurResFile() at the start of your
>application. Next, find the location and name of the resource file by
>calling GetFCBInfo().  That will give you the vRefNum, dirID, and file
>name that you need to call HOpen().
>

Why don't you just call GetAppParms (as documented in IM II, pg. 58).  It
returns the name of your application, the reference number for the 
application's resource file, and a handle to some finder information (info
about documents that were selected when the application was launched).

Mike.
-- 
_____________________________________________________________________________
Michael A. Kelly                                   America Online: Michael792
mkelly@cs.uoregon.edu or mkelly@apple.com              Compu$erve: 73567,1651
_____________________________________________________________________________

keith@Apple.COM (Keith Rollin) (07/01/91)

In article <54497@apple.Apple.COM> mkelly@Apple.COM (Michael Kelly) writes:
>In article <54493@apple.Apple.COM> keith@Apple.COM (Keith Rollin) writes:
>>In article <1991Jun29.002528.4831@neon.Stanford.EDU> commons@Sunburn.Stanford.EDU (Peter Commons) writes:
>>>The title says it all. I want to store and retrieve data from an application's
>>>own data fork. How do you open it/ get a reference number for it?
>>
>>The idea that immediately occurs to me is to get the application's
>>resource fork refNum by calling CurResFile() at the start of your
>>application. Next, find the location and name of the resource file by
>>calling GetFCBInfo().  That will give you the vRefNum, dirID, and file
>>name that you need to call HOpen().
>>
>
>Why don't you just call GetAppParms (as documented in IM II, pg. 58).  It
>returns the name of your application, the reference number for the 
>application's resource file, and a handle to some finder information (info
>about documents that were selected when the application was launched).

Right! I _knew_ there was a better way! Do what Mike says, not what I
said. I was recently playing around with INITs (which don't get to
call GetAppParms), and forgot the correct way of doing things.

-- 
------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc. 
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"But where the senses fail us, reason must step in."  - Galileo