aboutsummaryrefslogtreecommitdiffstats
path: root/src/c_init.go
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
commitb17fa17ff75842afa5e1fe7c8c1af6eeeebb6397 (patch)
treeb7851b958058f4f940b4f0473341294ddaf77532 /src/c_init.go
parentalright (diff)
downloadhardflip-b17fa17ff75842afa5e1fe7c8c1af6eeeebb6397.tar.gz
hardflip-b17fa17ff75842afa5e1fe7c8c1af6eeeebb6397.tar.bz2
hardflip-b17fa17ff75842afa5e1fe7c8c1af6eeeebb6397.tar.xz
hardflip-b17fa17ff75842afa5e1fe7c8c1af6eeeebb6397.tar.zst
hardflip-b17fa17ff75842afa5e1fe7c8c1af6eeeebb6397.zip
bench time
Diffstat (limited to 'src/c_init.go')
-rw-r--r--src/c_init.go23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/c_init.go b/src/c_init.go
index 6355d94..5d399e2 100644
--- a/src/c_init.go
+++ b/src/c_init.go
@@ -68,10 +68,11 @@ type HardOpts struct {
func c_recurse_data_dir(dir, root string, opts HardOpts,
ldirs *DirsList,
name string, parent *DirsNode, depth uint16,
- ui *HardUI) {
+ ui *HardUI, load_err *[]error) {
files, err := os.ReadDir(root + dir)
if err != nil {
- c_die("could not read data directory", err)
+ *load_err = append(*load_err, err)
+ return
}
dir_node := DirsNode{
name,
@@ -86,10 +87,13 @@ func c_recurse_data_dir(dir, root string, opts HardOpts,
filename := file.Name()
if file.IsDir() == true {
c_recurse_data_dir(dir + filename + "/", root, opts, ldirs,
- file.Name(), &dir_node, depth + 1, ui)
+ file.Name(), &dir_node, depth + 1, ui, load_err)
} else if filepath.Ext(filename) == ".yml" {
- host_node := c_read_yaml_file(root + dir + filename)
- if host_node == nil {
+ host_node, err := c_read_yaml_file(root + dir + filename, ui)
+ if err != nil {
+ *load_err = append(*load_err, err)
+ return
+ } else if host_node == nil {
return
}
host_node.Filename = filename
@@ -100,11 +104,12 @@ func c_recurse_data_dir(dir, root string, opts HardOpts,
}
}
-func c_load_data_dir(dir string, opts HardOpts, ui *HardUI) *DirsList {
- ldirs := DirsList{}
+func c_load_data_dir(dir string, opts HardOpts, ui *HardUI) (*DirsList, *[]error) {
+ ldirs := DirsList{}
+ var load_err []error
- c_recurse_data_dir("", dir + "/", opts, &ldirs, "", nil, 1, ui)
- return &ldirs
+ c_recurse_data_dir("", dir + "/", opts, &ldirs, "", nil, 1, ui, &load_err)
+ return &ldirs, &load_err
}
// fills litems sorting with dirs last