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

Re: [MacPerl] How to decode MacBinary with MacPerl



At 4:19 PM 3/31/96, rose@internet.sj.com (Axel Rose, SRPINGER & JACOBY
Werbung GmbH wrote:

>Basically I am looking for a way to convert a MacBinary file
>to a Mac file with MacPerl.
>
>I run a download with the help of ftplib from within MacPerl.
>In order to restore the resource fork the files need to be
>stored as MacBinary on the UNIX ftp server. Transformation
>can only take place on the Mac side.
>
>Programs like Fetch or StuffitExpander automatically handle
>this situation. But I want to avoid any additional programs.
>
>Has anybody ever written a piece of Perl code which is able
>to decode MacBinary?
>Is there any XCMD available?
>

The first real Mac program I ever wrote was to do conversion from
MacBinary. Using MacPerl to do the conversion should be pretty easy if you
can track down a couple of missing parts.

1) You need a copy of the MacBinary standard. I think I have seen it on one
of Apple's ftp sites, but a search just now didn't turn up anything. Let me
know if you have trouble finding it and I'll see if I have it on a floppy
somewhere.

The file format is pretty simple. There is some header information which
you should be able to handle with 'unpack'. The header contains file type
and creator information, the name of the original file, and the lengths of
the data and resource forks. The data for the two forks follows the header.

2) Unless there is some way to do it directly with MacPerl, you need an
XCMD that lets you write to a resource fork as if it were an ordinary data
file, i.e., a variation on 'print'. An XCMD that writes individual
resources won't work.

My guess is 15-20 lines of perl code to do this, perhaps fewer.

later,

---Dave---


========================================================================
David C. Schooley                         |
Ph.D. in progress                         |
Georgia Tech Electric Power               |       Simplify.
email: schooley@ee.gatech.edu             |
http://www.ee.gatech.edu/users/schooley/  |