'Add the TarInfo object `tarinfo\' to the archive. If `fileobj\' is
given, tarinfo.size bytes are read from it and added to the archive.
You can create TarInfo objects directly, or by using gettarinfo().
On Windows platforms, `fileobj\' should always be opened with mode
\'rb\' to avoid irritation about the file size.'

def addfile(self, tarinfo, fileobj=None):

    self._check('aw')
    tarinfo = copy.copy(tarinfo)
    buf = tarinfo.tobuf(self.format, self.encoding, self.errors)
    self.fileobj.write(buf)
    self.offset += len(buf)
    if (fileobj is not None):
        copyfileobj(fileobj, self.fileobj, tarinfo.size)
        (blocks, remainder) = divmod(tarinfo.size, BLOCKSIZE)
        if (remainder > 0):
            self.fileobj.write((NUL * (BLOCKSIZE - remainder)))
            blocks += 1
        self.offset += (blocks * BLOCKSIZE)
    self.members.append(tarinfo)
