Skip Menu |

This queue is for tickets about the Archive-Zip CPAN distribution.

Report information
The Basics
Id: 118035
Status: new
Priority: 0/
Queue: Archive-Zip

People
Owner: Nobody in particular
Requestors: tschoening [...] am-soft.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Support File::Temp in Archive::Zip::read
I've used Archive::Zip::read with string paths to files and recently changed that to a, in my context, better maintainable File::Temp, because that should be fully transparent for all users which either expect a string path or a FileHandle object. But sadly this doesn't work for Archive::Zip, because the object is ultimately forwarded to _newFileHandle, which detects File::Temp to be a IO::Handle and forwards it to fdopen. The problem in fdopen now is that stringification is used to check if a given object is a GLOB, a file descriptor number or something else. Because File::Temp overloads stringification and returns the path to the file, the check for a GLOB is always false. So the provided object is directly forwarded to open, which uses stringification for file handle dup-syntax and this fails, because a path to a file is no allowed handle. The produced error message: Show quoted text
> IO error: opening [...] for read : Invalid argument
fdopen: Show quoted text
> if (ref($fd) && "".$fd =~ /GLOB\(/o) { > # It's a glob reference; Alias it as we cannot get name of anon GLOBs > my $n = qualify(*GLOB); > *GLOB = *{*$fd}; > $fd = $n; > } elsif ($fd =~ m#^\d+$#) { > # It's an FD number; prefix with "=". > $fd = "=$fd"; > } > > open($io, _open_mode_string($mode) . '&' . $fd) > ? $io : undef;
The first line fails. As File::Temp is IO::Handle and IO::Seekable, it should be fine to check for it in _newFileHandle and use it like IO::Scalar or IO::String I guess.