Sha256: 3b32828848b775cc1dd8a5d7f154440ca52c05bc553ed8b1bc86e7bb05bdae7f

Contents?: true

Size: 781 Bytes

Versions: 2

Compression:

Stored size: 781 Bytes

Contents

module Drydock
  class TarWriter < ::Gem::Package::TarWriter

    def add_entry(name, mode: 0644, mtime: Time.now, uid: 0, gid: 0)
      check_closed

      fail Gem::Package::NonSeekableIO unless @io.respond_to?(:pos=)

      name, prefix = split_name(name)

      init_pos = @io.pos
      @io.write "\0" * 512 # placeholder for the header

      yield RestrictedStream.new(@io) if block_given?

      size = @io.pos - init_pos - 512

      remainder = (512 - (size % 512)) % 512
      @io.write "\0" * remainder

      final_pos = @io.pos
      @io.pos = init_pos

      header = Gem::Package::TarHeader.new(
        name: name, mode: mode,
        size: size, prefix: prefix, mtime: mtime
      )
      @io.write header
      @io.pos = final_pos

      self
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry-dock-0.2.0 lib/drydock/tar_writer.rb
dry-dock-0.1.6 lib/drydock/tar_writer.rb