2021-05-24 01:24:22 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2010-11-30 16:27:59 +08:00
|
|
|
module Zip
|
2022-11-07 05:26:37 +08:00
|
|
|
class PassThruCompressor < Compressor # :nodoc:all
|
2020-02-19 15:28:46 +08:00
|
|
|
def initialize(output_stream)
|
2010-11-30 16:27:59 +08:00
|
|
|
super()
|
2020-02-19 15:28:46 +08:00
|
|
|
@output_stream = output_stream
|
2015-03-21 16:16:06 +08:00
|
|
|
@crc = Zlib.crc32
|
2010-11-30 16:27:59 +08:00
|
|
|
@size = 0
|
|
|
|
end
|
2015-03-21 03:43:29 +08:00
|
|
|
|
2015-03-23 00:43:44 +08:00
|
|
|
def <<(data)
|
2010-11-30 16:27:59 +08:00
|
|
|
val = data.to_s
|
2015-03-21 16:16:06 +08:00
|
|
|
@crc = Zlib.crc32(val, @crc)
|
2012-04-12 18:01:40 +08:00
|
|
|
@size += val.bytesize
|
2013-06-03 02:33:03 +08:00
|
|
|
@output_stream << val
|
2010-11-30 16:27:59 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
attr_reader :size, :crc
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Copyright (C) 2002, 2003 Thomas Sondergaard
|
|
|
|
# rubyzip is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the ruby license.
|