Hi
I’m trying to extract a Zipfile using the ZipFile Class.
According to the docs,
Class: Zip::ZipFile"
the extract method takes a third param to specify the behaviour if a
file already exists.
However if I try to use that param I get a “wrong number of arguments (3
for 2)” error.
My code:
=====================================================
require ‘fileutils’
require ‘zip/zip’
require ‘zip/zipfilesystem’
def unzip(file,destination)
Zip::ZipFile.open(file) { |zip_file|
zip_file.each { |f|
f_path=File.join(destination, f.name)
FileUtils.mkdir_p(File.dirname(f_path))
zip_file.extract(f, f_path, proc { true })
}
}
end
What am I doing wrong?