diff options
author | Joe <rbo@gmx.us> | 2023-12-26 20:20:20 +0100 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2023-12-26 20:20:20 +0100 |
commit | da0196ddaeb1de894efbb12c86a7741d3ba1e856 (patch) | |
tree | cad0936e7794609bcdd8cb75a8745488a47313d7 /c_ldirs.go | |
parent | must rewrite inti (diff) | |
download | hardflip-da0196ddaeb1de894efbb12c86a7741d3ba1e856.tar.gz hardflip-da0196ddaeb1de894efbb12c86a7741d3ba1e856.tar.bz2 hardflip-da0196ddaeb1de894efbb12c86a7741d3ba1e856.tar.xz hardflip-da0196ddaeb1de894efbb12c86a7741d3ba1e856.tar.zst hardflip-da0196ddaeb1de894efbb12c86a7741d3ba1e856.zip |
its fucked
Diffstat (limited to '')
-rw-r--r-- | c_ldirs.go | 34 |
1 files changed, 33 insertions, 1 deletions
@@ -39,7 +39,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/c_ldirs.go - * Thu Dec 21 18:06:00 2023 + * Tue Dec 26 11:09:27 2023 * Joe * * the directories linked list @@ -48,6 +48,7 @@ package main type DirsNode struct { + ID uint64 name string lhost *HostList parent *DirsNode @@ -72,3 +73,34 @@ func (ldirs *DirsList) add_back(node *DirsNode) { } curr.next = new_node } + +// return the list node with the according id +func (ldirs *DirsList) sel(id uint64) *DirsNode { + curr := ldirs.head + + if curr == nil { + return nil + } + for curr.next != nil && curr.ID != id { + curr = curr.next + } + if curr.ID != id { + return nil + } + return curr +} + +// returns a string with the full path of the dir +func (ldirs *DirsList) path(node *DirsNode) string { + var path string + + if node == nil { + return "" + } + curr := node + for curr != nil { + path = curr.name + "/" + path + curr = curr.parent + } + return path +} |