aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-01-23 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-01-23 20:20:20 +0100
commit18d207ef1777d9c713192f39f671ae1902f8c94a (patch)
tree4cf77b9c23b1386f436e655a960841e5e143051d
parentgood (diff)
downloadhardflip-18d207ef1777d9c713192f39f671ae1902f8c94a.tar.gz
hardflip-18d207ef1777d9c713192f39f671ae1902f8c94a.tar.bz2
hardflip-18d207ef1777d9c713192f39f671ae1902f8c94a.tar.xz
hardflip-18d207ef1777d9c713192f39f671ae1902f8c94a.tar.zst
hardflip-18d207ef1777d9c713192f39f671ae1902f8c94a.zip
segv
Diffstat (limited to '')
-rw-r--r--src/c_hardflip.go2
-rw-r--r--src/c_utils.go28
-rw-r--r--src/i_events.go2
-rw-r--r--src/i_ui.go4
4 files changed, 23 insertions, 13 deletions
diff --git a/src/c_hardflip.go b/src/c_hardflip.go
index 8ffdaba..fa6dfb4 100644
--- a/src/c_hardflip.go
+++ b/src/c_hardflip.go
@@ -63,7 +63,7 @@ type HardData struct {
}
func main() {
- data_dir := c_get_data_dir()
+ data_dir := c_get_data_dir(nil)
opts := HardOpts{true, true, false, ""}
i_ui(data_dir, opts)
}
diff --git a/src/c_utils.go b/src/c_utils.go
index 72761d8..84479ce 100644
--- a/src/c_utils.go
+++ b/src/c_utils.go
@@ -60,8 +60,8 @@ import (
// not exist
// the first path being checked is $XDG_DATA_HOME then $HOME/.local/share
// it returns the full data directory path
-func c_get_data_dir() string {
- var ptr *string
+func c_get_data_dir(ui *HardUI) string {
+ var ptr string
var home string
if home = os.Getenv("HOME"); len(home) == 0 {
c_die("env variable HOME not defined", nil)
@@ -69,18 +69,26 @@ func c_get_data_dir() string {
xdg_home := os.Getenv("XDG_DATA_HOME")
if len(xdg_home) > 0 {
- ptr = &xdg_home
+ ptr = xdg_home + "/qwe"
} else {
- ptr = &home
- *ptr += "/.local/share"
+ ptr = home + "/.local/share"
}
- *ptr += "/" + DATA_DIR_NAME
- if _, err := os.Stat(*ptr); os.IsNotExist(err) {
- if err := os.MkdirAll(*ptr, os.ModePerm); err != nil {
- c_die("could not create path " + *ptr, err)
+ ptr += "/" + DATA_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)
}
+ } else if err != nil {
+ if ui == nil {
+ c_die("could read path " + ptr, err)
+ }
+ c_error_mode("could read path" + ptr, err, ui)
+ // FIX: segv
}
- return *ptr
+ return ptr
}
// c_die displays an error string to the stderr fd and exits the program
diff --git a/src/i_events.go b/src/i_events.go
index f0ee03b..11703da 100644
--- a/src/i_events.go
+++ b/src/i_events.go
@@ -166,7 +166,7 @@ func i_fold_dir(data *HardData, item *ItemsNode) {
}
func i_reload_data(data *HardData) {
- data.data_dir = c_get_data_dir()
+ data.data_dir = c_get_data_dir(&data.ui)
g_load_count = -1
data.ldirs, data.litems, data.load_err = i_load_ui(data.data_dir, data.opts,
&data.ui)
diff --git a/src/i_ui.go b/src/i_ui.go
index ea2a593..83cdf4d 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -328,7 +328,9 @@ func i_load_ui(data_dir string,
ui.mode = LOAD_MODE
ldirs, load_err := c_load_data_dir(data_dir, opts, ui)
litems := c_load_litems(ldirs)
- ui.mode = NORMAL_MODE
+ if ui.mode != ERROR_MODE {
+ ui.mode = NORMAL_MODE
+ }
if len(load_err) == 0 {
load_err = nil
}