class Zip::ArchiveSource
- Zip::ArchiveSource
- Zip::Source
- Reference
- Object
Overview
Use file from another Archive
as a source for an Archive#add
or
Archive#replace
.
Example
# open source archive
Zip::Archive.open("foo.zip") do |src_zip|
# open destination archive
Zip::Archive.create("bar.zip") do |dst_zip|
# create source from "some-file.txt" in "foo.zip"
source = ArchiveSource.new(dst_zip, src_zip, "some-file.txt")
# add to destination archive as "foo.txt"
dst_zip.add("foo.txt", source)
end
end
Defined in:
zip/sources.crConstructors
-
.new(dst_zip : Archive, src_zip : Archive, src_index : UInt64, offset : UInt64 = 0_u64, len : Int64 = -1_i64, flags : Int32 = 0)
Create ArchiveSource from source zip and source index.
-
.new(dst_zip : Archive, src_zip : Archive, src_path : String, offset : UInt64 = 0_u64, len : Int64 = -1_i64, flags : Int32 = 0)
Create
ArchiveSource
from source zip and source path.
Instance methods inherited from class Zip::Source
to_unsafe : LibZip::ZipSourceT
to_unsafe
Constructor Detail
def self.new(dst_zip : Archive, src_zip : Archive, src_index : UInt64, offset : UInt64 = 0_u64, len : Int64 = -1_i64, flags : Int32 = 0)
#
Create ArchiveSource from source zip and source index.
Raises an exception if ArchiveSource
could not be created.
Example
# open source archive
Zip::Archive.open("foo.zip") do |src_zip|
# open destination archive
Zip::Archive.create("bar.zip") do |dst_zip|
# define index
index = 0
# create source from index in "foo.zip"
source = ArchiveSource.new(dst_zip, src_zip, index)
# add to destination archive as "foo.txt"
zip.add("foo.txt", source)
end
end
def self.new(dst_zip : Archive, src_zip : Archive, src_path : String, offset : UInt64 = 0_u64, len : Int64 = -1_i64, flags : Int32 = 0)
#
Create ArchiveSource
from source zip and source path.
Raises an exception if ArchiveSource
could not be created.
Example
# open source archive
Zip::Archive.open("foo.zip") do |src_zip|
# open destination archive
Zip::Archive.create("bar.zip") do |dst_zip|
# create source from "some-file.txt" in "foo.zip"
source = ArchiveSource.new(dst_zip, src_zip, "some-file.txt")
# add to destination archive as "foo.txt"
dst_zip.add("foo.txt", source)
end
end