Re: [MacPerl-Porters] [ macperl-Bugs-664987 ] IO::File + leading space for hard disk
[email protected] (Chris Nandor) Thu, 9 Jan 2003 11:13:16 -0500
| Newsgroups | perl.macperl.porters |
|---|---|
| Message-ID | <p05200f02ba434e3b3c62@[10.0.1.104]> |
At 15:21 +0100 2003.01.09, Bart Lateur wrote:
>On Thu, 09 Jan 2003 03:59:10 -0800, SourceForge.net wrote:
>
>>The following failes:
>
>>$fh->open( '$file', "r" ) or die "unable to open'$file' - $!";
>>
>>Note the leading space in the hard disk name " myharddisk".
>
>Also note the single quotes around $file in the method call. Could that
>be it, or is this a case of badly typed over code?
I noted in the bug report that IO::File->open uses either sysopen for
numeric modes, or two-arg open. There is no way, that I know of, to open a
path that has leading space, period, with two-arg open. If the path is
relative, you can protect it with "./", but that is not possible here.
I -- or someone who wants to -- needs to patch IO::File to use three-arg
open. It'd be pretty easy, but will require testing, of course. Something
like (untested)
if (! File::Spec->file_name_is_absolute($file)) {
$file = File::Spec->catfile(File::Spec->curdir(),$file);
}
- $file = IO::Handle::_open_mode_string($mode) . " $file\0";
+ return open($fh, IO::Handle::_open_mode_string($mode), $file);
}
open($fh, $file);
Would just need to make sure this doesn't break anything (including
pre-perl 5.6, if IO still works there).
--
Chris Nandor [email protected] http://pudge.net/
Open Source Development Network [email protected] http://osdn.com/