diff options
author | Joe <rbo@gmx.us> | 2024-02-01 20:20:20 +0100 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-02-01 20:20:20 +0100 |
commit | 2601e660db5ffb7a57e2496c24f9bbb52a0158f3 (patch) | |
tree | 1b5144ee08df2f2066c039e43c4bafe8786421d9 /src/c_utils.go | |
parent | useless changes (diff) | |
download | hardflip-2601e660db5ffb7a57e2496c24f9bbb52a0158f3.tar.gz hardflip-2601e660db5ffb7a57e2496c24f9bbb52a0158f3.tar.bz2 hardflip-2601e660db5ffb7a57e2496c24f9bbb52a0158f3.tar.xz hardflip-2601e660db5ffb7a57e2496c24f9bbb52a0158f3.tar.zst hardflip-2601e660db5ffb7a57e2496c24f9bbb52a0158f3.zip |
conf
Diffstat (limited to '')
-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 |