[comp.sys.mac.programmer] Using Resource Fork to store data

commons@Sunburn.Stanford.EDU (Peter Commons) (07/18/90)

I'm currently working on a new multi-user game for the Mac. In thinking about
how I would like my save file to look, it would be very convenient to have
one resource with the main data and one resource with the data for each player
(rather than have all the data sequentially laid out in the data fork) because
the game will only need to look at one player's info at a time. 

Can I do this? If so, should I use my own (non-reserved) resource name? And if
I define my own resource type, how do I specify it's length (or does it 
automatically make it as long as the handle I pass it when I call AddResource?

Thanks in advance.



--
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
|   Peter Commons			"Zut, alors! I have meesed one!!!"    |
|   commons@cs.stanford.edu						      |
|   Computer Science Department, Stanford University			      |

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

In article <1990Jul17.172044.20361@Neon.Stanford.EDU> Peter Commons writes:
>I'm currently working on a new multi-user game for the Mac. In thinking about
>how I would like my save file to look, it would be very convenient to have
>one resource with the main data and one resource with the data for each player
>(rather than have all the data sequentially laid out in the data fork) because
>the game will only need to look at one player's info at a time. 
>
>Can I do this? If so, should I use my own (non-reserved) resource name? And if
>I define my own resource type, how do I specify it's length (or does it 
>automatically make it as long as the handle I pass it when I call AddResource?

Yes, you can do that.  And, yes, you should use a non-reserved resource name.
AddResource will make a resource that's as big as the handle you pass to it.
Typically your program would have a record that defines the player data and
you'd pass the sizeof() that data to NewHandle to create the handle...

steve
-- 
____________________________________________________________________

  Steve Christensen             Internet:   stevec@goofy.apple.com
  Apple Computer, Inc.          AppleLink:  CHRISTENSE1
  20525 Mariani Ave, MS 81-CS   CompuServe: 76174,1712
  Cupertino, CA  95014

  "You just contradicted me."  "No I didn't."
____________________________________________________________________