aboutsummaryrefslogtreecommitdiffstats
path: root/c_ldirs.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--c_ldirs.go14
1 files changed, 13 insertions, 1 deletions
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
+}