From d614eb676448a8b03de7a54b738446caf64343ee Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 9 Jan 2024 20:20:20 +0100 Subject: i can't fix that shit --- c_ldirs.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'c_ldirs.go') diff --git a/c_ldirs.go b/c_ldirs.go index d707686..d7628e7 100644 --- a/c_ldirs.go +++ b/c_ldirs.go @@ -110,9 +110,21 @@ func (dir *DirsNode) path() string { return path } +// returns the number of hosts of the dir func (dir *DirsNode) count_hosts() int { - if dir.lhost.head == nil { + if dir.lhost.head == nil || dir.lhost.last == nil { return 0 } return dir.lhost.last.ID + 1 } + +// return the number of hosts and subfolders of the dir +func (dir *DirsNode) count_elements() int { + items := 0 + + items += dir.count_hosts() + for ptr := dir.next; ptr != nil && ptr.Depth > dir.Depth; ptr = ptr.next { + items += ptr.count_hosts() + 1 + } + return items +} -- cgit v1.2.3