package state

import (
	"github.com/centurylinkcloud/clc-go-cli/config"
	"io/ioutil"
	"os"
	"path"
)

func ReadFromFile(name string) ([]byte, error) {
	p, err := config.GetPath()
	if err != nil {
		return nil, err
	}
	return ioutil.ReadFile(path.Join(p, name))
}

func WriteToFile(data []byte, name string, perm os.FileMode) error {
	if err := config.CreateIfNotExists(); err != nil {
		return err
	}
	p, err := config.GetPath()
	if err != nil {
		return err
	}
	return ioutil.WriteFile(path.Join(p, name), data, perm)
}

package state

import (
	"github.com/centurylinkcloud/clc-go-cli/config"
	"io/ioutil"
	"os"
	"path"
)

func ReadFromFile(name string) ([]byte, error) {
	p, err := config.GetPath()
	if err != nil {
		return nil, err
	}
	return ioutil.ReadFile(path.Join(p, name))
}

func WriteToFile(data []byte, name string, perm os.FileMode) error {
	if err := config.CreateIfNotExists(); err != nil {
		return err
	}
	p, err := config.GetPath()
	if err != nil {
		return err
	}
	return ioutil.WriteFile(path.Join(p, name), data, perm)
}

func GetFileInfo(name string) (os.FileInfo, error) {
	p, err := config.GetPath()
	if err != nil {
		return nil, err
	}
	return os.Stat(path.Join(p, name))
}

Add GetFileInfo, which is quite self-explanatory
Add GetFileInfo, which is quite self-explanatory
