Re: [MacPerl-Porters] default type/creator

[email protected] (Bart Lateur)
Newsgroups perl.macperl.porters
Organization MediaMind
Message-ID <[email protected]>
On Tue, 23 Oct 2001 23:25:23 +0200, Axel Rose wrote:

>using Net::FTP I wonder about the following:
>  $ftp->binary;
>  $ftp->get( $remote_file, $local_file );
>The local file has type/creator set to TEXT/'MPS '.
>
>It doesn't matter much if the application using this downloaded
>data ignores type/creator (.jpg, .pdf, .doc). But on the other
>hand if a user happens to double-click that data he might arrive
>in a text editor. Isn't it better to avoid wrong usage at all.
>
>I know how to avoid this by using MacBinary conversion.
>The conversion process needs time though and the programmer
>has to handle the extra files (.bin, .1). So if I care
>I can always reconstruct the original type/creator information.
>
>I believe patching Net::FTP is the wrong direction.
>MacPerl probably can't do much because it doesn't know
>whether I transfer in binary mode.

FTP is a protocol intended to exchange files with Unix and similar
systems. That means that only data forks can/may be transferred, and
that file extensions are meaningful.

In short: you'll need a mechanism to map file extensions into
creator/file type, with (user editable) database. The Mac commonly has
some built in. I can remember the "DOS" control panel, which provided a
crator/file type for files on a DOS floppy disk.

Internet Config has a similar system. Since this comes with MacPerl, I
think it would be best to tap into that, if possible. Preferably with an
extra module. Judging from the user interface, this should be able to
tell you if this is indeed a text file, or a binary file.

Well... There's a module, Net::Config, which relies on
Mac::InternetConfig for some settings. Both come with MacPerl. The
latter might be able to do what we want; the ICMapEntry related stuff
looks particularly promising.

-- 
	Bart.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.