Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read file comments from a zip file in Ruby

Tags:

ruby

zip

rubyzip

I am doing Python challenge in Ruby. I need to read the file contents and comments from a Zip file. The content is no problem with the RubyZip gem but I am unable to get the comments out. Any ideas?

like image 285
Gerhard Avatar asked Dec 18 '22 05:12

Gerhard


1 Answers

According to the documentation an instance of the RubyZip ZipFile class has a comment attribute which returns the zip file's comment, if it has one.

e.g.

require 'zip/zip'

Zip::ZipFile.open('zip_with_comment.zip') do |zipfile|
  puts zipfile.comment
end
like image 69
mikej Avatar answered Jan 03 '23 09:01

mikej