Method: SevenZipRuby::SevenZipReader.extract
- Defined in:
- lib/seven_zip_ruby/seven_zip_reader.rb
.extract(stream, index, dir = ".", param = {}) ⇒ Object
Open and extract 7zip archive.
Args
stream
-
Input stream to read 7zip archive.
stream.seek
andstream.read
are needed, such asFile
andStringIO
. index
-
Index of the entry to extract. Integer or Array of Integer can be specified.
dir
-
Directory to extract the archive to.
param
-
Optional hash parameter.
:password
key represents password of this archive.
Examples
File.open("filename.7z", "rb") do |file|
SevenZipRuby::SevenZipReader.extract(file, 1, "path_to_dir")
end
File.open("filename.7z", "rb") do |file|
SevenZipRuby::SevenZipReader.extract(file, [1, 2, 4], "path_to_dir", password: "PasswordOfArchive")
end
File.open("filename.7z", "rb") do |file|
SevenZipRuby::SevenZipReader.extract(file, :all, "path_to_dir")
end
174 175 176 177 178 179 |
# File 'lib/seven_zip_ruby/seven_zip_reader.rb', line 174 def extract(stream, index, dir = ".", param = {}) password = { password: param.delete(:password) } self.open(stream, password) do |szr| szr.extract(index, dir) end end |