# frozen_string_literal: true # # Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com) # # ronin-support is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published # by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # ronin-support is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with ronin-support. If not, see . # require 'ronin/support/compression/zlib' require 'stringio' module Ronin module Support module Compression module Gzip # # Handles reading gzip compressed data. # # @see https://rubydoc.info/stdlib/zlib/Zlib/GzipReader # # @api public # # @since 1.0.0 # class Reader < ::Zlib::GzipReader # # Initializes the gzip writer. # # @param [IO, StringIO, String] io_or_buffer # The IO object or buffer to read from. If a `String` is given, then # it will be wrapped in a `StringIO` object using the optional # `mode` argument. # # @param [String] mode # The optional mode to initialize the `StringIO` object to wrap # around the given buffer `String`. # # @example Initializing with an IO object: # gzip = Compression::Gzip::Reader.new(io) # # @example Initializing with a buffer: # buffer = "..." # gzip = Compression::Gzip::Reader.new(buffer) # def initialize(io_or_buffer, mode: 'r') io = case io_or_buffer when String then StringIO.new(io_or_buffer,mode) else io_or_buffer end super(io) end end end end end end