diff options
Diffstat (limited to 'src/c_utils.go')
-rw-r--r-- | src/c_utils.go | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/c_utils.go b/src/c_utils.go index 7ec70c0..3b94cc1 100644 --- a/src/c_utils.go +++ b/src/c_utils.go @@ -52,6 +52,7 @@ package main import ( + "errors" "fmt" "os" "os/exec" @@ -62,15 +63,13 @@ import ( // not exist // the first path being checked is $XDG_CONFIG_HOME then $HOME/.config // it returns the full data directory path -func c_get_conf_dir(ui *HardUI) string { +func c_get_conf_dir(load_err *[]error) string { var ptr string var home string if home = os.Getenv("HOME"); len(home) == 0 { - if ui == nil { - c_die("env variable HOME not defined", nil) - } - c_error_mode("env variable HOME not defined", nil, ui) + *load_err = append(*load_err, + errors.New("env variable HOME not defined")) return "" } xdg_home := os.Getenv("XDG_CONFIG_HOME") @@ -83,16 +82,10 @@ func c_get_conf_dir(ui *HardUI) string { ptr += "/" + CONF_DIR_NAME if _, err := os.Stat(ptr); os.IsNotExist(err) { if err := os.MkdirAll(ptr, os.ModePerm); err != nil { - if ui == nil { - c_die("could not create path " + ptr, err) - } - c_error_mode("could not create path" + ptr, err, ui) + *load_err = append(*load_err, err) } } else if err != nil { - if ui == nil { - c_die("could read path " + ptr, err) - } - c_error_mode("could read path" + ptr, err, ui) + *load_err = append(*load_err, err) return "" } return ptr |