diff options
Diffstat (limited to '')
-rw-r--r-- | c_hardflip.go | 4 | ||||
-rw-r--r-- | c_init.go | 17 | ||||
-rw-r--r-- | i_events.go | 3 |
3 files changed, 15 insertions, 9 deletions
diff --git a/c_hardflip.go b/c_hardflip.go index b6e77a6..b99b418 100644 --- a/c_hardflip.go +++ b/c_hardflip.go @@ -97,7 +97,8 @@ func main() { // TODO: no ldirs just hosts raw hosts data_dir := c_get_data_dir() opts := HardOpts{true, true, false} - litems, ldirs := c_load_data_dir(data_dir, opts) + ldirs := c_load_data_dir(data_dir, opts) + litems := c_load_litems(ldirs) data := HardData{ litems, ldirs, @@ -106,7 +107,6 @@ func main() { data_dir, nil, } - c_fill_litems() c_reset_ptr(&data) // for ptr = ldirs.head; ptr != nil ; ptr = ptr.next { @@ -65,7 +65,7 @@ type HardOpts struct { // this function recurses into the specified root directory in order to load // every yaml file into memory func c_recurse_data_dir(dir, root string, opts HardOpts, - litems *ItemsList, ldirs *DirsList, + ldirs *DirsList, name string, parent *DirsNode, depth uint16) { files, err := os.ReadDir(root + dir) if err != nil { @@ -88,7 +88,7 @@ func c_recurse_data_dir(dir, root string, opts HardOpts, for _, file := range files { filename := file.Name() if file.IsDir() == true { - c_recurse_data_dir(dir + filename + "/", root, opts, litems, ldirs, + c_recurse_data_dir(dir + filename + "/", root, opts, ldirs, file.Name(), &dir_node, depth + 1) } else if filepath.Ext(filename) == ".yml" { host_node := c_read_yaml_file(root + dir + filename) @@ -106,10 +106,15 @@ func c_recurse_data_dir(dir, root string, opts HardOpts, } } -func c_load_data_dir(dir string, opts HardOpts) (*ItemsList, *DirsList) { - litems := ItemsList{} +func c_load_data_dir(dir string, opts HardOpts) *DirsList { ldirs := DirsList{} - c_recurse_data_dir("", dir + "/", opts, &litems, &ldirs, "", nil, 1) - return &litems, &ldirs + c_recurse_data_dir("", dir + "/", opts, &ldirs, "", nil, 1) + return &ldirs +} + +func c_load_litems(ldirs *DirsList) *ItemsList { + litems := ItemsList{} + + return &litems } diff --git a/i_events.go b/i_events.go index 614ef94..a95666a 100644 --- a/i_events.go +++ b/i_events.go @@ -58,7 +58,8 @@ import ( ) func i_reload_data(data *HardData) { - data.litems, data.ldirs = c_load_data_dir(data.data_dir, data.opts) + data.ldirs = c_load_data_dir(data.data_dir, data.opts) + data.litems = c_load_litems(data.ldirs) data.ui.sel_max, data.ui.count_dirs, data.ui.count_hosts = i_get_sel_max(data.ldirs) |