[comp.sys.mac.programmer] Data Fork Of Currently Running APPL

cl29+@andrew.cmu.edu (Cameron Christopher Long) (07/06/90)

Hi,

I am working on a program that stores data in its data fork. Currently,
I am opening the data fork using FOPEN since I know the name of the APPL.
However, if someone renames the program, how will I know what to open?

All suggestions are most appreciated,
Cameron Altenhof-Long
cl29@andrew.cmu.edu

steve@uswmrg2.UUCP (Steve Martin) (07/06/90)

In article <UaYrSJu00WB9Q6sY9w@andrew.cmu.edu> cl29+@andrew.cmu.edu (Cameron Christopher Long) writes:
>Hi,
>
>I am working on a program that stores data in its data fork. Currently,
>I am opening the data fork using FOPEN since I know the name of the APPL.
>However, if someone renames the program, how will I know what to open?

Why not look at the low memory CurApName?   Check Inside Macintosh II page 58.
-- 
Steve Martin                         | Nothing I say can be held against
U S West Marketing Resources Group   | Me or my employer!
(...uswat.uswest.com!uswmrg2!steve)

austing@Apple.COM (Glenn L. Austin) (07/06/90)

cl29+@andrew.cmu.edu (Cameron Christopher Long) writes:

>I am working on a program that stores data in its data fork. Currently,
>I am opening the data fork using FOPEN since I know the name of the APPL.
>However, if someone renames the program, how will I know what to open?

Use PBGetFCBInfo (IM4, pg. 179) with the refCon of the application's resource
fork as the file refCon.  This gives you the name of the application, whether
it is locked, where it is on disk, etc.

>All suggestions are most appreciated,
>Cameron Altenhof-Long
>cl29@andrew.cmu.edu
You're welcome.

-- 
-----------------------------------------------------------------------------
| Glenn L. Austin               | "Turn too soon, run out of room,          | 
| Auto Racing Enthusiast and    |   Turn too late, much better fate"        |
| Communications Toolbox Hacker |   - Jim Russell Racing School Instructors |
| Apple Computer, Inc.          | "Drive slower, race faster" - D. Waltrip  | 
| Internet:   austing@apple.com |-------------------------------------------|
| AppleLink:  AUSTIN.GLENN      | All opinions stated above are mine --     |
| Bellnet:    (408) 974-0876    |                who else would want them?  |
-----------------------------------------------------------------------------

stevec@Apple.COM (Steve Christensen) (07/07/90)

In article <UaYrSJu00WB9Q6sY9w@andrew.cmu.edu> Cameron Christopher Long writes:
>I am working on a program that stores data in its data fork. Currently,
>I am opening the data fork using FOPEN since I know the name of the APPL.
>However, if someone renames the program, how will I know what to open?

Use GetAppParms() to get the app's name.  It's described in the Segment Loader
chapter of Inside Mac volume II.

steve

topping@chinook.cis.ohio-state.edu (brian e topping) (07/09/90)

In article <1990Jul5.195908.28307@uswmrg2.UUCP> steve@uswmrg2.UUCP (Steve Martin) writes:
>In article <UaYrSJu00WB9Q6sY9w@andrew.cmu.edu> cl29+@andrew.cmu.edu (Cameron Christopher Long) writes:
>>Hi,
>>
>>I am working on a program that stores data in its data fork. Currently,
>>I am opening the data fork using FOPEN since I know the name of the APPL.
>>However, if someone renames the program, how will I know what to open?
>
>Why not look at the low memory CurApName?   Check Inside Macintosh II page 58.
>-- 

If you are working in C you can use the argv[] argument vectors passed to
the main() procedure.  The name of the program will be in a C string pointed
to by argv[0].  If you want the dirID, you can get it by a _GetVol to find
the working directory followed by a _GetWDInfo to find the dirID before you
do any file system calls that change the world as the application started.



Brian Topping
<topping@cis.ohio-state.edu>

bhil@ohs.UUCP (Brian T. Hill) (07/12/90)

From article <81985@tut.cis.ohio-state.edu>, by topping@chinook.cis.ohio-state.edu (brian e topping):
> 
> If you are working in C you can use the argv[] argument vectors passed to
> the main() procedure.  The name of the program will be in a C string pointed
> to by argv[0].  If you want the dirID, you can get it by a _GetVol to find
> the working directory followed by a _GetWDInfo to find the dirID before you
> do any file system calls that change the world as the application started.
> 
> Brian Topping
> <topping@cis.ohio-state.edu>


Hmm.  I think I've read somewhere (TechNote maybe?) that you can't get the
application's dirID by getting the current dirID when the application is
first opened.  Apparently, this method will fail if the application was
Launched by another application or some variation of that theme.

Brian T. Hill		bhil@ohs.UUCP  (bhil@ohs.uunet)
trACE(tm) Software Development
175 South  400 East
Orem, Utah, 84058
(801) 227-8778

mneerach@inf.ethz.ch (Matthias Ulrich Neeracher) (07/13/90)

In article <561@ohs.UUCP> bhil@ohs.UUCP (Brian T. Hill) writes:
>From article <81985@tut.cis.ohio-state.edu>, by topping@chinook.cis.ohio-state.edu (brian e topping):
>> If you are working in C you can use the argv[] argument vectors passed to
>> the main() procedure.  The name of the program will be in a C string pointed
>> to by argv[0].  If you want the dirID, you can get it by a _GetVol to find
>> the working directory followed by a _GetWDInfo to find the dirID before you
>> do any file system calls that change the world as the application started.
>Hmm.  I think I've read somewhere (TechNote maybe?) that you can't get the
>application's dirID by getting the current dirID when the application is
>first opened.  Apparently, this method will fail if the application was
>Launched by another application or some variation of that theme.

There is also a (quite useful) INIT called DFaultD which lets users change
the default folder at startup. As soon as somebody decides to use this with
your application, there care problems.

***************************************************************************
* Matthias Neeracher   * I wouldn't recommend sex, drugs or insanity for  *
* mneerach@inf.ethz.ch * everyone, but they've always worked for me - HST *
***************************************************************************

austing@Apple.COM (Glenn L. Austin) (07/14/90)

bhil@ohs.UUCP (Brian T. Hill) writes:
>From article <81985@tut.cis.ohio-state.edu>, by topping@chinook.cis.ohio-state.edu (brian e topping):
>> 
>> If you are working in C you can use the argv[] argument vectors passed to
>> the main() procedure.  The name of the program will be in a C string pointed
>> to by argv[0].  If you want the dirID, you can get it by a _GetVol to find
>> the working directory followed by a _GetWDInfo to find the dirID before you
>> do any file system calls that change the world as the application started.
>> 
>> Brian Topping
>> <topping@cis.ohio-state.edu>

>Hmm.  I think I've read somewhere (TechNote maybe?) that you can't get the
>application's dirID by getting the current dirID when the application is
>first opened.  Apparently, this method will fail if the application was
>Launched by another application or some variation of that theme.

You can use PBGetFCBInfo with the CurResFile() as the refNum of the file.  This
will return GOBS of info about the file, including the dirID and vRefNum.
PBGetFCBInfo is on pg. 179 of IM 4.

-- 
-----------------------------------------------------------------------------
| Glenn L. Austin               | "Turn too soon, run out of room,          | 
| Auto Racing Enthusiast and    |   Turn too late, much better fate"        |
| Communications Toolbox Hacker |   - Jim Russell Racing School Instructors |
| Apple Computer, Inc.          | "Drive slower, race faster" - D. Waltrip  | 
| Internet:   austing@apple.com |-------------------------------------------|
| AppleLink:  AUSTIN.GLENN      | All opinions stated above are mine --     |
| Bellnet:    (408) 974-0876    |                who else would want them?  |
-----------------------------------------------------------------------------