func (cc *CommonConfig) SetNextProfileName(name string) error {
	if err := os.MkdirAll(cc.UserProfileDir(), 0755); err != nil {
		return err
	}
	line := strings.TrimSpace(name) + "\n"
	return ioutil.WriteFile(cc.NextProfile(), []byte(line), 0644)
}
SetNextProfileName writes the given profile name as active for the next boot.
package torcx
import (
	"bufio"
	"encoding/json"
	"io"
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"
	"github.com/pkg/errors"
	"github.com/sirupsen/logrus"
)
var DefaultLowerProfiles = []string{VendorProfileName, OemProfileName}
func CurrentProfileNames() (string, []string, error) {
	meta, err := ReadMetadata(SealPath)
	if err != nil {
		return "", nil, err
	}
	upperProfile, ok := meta[SealUpperProfile]
	if !ok {
		return "", nil, errors.New("unable to determine current upper profile name")
	}
	lowerString, ok := meta[SealLowerProfiles]
	if !ok {
		return "", nil, errors.New("unable to determine current lower profile names")
	}
	lowerProfiles := strings.Split(lowerString, ":")
	return upperProfile, lowerProfiles, nil
}
func CurrentProfilePath() (string, error) {
	var path string
	meta, err := ReadMetadata(SealPath)
	if err != nil {
		return "", err
	}
	path, ok := meta[SealRunProfilePath]
	if !ok {
		return "", errors.New("unable to determine current profile path")
	}
	if path == "" {
		return "", errors.New("invalid profile path")
	}
	return path, nil
}
func (cc *CommonConfig) NextProfileName() (string, error) {
	fc, err := ioutil.ReadFile(cc.NextProfile())
	if err != nil {
		return "", errors.Wrapf(err, "unable to read profile file")
	}
	profileName := strings.TrimSpace(string(fc))
	profileName = strings.TrimSuffix(profileName, ".json")
	profiles, err := ListProfiles(cc.ProfileDirs())
	if err != nil {
		return "", errors.Wrap(err, "could not list profiles")
	}
	if profileName == "" {
		return "", errors.New("missing profile name")
	}
	if _, ok := profiles[profileName]; !ok {
		return "", errors.Errorf("profile %q not found", profileName)
	}
	return profileName, nil
}