aboutsummaryrefslogtreecommitdiffstats
path: root/c_ldirs.go
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-01-11 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-01-11 20:20:20 +0100
commitbcbf5b5db7a15071da9c7ae25f4a7abdcc572587 (patch)
tree257f6b01674987e3574b413a179d203549318f9d /c_ldirs.go
parentqwe (diff)
downloadhardflip-bcbf5b5db7a15071da9c7ae25f4a7abdcc572587.tar.gz
hardflip-bcbf5b5db7a15071da9c7ae25f4a7abdcc572587.tar.bz2
hardflip-bcbf5b5db7a15071da9c7ae25f4a7abdcc572587.tar.xz
hardflip-bcbf5b5db7a15071da9c7ae25f4a7abdcc572587.tar.zst
hardflip-bcbf5b5db7a15071da9c7ae25f4a7abdcc572587.zip
cool
Diffstat (limited to 'c_ldirs.go')
-rw-r--r--c_ldirs.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/c_ldirs.go b/c_ldirs.go
index 141a0b8..be1a225 100644
--- a/c_ldirs.go
+++ b/c_ldirs.go
@@ -79,6 +79,43 @@ func (ldirs *DirsList) add_back(node *DirsNode) {
ldirs.last = last.next
}
+// removes a dir node from the list
+func (ldirs *DirsList) del(dir *DirsNode) {
+ if ldirs.head == nil {
+ return
+ }
+ if ldirs.head == dir {
+ ldirs.head = ldirs.head.next
+ if ldirs.head == nil {
+ ldirs.last = nil
+ return
+ }
+ for ptr := ldirs.head; ptr != nil; ptr = ptr.next {
+ ptr.ID -= 1
+ }
+ return
+ }
+ if ldirs.last == dir {
+ ptr := ldirs.head
+ for ptr.next != nil {
+ ptr = ptr.next
+ }
+ ldirs.last = ptr
+ ldirs.last.next = nil
+ return
+ }
+ ptr := ldirs.head
+ for ptr.next != nil && ptr.next != dir {
+ ptr = ptr.next
+ }
+ if ptr.next == dir {
+ ptr.next = ptr.next.next
+ }
+ for ptr := ptr.next; ptr != nil; ptr = ptr.next {
+ ptr.ID -= 1
+ }
+}
+
// return the list node with the according id
func (ldirs *DirsList) sel(id int) *DirsNode {
curr := ldirs.head