def makeopendir(fs, directory):
    """ Creates and opens the given directory in the given PyFilesystem. """
    if not fs.isdir(directory):
        fs.makedir(directory)
    return fs.opendir(directory)
