Method: AppInfo::Util.unarchive
- Defined in:
- lib/app_info/util.rb
.unarchive(file, path: nil) ⇒ Object
Unarchive zip file
source: github.com/soffes/lagunitas/blob/master/lib/lagunitas/ipa.rb
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/app_info/util.rb', line 71 def self.unarchive(file, path: nil) path = path ? "#{path}-" : '' root_path = "#{Dir.mktmpdir}/AppInfo-#{path}#{SecureRandom.hex}" Zip::File.open(file) do |zip_file| if block_given? yield root_path, zip_file else zip_file.each do |f| f_path = File.join(root_path, f.name) FileUtils.mkdir_p(File.dirname(f_path)) zip_file.extract(f, f_path) unless File.exist?(f_path) end end end root_path end |