Reading file comments from a zip file in Ruby

I am doing a Python task in Ruby. I need to read the contents of a file and comments from a zip file. Content does not present a problem with RubyZip gem, but I can not get comments. Any ideas?

+3
source share
2 answers

In fact, you will need comments on each of the files, which made it much harder for me to find the documentation . Here is an example of how to get a comment from a file.

require 'zip/zip'

Zip::ZipFile.open("6.zip") do |zipfile|
  p zipfile.get_entry("90052.txt").comment
end
+5
source

RubyZip ZipFile comment, zip , .

.

require 'zip/zip'

Zip::ZipFile.open('zip_with_comment.zip') do |zipfile|
  puts zipfile.comment
end
+6

Source: https://habr.com/ru/post/1720451/


All Articles