|Subject:||Using Archive::Zip reading from IO::String results in a seek error|
I have an application which needs to read zipped data from a scalar. I therefore wrapped the in-memory zipped content into an IO::String, created Archive::Zip using new and parsed the zipped data using Archive::Zip::read. Everything seemed to work, I got the zip members, their sizes etc., but on accessing the contents using the contents()-method of any member the only return was "4", which indicates an error. After some debugging I found that Archive::Zip::Archive::read closes the file handle it worked with, resulting in IO::String discarding it's associated buffer. As IO::String is no file, it really loses any data and Archive::Zip can't just reopen the given handle anymore. If my application calls IO::String::open on the former created object with the former used in memory zip data again, $member->contents() is working as expected. From my point of view this is a bug as Archive::Zip::Archive::Read should only close file handles it opened itself and/or is sure of that closing and reopening a file handle is possible without data loss. This is not the case with IO::String as on closing it deletes it buffers.