root/Mac-Macbinary/trunk/README

Revision 20 (checked in by miyagawa, 20 years ago)

updated document.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 NAME
2     Mac::Macbinary - Decodes Macbinary files.
3
4 SYNOPSIS
5       use Mac::Macbinary;
6
7       $mb = new Mac::Macbinary(\*FH);       # filehandle
8       $mb = new Mac::Macbinary($fh);        # IO::* instance
9       $mb = new Mac::Macbinary("/path/to/file");
10
11       $header = $mb->header;                # Mac::Macbinary::Header instance
12       $name = $header->name;
13
14 DESCRIPTION
15     This module provides an object-oriented way to extract various kinds of
16     information from Macintosh Macbinary files.
17
18 METHODS
19     Following methods are available.
20
21   Class method
22
23     new(*THINGY*)
24         Constructor of Mac::Macbinary. Accepts filhandle GLOB reference,
25         FileHandle instance, IO::* instance, or whatever objects that can do
26         `read' methods.
27
28         If the argument belongs none of those above, `new()' treats it as a
29         path to file. Any of following examples are valid constructors.
30
31           open FH, "path/to/file";
32           $mb = new Mac::Macbinary(\*FH);
33
34           $fh = new FileHandle "path/to/file";
35           $mb = new Mac::Macbinary($fh);
36
37           $io = new IO::File "path/to/file";
38           $mb = new Mac::Macbinary($io);
39
40           $mb = new Mac::Macbinary "path/to/file";
41
42         `new()' throws an exception "Can't read blahblah" if the given
43         argument to the constructor is neither a valid filehandle nor an
44         existing file.
45
46   Instance Method
47
48     data
49         returns the data range of original file.
50
51     header
52         returns the header object (instance of Mac::Macbinary::Header).
53
54     Following accessors are available via Mac::Macbinary instance.
55
56     name, type, creator, flags, location, dflen, rflen, cdate, mdate
57         returns the original entry in the header of Macbinary file. Below is
58         a structure of the info file, taken from MacBin.C
59
60           char zero1;
61           char nlen;
62           char name[63];
63           char type[4];           65      0101
64           char creator[4];        69
65           char flags;             73
66           char zero2;             74      0112
67           char location[6];       80
68           char protected;         81      0121
69           char zero3;             82      0122
70           char dflen[4];
71           char rflen[4];
72           char cdate[4];
73           char mdate[4];
74
75 EXAMPLE
76     Some versions of MSIE for Macintosh sends their local files as Macbinary
77     format via forms. You can decode them in a following way:
78
79       use CGI;
80       use Mac::Macbinary;
81
82       $q = new CGI;
83       $filename = $q->param('uploaded_file');
84       $type = $q->uploadInfo($filename)->{'Content-Type'};
85      
86       if ($type eq 'application/x-macbinary') {
87           $mb = Mac::Macbinary->new($q->upload('uploaded_file');
88           # now, you can get data via $mb->data;
89       }
90
91 TODO
92     should add `is_macbinary()', to detect if a file is a Macbinary file or
93     not.
94
95 AUTHOR
96     Tatsuhiko Miyagawa <miyagawa@bulknews.net>
97
98 ACKNOWLEDGEMENT
99     Macbinary.pm is originally written by Dan Kogai <dankogai@dan.co.jp>.
100
101     There are also `Mac::Conversions' and `Convert::BinHex', which works kind
102     similar to this module. (However, `Mac::Conversions' works only on
103     MacPerl, and `Convert::BinHex' is now deprecated.) Many thanks to Paul J.
104     Schinder and Eryq, authors of those ones.
105
106 SEE ALSO
107     perl(1).
108
Note: See TracBrowser for help on using the browser.