[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Mac resource fork question



At 1:49 PM -0500 on 11/19/97, Bill Ledbetter supposedly said:
>Well, I have the resource data in raw form.  Basically, I am deciphering
>someone else's proprietary format of a file that includes the raw data
>fork, followed by the raw resource fork and don't want to wade down into
>the resource fork.  I'd just like to write it out.  I may have to resort to
>binhexing it and let Stuffit Expander handle the rejoining, but I thought
>surely Perl could do it.  I'm not all that proficient in perl5 or in C
>programming on the Mac.

Something similar this came up a while back under the topic of
BinHex/MacBinary conversions, and maybe something else.

The following line of code comes from Paul's "Conversions.pm" module.

    my $resfork = POSIX::open($outname,
                &POSIX::O_WRONLY|&Fcntl::O_RSRC |&POSIX::O_CREAT)
                or croak("Unable to open the resource fork of $outname");

The idea is that the &Fcntl::O_RSRC flag tells the POSIX::open function to
open/create the resource fork instead of the data fork. The other POSIX::
file routines can then be used to do things to the file. It appears that
the task at hand is similar to decoding a MacBinary file, so conversions.pm
might be a good source of more example code.

When you get finished, be sure to open the file with ResEdit as a final
check to make sure that everything worked out OK. This is a good debugging
step because ResEdit does a sanity check on the resource fork when it opens
a file. It will complain if you mess up.

later,

---Dave---


=========================================================
David C. Schooley              | "Success is how high you
Ph.D. in progress              |  bounce after you hit
Georgia Tech Electric Power    |  bottom.
mailto:schooley@ece.gatech.edu |   - General George S. Patton
http://www.ee.gatech.edu/users/schooley/



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch