    # File lib/facets/more/minitar.rb, line 366
        def add_file(name, opts = {}) # :yields RestrictedStream, +opts+:
          raise Archive::Tar::Minitar::BlockRequired unless block_given?
          raise Archive::Tar::Minitar::ClosedStream if @closed
          raise Archive::Tar::Minitar::NonSeekableStream 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), opts
            # FIXME: what if an exception is raised in the block?

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

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

          header = { :name => name, :mode => opts[:mode], :mtime => opts[:mtime],
                     :size => size, :gid => opts[:gid], :uid => opts[:uid],
                     :prefix => prefix }
          header = Archive::Tar::PosixHeader.new(header).to_s
          @io.write(header)
          @io.pos = final_pos
        end