aboutsummaryrefslogtreecommitdiffstats
path: root/c_ldirs.go
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2023-12-26 20:20:20 +0100
committerJoe <rbo@gmx.us>2023-12-26 20:20:20 +0100
commitda0196ddaeb1de894efbb12c86a7741d3ba1e856 (patch)
treecad0936e7794609bcdd8cb75a8745488a47313d7 /c_ldirs.go
parentmust rewrite inti (diff)
downloadhardflip-da0196ddaeb1de894efbb12c86a7741d3ba1e856.tar.gz
hardflip-da0196ddaeb1de894efbb12c86a7741d3ba1e856.tar.bz2
hardflip-da0196ddaeb1de894efbb12c86a7741d3ba1e856.tar.xz
hardflip-da0196ddaeb1de894efbb12c86a7741d3ba1e856.tar.zst
hardflip-da0196ddaeb1de894efbb12c86a7741d3ba1e856.zip
its fucked
Diffstat (limited to 'c_ldirs.go')
-rw-r--r--c_ldirs.go34
1 files changed, 33 insertions, 1 deletions
diff --git a/c_ldirs.go b/c_ldirs.go
index 03d5657..f78ef97 100644
--- a/c_ldirs.go
+++ b/c_ldirs.go
@@ -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
+}