Net::ChooseFName 0.01 review
DownloadNet::ChooseFName is a Perl extension for choosing a name of a local mirror of a net (e.g., FTP or HTTP) resource. SYNOPSIS us
|
|
Net::ChooseFName is a Perl extension for choosing a name of a local mirror of a net (e.g., FTP or HTTP) resource.
SYNOPSIS
use Net::ChooseFName;
$namer = Net::ChooseFName->new(max_length => 64); # Copies to CD ok
$name = $namer->find_name_by_response($LWP_response);
$name = $namer->find_name_by_response($LWP_response, $as_if_content_type);
$name = $namer->find_name_by_url($url, $suggested_name,
$content_type, $content_encoding);
$name = $namer->find_name_by_url($url, $suggested_name, $content_type);
$name = $namer->find_name_by_url($url, $suggested_name);
$name = $namer->find_name_by_url($url);
$namer_returns_undef = Net::ChooseFName->failer(); # Funny constructor
This module helps to pick up a local file name for a remote resource (e.g., one downloaded from Internet). It turns out that this is a tricky business; keep in mind that most servers are misconfigured, most URLs are malformed, and most filesystems are limited w.r.t. possible filenames. As a result most downloaders fail to work in some situations since they choose names which are not supported on particular filesystems, or not useful for file:///-related work.
Because of the many possible twists and ramifications, the design of this module is to be as much configurable as possible. One of ways of configurations is a rich system of options which influence different steps of the process. To cover cases when options are not flexible enough, the process is broken into many steps; each step is easily overridable by subclassing Net::ChooseFName.
The defaults are chosen to be as safe as possible while not getting very much into the ways. For example, since % is a special character on DOSish shells, to simplify working from command line on such systems, we avoid this letter in generated file names. Similarly, since MacOS has problems with filenames with 8-bit characters, we avoid them too; since may Unix programs have problem with spaces in file names, we massage them into underscores; the length of the longest file path component is restricted to 255 chars.
Note that in many situations it is advisable to make these restrictions yet stronger. For example, for copying to CD one should restrict names yet more (max_length => 64); for copying to MSDOS file systems enable option '8+3' => 1.
[In the description of methods the $self argument is omitted.]
Requirements:
Perl
Net::ChooseFName 0.01 keywords