Save the register to <salt cachedir>/thorium/saves/<name>, or to an
    absolute path.

    If an absolute path is specified, then the directory will be created
    non-recursively if it doesn't exist.

    USAGE:

    .. code-block:: yaml

        foo:
          file.save

        /tmp/foo:
          file.save

def save(name, filter=False):
    '''
    Save the register to <salt cachedir>/thorium/saves/<name>, or to an
    absolute path.

    If an absolute path is specified, then the directory will be created
    non-recursively if it doesn't exist.

    USAGE:

    .. code-block:: yaml

        foo:
          file.save

        /tmp/foo:
          file.save
    '''
    ret = {'name': name,
           'changes': {},
           'comment': '',
           'result': True}
    if name.startswith('/'):
        tgt_dir = os.path.dirname(name)
        fn_ = name
    else:
        tgt_dir = os.path.join(__opts__['cachedir'], 'thorium', 'saves')
        fn_ = os.path.join(tgt_dir, name)
    if not os.path.isdir(tgt_dir):
        os.makedirs(tgt_dir)
    with salt.utils.files.fopen(fn_, 'w+') as fp_:
        if filter is True:
            salt.utils.json.dump(salt.utils.data.simple_types_filter(__reg__), fp_)
        else:
            salt.utils.json.dump(__reg__, fp_)
    return ret