'Returns a filename that\'s free on the target storage system, and
available for new content to be written to.'

def get_available_name(self, name):

    (dir_name, file_name) = os.path.split(name)
    (file_root, file_ext) = os.path.splitext(file_name)
    count = itertools.count(1)
    while self.exists(name):
        name = os.path.join(dir_name, ('%s_%s%s' % (file_root, count.next(), file_ext)))
    return name
