Subject: | not only regular files mappable |
Date: | Tue, 22 Dec 2009 08:29:46 +1100 |
To: | bug-File-Map [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
In File::Map 0.20 a program
use strict;
use warnings;
use File::Map 'map_file';
my $filename = '/dev/null';
my $str;
map_file ($str, $filename, '<');
gets an error
Could not map: handle doesn't refer to a file at /home/gg/bug/file-map-dev/foo.pl line 7
which is misleading when it says "could not map", as it is in fact
possible to map a non-file like /dev/null.
In is_stattable() I believe there's no need to demand an ordinary file
before looking at st_size. On char specials it's zero (or sometimes how
many bytes are queued for reading, supposedly). I believe it will be
simpler to have it how it was before, were an omitted size to map_file()
means get it from st_size. A caller who suspects st_size might not be a
good value can take steps, but File::Map needn't disallow outright.
(Testing file types is generally not a good idea of course -- you don't
want program or library code presuming to know the types of files the
system can or can't operate on ...)