func CreateTorusRoot() (string, error) {
	torusRoot := os.Getenv("TORUS_ROOT")
	if len(torusRoot) == 0 {
		torusRoot = path.Join(os.Getenv("HOME"), ".torus")
	}

	src, err := os.Stat(torusRoot)
	if err != nil && !os.IsNotExist(err) {
		return "", err
	}

	if err == nil && !src.IsDir() {
		return "", fmt.Errorf("%s exists but is not a dir", torusRoot)
	}

	if os.IsNotExist(err) {
		err = os.Mkdir(torusRoot, requiredPermissions)
		if err != nil {
			return "", err
		}

		src, err = os.Stat(torusRoot)
		if err != nil {
			return "", err
		}
	}

	fMode := src.Mode()
	if fMode.Perm() != requiredPermissions {
		return "", fmt.Errorf("%s has permissions %d requires %d",
			torusRoot, fMode.Perm(), requiredPermissions)
	}

	return torusRoot, nil
}
// CreateTorusRoot creates the root directory for the Torus daemon.
CreateTorusRoot creates the root directory for the Torus daemon.
// CreateTorusRoot creates the root directory for the Torus daemon .
func CreateTorusRoot() (string, error) {
	torusRoot := os.Getenv("TORUS_ROOT")
	if len(torusRoot) == 0 {
		torusRoot = path.Join(os.Getenv("HOME"), ".torus")
	}
	src, err := os.Stat(torusRoot)
	if err != nil && !os.IsNotExist(err) {
		return "", err
	}
	if err == nil && !src.IsDir() {
		return "", fmt.Errorf("%s exists but is not a dir", torusRoot)
	}
	if os.IsNotExist(err) {
		err = os.Mkdir(torusRoot, requiredPermissions)
		if err != nil {
			return "", err
		}
		src, err = os.Stat(torusRoot)
		if err != nil {
			return "", err
		}
	}
	fMode := src.Mode()
	if fMode.Perm() != requiredPermissions {
		return "", fmt.Errorf("%s has permissions %d requires %d",
			torusRoot, fMode.Perm(), requiredPermissions)
	}
	return torusRoot, nil
}
func CreateTorusRoot ( ) ( string , error ) { torusRoot := os . Getenv ( " " ) if len ( torusRoot ) == 0 { torusRoot = path . Join ( os . Getenv ( " " ) , " " ) } src , err := os . Stat ( torusRoot ) if err != nil && ! os . IsNotExist ( err ) { return " " , err } if err == nil && ! src . IsDir ( ) { return " " , fmt . Errorf ( " " , torusRoot ) } if os . IsNotExist ( err ) { err = os . Mkdir ( torusRoot , requiredPermissions ) if err != nil { return " " , err } src , err = os . Stat ( torusRoot ) if err != nil { return " " , err } } fMode := src . Mode ( ) if fMode . Perm ( ) != requiredPermissions { return " " , fmt . Errorf ( " " , torusRoot , fMode . Perm ( ) , requiredPermissions ) } return torusRoot , nil }
CreateTorusRoot creates the root directory for the Torus daemon.
CreateTorusRoot creates the root directory for the Torus daemon .