>I'm writing a simple program in ANSI C which is supposed to read in a file
>using the standard fread() function. This works fine on the PCs and UNIX
>systems I've tested it on, but on my Macs, it misses the entire resource
>fork. Since the program is supposed to recreate the files at the other end
>(i.e. fwrite() the data into a new file), I need to read the resources,
>otherwise the mac files are useless.
>If anyone knows how I can get the resource fork read in with ANSI C (or
>with as few Toolbox calls as possible), I'd appreciate hearing from you. I
>using the latest version of CodeWarrior (although I can't find a compiler
By now I assume you know the reason why you are having problems. However,
I have a better idea that no one has posted yet. Go into the Mac specific
parts of MSL and find file fopen.c (or it could be open.c) and make a copy
of it. Call it fopen_rsrc.c or something like that. You should be able to
make a few modifications and have it open the resource fork instead of the
data fork. Also, there is a segment about truncating that needs to be
commented out. You don't want to truncate the data fork when you open the
resource fork. Then, you can do something like this:
FILE * in = fopen_rsrc("myfile.dat");
I have done this before and it did work. However, I have since gone to a
better, OO method of my own design (that puts MSL to shame BTW). But I
probably have it on backup. Still, I don't know if I could legally post the
code or give it away since it is based on MSL. But any halfway decent Mac
programmer should be able to make these changes. Just change the FSpOpenDF
to FSpOpenRF, yada, yada, yada.
If I get an OK from MW Ron, I might dig up my old code and post it.
"Just because you're paranoid doesn't mean they aren't out to get you."