def write_cache_file(source_cache_d, key_filenames, rosdep_data):
    """
    :param source_cache_d: directory to write cache file to
    :param key_filenames: filename (or list of filenames) to be used in hashing
    :param rosdep_data: dictionary of data to serialize as YAML
    :returns: name of file where cache is stored
    :raises: :exc:`OSError` if cannot write to cache file/directory
    :raises: :exc:`IOError` if cannot write to cache file/directory
    """
    if not os.path.exists(source_cache_d):
        os.makedirs(source_cache_d)
    key_hash = compute_filename_hash(key_filenames)
    filepath = os.path.join(source_cache_d, key_hash)
    try:
        write_atomic(filepath + PICKLE_CACHE_EXT, pickle.dumps(rosdep_data, -1), True)
    except __HOLE__ as e:
        raise CachePermissionError("Failed to write cache file: " + str(e))
    try:
        os.unlink(filepath)
    except OSError:
        pass
    return filepath
dataset/ETHPy150Open ros-infrastructure/rosdep/src/rosdep2/sources_list.py/write_cache_file