Export store.{ensureDataDir errEmptyHOME}

This commit is contained in:
Cheer Xiao 2015-02-09 13:59:05 +01:00
parent fd2e26700a
commit f0c2bc11fb
2 changed files with 4 additions and 4 deletions

View File

@ -7,16 +7,16 @@ import (
)
var (
errEmptyHOME = errors.New("Environment variable HOME is empty")
ErrEmptyHOME = errors.New("Environment variable HOME is empty")
)
// ensureDataDir ensures Elvish's data directory exists, creating it if
// necessary. It returns the path to the data directory (never with a
// trailing slash) and possible error.
func ensureDataDir() (string, error) {
func EnsureDataDir() (string, error) {
home := os.Getenv("HOME")
if home == "" {
return "", errEmptyHOME
return "", ErrEmptyHOME
}
home = strings.TrimRight(home, "/")
ddir := home + "/.elvish"

View File

@ -16,7 +16,7 @@ var createTable = map[string]string{}
// DefaultDB returns the default database for storage.
func DefaultDB() (*sql.DB, error) {
ddir, err := ensureDataDir()
ddir, err := EnsureDataDir()
if err != nil {
return nil, err
}