diff options
Diffstat (limited to 'c_init.go')
-rw-r--r-- | c_init.go | 31 |
1 files changed, 20 insertions, 11 deletions
@@ -60,7 +60,8 @@ 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, ldirs *DirsList, +func c_recurse_data_dir(dir, root string, opts HardOpts, + litems *ItemsList, ldirs *DirsList, id *uint64, name string, parent *DirsNode, depth uint16) { files, err := os.ReadDir(root + dir) if err != nil { @@ -75,30 +76,38 @@ func c_recurse_data_dir(dir, root string, opts HardOpts, ldirs *DirsList, opts.FoldAll, nil, } + item_node := ItemsNode{} + item_node.Dirs = &dir_node + item_node.Host = nil *id++ ldirs.add_back(&dir_node) + litems.add_back(&item_node) for _, file := range files { filename := file.Name() if file.IsDir() == true { - c_recurse_data_dir(dir + filename + "/", root, opts, ldirs, + c_recurse_data_dir(dir + filename + "/", root, opts, litems, ldirs, id, file.Name(), &dir_node, depth + 1) } else if filepath.Ext(filename) == ".yml" { - host := c_read_yaml_file(root + dir + filename) - if host == nil { + host_node := c_read_yaml_file(root + dir + filename) + if host_node == nil { return } - host.Filename = filename - host.Dir = &dir_node - dir_node.lhost.add_back(host) + item_node := ItemsNode{} + item_node.Dirs = nil + item_node.Host = host_node + host_node.Filename = filename + host_node.Dir = &dir_node + dir_node.lhost.add_back(host_node) } } } -func c_load_data_dir(dir string, opts HardOpts) *DirsList { - ldirs := DirsList{} +func c_load_data_dir(dir string, opts HardOpts) (*ItemsList, *DirsList) { + litems := ItemsList{} + ldirs := DirsList{} var id uint64 id = 0 - c_recurse_data_dir("", dir + "/", opts, &ldirs, &id, "", nil, 1) - return &ldirs + c_recurse_data_dir("", dir + "/", opts, &litems, &ldirs, &id, "", nil, 1) + return &litems, &ldirs } |