From f2590365561991f352091a12178bfd074ce3256a Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 27 Dec 2023 20:20:20 +0100 Subject: dirty but that's the way --- .gitignore | 27 +++++++++++++++++++++++++++ c_hardflip.go | 25 ++++--------------------- c_init.go | 1 + c_ldirs.go | 5 ++++- c_lhosts.go | 5 ++++- c_litems.go | 5 ++++- 6 files changed, 44 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 7d52328..15d6ef2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,28 @@ +# Created by https://www.toptal.com/developers/gitignore/api/go +# Edit at https://www.toptal.com/developers/gitignore?templates=go + +### Go ### +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work + +# End of https://www.toptal.com/developers/gitignore/api/go hf diff --git a/c_hardflip.go b/c_hardflip.go index 8155af0..3a677fd 100644 --- a/c_hardflip.go +++ b/c_hardflip.go @@ -47,14 +47,12 @@ package main -import "fmt" - // the main data structure, holds up everything important type HardData struct { litems *ItemsList - ldirs *DirsList - ui HardUI - opts HardOpts + ldirs *DirsList + ui HardUI + opts HardOpts data_dir string } @@ -69,21 +67,6 @@ func main() { opts, data_dir, } - // dir := data.ldirs.head - // for dir != nil { - // spaces := "" - // for i := 0; uint16(i) < dir.Depth; i++ { - // spaces += " " - // } - // fmt.Println(spaces, dir.ID, dir.Name + "/") - // host := dir.lhost.head - // for host != nil { - // fmt.Println(spaces, " ", host.ID, host.Filename) - // host = host.next - // } - // dir = dir.next - // } return - fmt.Println(data) - // i_ui(&data) + i_ui(&data) } diff --git a/c_init.go b/c_init.go index 336edfd..7eb82a6 100644 --- a/c_init.go +++ b/c_init.go @@ -98,6 +98,7 @@ func c_recurse_data_dir(dir, root string, opts HardOpts, host_node.Filename = filename host_node.Dir = &dir_node dir_node.lhost.add_back(host_node) + litems.add_back(&item_node) } } } diff --git a/c_ldirs.go b/c_ldirs.go index 468b542..199927a 100644 --- a/c_ldirs.go +++ b/c_ldirs.go @@ -59,6 +59,7 @@ type DirsNode struct { type DirsList struct { head *DirsNode + last *DirsNode } // adds a directory node to the list @@ -67,13 +68,15 @@ func (ldirs *DirsList) add_back(node *DirsNode) { if ldirs.head == nil { ldirs.head = new_node + ldirs.last = ldirs.head return } - curr := ldirs.head + curr := ldirs.last for curr.next != nil { curr = curr.next } curr.next = new_node + ldirs.last = curr.next } // return the list node with the according id diff --git a/c_lhosts.go b/c_lhosts.go index 8486004..fe8f7a0 100644 --- a/c_lhosts.go +++ b/c_lhosts.go @@ -76,6 +76,7 @@ type HostNode struct { type HostList struct { head *HostNode + last *HostNode } // adds a host node to the list @@ -84,14 +85,16 @@ func (lhost *HostList) add_back(node *HostNode) { if lhost.head == nil { lhost.head = new_node + lhost.last = lhost.head return } - curr := lhost.head + curr := lhost.last for curr.next != nil { curr = curr.next } new_node.ID = curr.ID + 1 curr.next = new_node + lhost.last = curr.next } func (lhost *HostList) reset_id() { diff --git a/c_litems.go b/c_litems.go index e607d19..05ffbe2 100644 --- a/c_litems.go +++ b/c_litems.go @@ -56,6 +56,7 @@ type ItemsNode struct { type ItemsList struct { head *ItemsNode + last *ItemsNode } func (litems *ItemsList) add_back(node *ItemsNode) { @@ -63,13 +64,15 @@ func (litems *ItemsList) add_back(node *ItemsNode) { if litems.head == nil { litems.head = new_node + litems.last = litems.head return } - curr := litems.head + curr := litems.last for curr.next != nil { curr = curr.next } new_node.ID = curr.ID + 1 curr.next = new_node + litems.last = curr.next } -- cgit v1.2.3