add_file (Archive::Tar::Minitar::Writer)

         # File lib/archive/tar/minitar.rb, line 366
    366:     def add_file(name, opts = {}) # :yields RestrictedStream, +opts+:
    367:       raise Archive::Tar::Minitar::BlockRequired unless block_given?
    368:       raise Archive::Tar::Minitar::ClosedStream if @closed
    369:       raise Archive::Tar::Minitar::NonSeekableStream unless @io.respond_to?(:pos=)
    370:
    371:       name, prefix = split_name(name)
    372:       init_pos = @io.pos
    373:       @io.write("\0" * 512) # placeholder for the header
    374:
    375:       yield RestrictedStream.new(@io), opts
    376:         # FIXME: what if an exception is raised in the block?
    377:
    378:       size      = @io.pos - (init_pos + 512)
    379:       remainder = (512 - (size % 512)) % 512
    380:       @io.write("\0" * remainder)
    381:
    382:       final_pos = @io.pos
    383:       @io.pos   = init_pos
    384:
    385:       header = { :name => name, :mode => opts[:mode], :mtime => opts[:mtime],
    386:                  :size => size, :gid => opts[:gid], :uid => opts[:uid],
    387:                  :prefix => prefix }
    388:       header = Archive::Tar::PosixHeader.new(header).to_s
    389:       @io.write(header)
    390:       @io.pos = final_pos
    391:     end