diff options
author | Joe <rbo@gmx.us> | 2023-12-27 20:20:20 +0100 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2023-12-27 20:20:20 +0100 |
commit | b152d0fe07e75ff7a4303cadca25771e6237ca6c (patch) | |
tree | abfb8a9ee7d23c7ddf037f8fa4a12b99305999b9 /c_init.go | |
parent | how (diff) | |
download | hardflip-b152d0fe07e75ff7a4303cadca25771e6237ca6c.tar.gz hardflip-b152d0fe07e75ff7a4303cadca25771e6237ca6c.tar.bz2 hardflip-b152d0fe07e75ff7a4303cadca25771e6237ca6c.tar.xz hardflip-b152d0fe07e75ff7a4303cadca25771e6237ca6c.tar.zst hardflip-b152d0fe07e75ff7a4303cadca25771e6237ca6c.zip |
not quite clean
Diffstat (limited to '')
-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 } |