aboutsummaryrefslogtreecommitdiffstats
path: root/c_init.go
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2023-12-21 20:20:20 +0100
committerJoe <rbo@gmx.us>2023-12-21 20:20:20 +0100
commit3edca0fd3c5b0411ef2dc95bfe9f34865b5fb55f (patch)
treec7983a4d1fe26c2de0398dc18d15b374e530a219 /c_init.go
parenticon option (diff)
downloadhardflip-3edca0fd3c5b0411ef2dc95bfe9f34865b5fb55f.tar.gz
hardflip-3edca0fd3c5b0411ef2dc95bfe9f34865b5fb55f.tar.bz2
hardflip-3edca0fd3c5b0411ef2dc95bfe9f34865b5fb55f.tar.xz
hardflip-3edca0fd3c5b0411ef2dc95bfe9f34865b5fb55f.tar.zst
hardflip-3edca0fd3c5b0411ef2dc95bfe9f34865b5fb55f.zip
must rewrite inti
Diffstat (limited to '')
-rw-r--r--c_init.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/c_init.go b/c_init.go
index ca26683..5a9bc21 100644
--- a/c_init.go
+++ b/c_init.go
@@ -59,14 +59,20 @@ 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 string, root string, lhost *HostList) {
+// TODO - must rewrite this function entirely
+func c_recurse_data_dir(dir string, root string,
+ lhost *HostList, ldirs *DirsList) {
files, err := os.ReadDir(root + dir)
if err != nil {
c_die("could not read data directory", err)
}
for _, file := range files {
if file.IsDir() == true {
- c_recurse_data_dir(dir + file.Name() + "/", root, lhost)
+ var dir_node *DirsNode
+ dir_node.name = file.Name()
+ dir_node.parent = dont_know
+ ldirs.add_back(dir_node)
+ c_recurse_data_dir(dir + file.Name() + "/", root, lhost, ldirs)
} else if filepath.Ext(file.Name()) == ".yml" {
host := c_read_yaml_file(root + dir + file.Name())
if host == nil {
@@ -82,6 +88,9 @@ func c_recurse_data_dir(dir string, root string, lhost *HostList) {
func c_load_data_dir(dir string) (*HostList, *DirsList) {
lhost := HostList{}
ldirs := DirsList{}
- c_recurse_data_dir("", dir + "/", &lhost)
+ var root_dir DirsNode
+
+ ldirs.add_back(&root_dir)
+ c_recurse_data_dir("", dir + "/", &lhost, &ldirs)
return &lhost, &ldirs
}