[erlang-questions] [bug] zip archives in memory (patch incl.)

Martin Dvořák martin.dvorak@REDACTED
Wed Apr 2 13:27:21 CEST 2008


Hi,

I've found two bugs regarding handling zip archives in memory. The 
attached patch solves both of them, it has been tested with R11B5 and 
should work with R12B1 as well.

1. When decompressing from memory (ie. the archive given as a binary to 
extract/2), the decompression crashes when the archive contains a directory.

This is because get_z_file/7 returns In accumulator (when it encounters 
a directory), which is a tuple in case of binary_io/2, but the calling 
get_z_files/5 function undestands the tuple as a return value and a new 
accumulator.

2. When decompressing to memory (ie. with the 'memory' option passed to 
extract/2), the directories found in the archive are created on the real 
disk filesystem.

This is because filelib:ensure_dir/1 is called in get_z_file/7 no matter 
which function (file_io/2 or binary_io/2) has been selected for output.


/Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zip.patch
Type: text/x-diff
Size: 1884 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080402/b4b26e9d/attachment.bin>


More information about the erlang-questions mailing list