Method: SevenZipRuby::SevenZipReader.open_file
- Defined in:
- lib/seven_zip_ruby/seven_zip_reader.rb
.open_file(filename, param = {}, &block) ⇒ Object
Open 7zip archive to read.
Args
filename
-
Filename of 7zip archive.
param
-
Optional hash parameter.
:password
key represents password of this archive.
Examples
# Open archive
SevenZipRuby::SevenZipReader.open_file("filename.7z") do |szr|
# Read and extract archive.
end
# Open encrypted archive
SevenZipRuby::SevenZipReader.open_file("filename.7z", password: "PasswordOfArchive") do |szr|
# Read and extract archive.
end
# Open without block.
szr = SevenZipRuby::SevenZipReader.open_file("filename.7z")
# Read and extract archive.
szr.close
138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/seven_zip_ruby/seven_zip_reader.rb', line 138 def open_file(filename, param = {}, &block) # :yield: szr szr = self.new szr.open_file(filename, param) if (block) begin block.call(szr) szr.close ensure szr.close_file end else szr end end |