From: Thomas Sondergaard Date: 2010-09-11T04:55:11+09:00 Subject: Re: Rubyzip - `dup': can't dup NilClass (TypeError) Brian Candler wrote: > I don't know why this entry happens to have a type of 0, but you can > allow it like this: > > --- rubyzip-0.9.4/lib/zip/zip.rb.orig 2010-06-16 21:38:16.755077969 > +0100 > +++ rubyzip-0.9.4/lib/zip/zip.rb 2010-08-27 09:41:14.853352187 +0100 > @@ -637,12 +637,12 @@ > case (@externalFileAttributes >> 28) > when 04 > @ftype = :directory > - when 010 > + when 010, 00 > @ftype = :file > when 012 > @ftype = :symlink > The encoding of the external file attributes appears to be illegal. To verify this with another tool try running "zipinfo -v" on the zip-file and notice that it prints a '?' as the file type in the external file attributes. rubyzip should not throw if the value is unknown - it should simply translate it to :unknown. My familiarity with both ruby and rubyzip are rusting, but perhaps something like this: diff -u -r1.47 zip.rb --- lib/zip/zip.rb 14 May 2010 20:19:08 -0000 1.47 +++ lib/zip/zip.rb 10 Sep 2010 19:51:32 -0000 @@ -643,7 +643,7 @@ when 012 @ftype = :symlink else - raise ZipInternalError, "unknown file type #{'0%o' % (@externalFileAttributes >> 28)}" + @ftype = :unknown end else if name_is_directory? @@ -709,11 +709,11 @@ when :symlink ft = 012 @unix_perms ||= 0755 - else - raise ZipInternalError, "unknown file type #{self.inspect}" end - @externalFileAttributes = (ft << 12 | (@unix_perms & 07777)) << 16 + if (!ft.nil?) + @externalFileAttributes = (ft << 12 | (@unix_perms & 07777)) << 16 + end end io << The problem should also be reported to the author of the tool generating the zip archives. Regards, Thomas -- Posted via http://www.ruby-forum.com/.