[comp.sys.mac.programmer] Oh THIS is interesting

jtn@potomac.ads.com (John T. Nelson) (03/12/91)

Oh THIS is interesting.  There's a function to opn resources
(RFopen()) but there's no function to actually close the resource
file!  At least none that I can find offhand.  Am I expected to use
FSclose?  If I do that won't that also close the data fork which I
MIGHT want open?

See, I'd like to open both forks independently and close them
independently.  The program I'm working on compares the contents of
resource forks byte by byte.  Interestingly enough, files that are
EXECT duplicates of each other (call them fileA and fileB) have
differing resource contents, at least according to this program that
I've written.

Will resource forks ALWAYS be different between files even when I've
used COMMAND-D to duplicate them from the finder?  Their data forks
are identical, that's no problem.  But their resource forks are always
different.  Wierd.



=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
ORGANIZATION:  Advanced Decision Systems   GEOGRAPHIC: Arlington, VA
UUCP:          kzin!speaker@mimsy.umd.edu  INTERNET:   jtn@potomac.ads.com
SPOKEN:        Dark Hacker                 PHONE:      (703) 243-1611

The Mythos of Dark Hacker:

"Controlled by the sinister and shadowy "suits" Dark Hacker now employs
the tools of computer science to free himself from the suit's will.
By day he is a lackey... but at night when the city sleeps he
becomes.... DARK HACKER!"
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) (03/12/91)

The way I understand it, _OpenRF returns an i/o refnum for the resource
fork, the same way _Open returns one for the data fork. You can
use this resource fork refnum with all the regular file i/o
calls (_Read, _Write, _SetEOF etc), and when you've finished with
it, you close it with _Close.

If you open the data fork at the same time, you'll get a different
refnum, which you can use with the same calls, as though it were a
completely separate file. No conflict.

As for differences between resource forks of supposedly identical
files, it could just be because part of the first 256 bytes of the resource
fork is "reserved for system use" (see Inside Mac pgs I-128 to I-129).
Maybe something gets written here during the copying process--who knows?

Lawrence D'Oliveiro                       fone: +64-71-562-889
Computer Services Dept                     fax: +64-71-384-066
University of Waikato            electric mail: ldo@waikato.ac.nz
Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+13:00