def add_files_to_zip(zip_file, base_dir, file_list):
  """Pack a list of files into a zip archive, that is already opened for
  writing.

  Args:
    zip_file: An object representing the zip archive.
    base_dir: Base path of all the files in the real file system.
    file_list: List of absolute file paths to add. Must start with base_dir.
        The base_dir is stripped in the zip file entries.
  """
  if (base_dir[-1] != '/'):
    base_dir += '/'
  for file_path in file_list:
    assert file_path.startswith(base_dir)
    zip_file.write(file_path, file_path[len(base_dir):])
  return 0