[comp.sys.mac.programmer] What's the best strategy for copying a resource file?

vrm@blackwater.cerc.wvu.wvnet.edu (Vasile R. Montan) (05/09/91)

I want to completely copy a resource file.  There is nothing in
the data fork of the file.  In some cases, I will want to copy
everything in the resource fork; in other cases, I will want to
leave out a small number of the resources.

I've thought of several strategies for doing this; does anyone else
have some experience to share?  Here are possible strategies:

1.  Open the resource fork using OpenRF; copy it byte-by-byte
into the new file.  In cases where I want to leave certain resources
out, reopen the file as a resource file and RmveResource the unwanted
resources.

2.  Open the file as a resource file.  Iterate through the resources
and copy each one, skipping those that I want to leave out.  (I am
aware of the gotchas involved in doing this and how to avoid them)

3.  If there is some Toolbox call that completely copies a file,
this strategy would work (it is a variant of #1).  Call the routine
to duplicate the file; then open the resource fork and remove any
unwanted resources.

In no case will the resource fork be very big; it would be rare
to find files over, say, 100K or a few dozen resources.

Any suggestions?

--Kurisuto
un020070@vaxa.wvnet.edu