summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/genie/src/base/tree.lua
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/genie/src/base/tree.lua')
-rw-r--r--3rdparty/genie/src/base/tree.lua32
1 files changed, 18 insertions, 14 deletions
diff --git a/3rdparty/genie/src/base/tree.lua b/3rdparty/genie/src/base/tree.lua
index 73c85af624a..5e4322d4238 100644
--- a/3rdparty/genie/src/base/tree.lua
+++ b/3rdparty/genie/src/base/tree.lua
@@ -43,7 +43,11 @@
if p == "." then
return tr
end
-
+
+ if p == "/" then
+ return tr
+ end
+
-- Look for the immediate parent for this new node, creating it if necessary.
-- Recurses to create as much of the tree as necessary.
local parentnode = tree.add(tr, path.getdirectory(p), onaddfunc)
@@ -53,7 +57,7 @@
if childname == ".." then
return parentnode
end
-
+
-- Create the child if necessary. If two children with the same name appear
-- at the same level, make sure they have the same path to prevent conflicts
-- i.e. ../Common and ../../Common can both appear at the top of the tree
@@ -66,7 +70,7 @@
onaddfunc(childnode)
end
end
-
+
return childnode
end
@@ -176,32 +180,32 @@
-- process an individual node
donode = function(node, fn, depth)
- if node.isremoved then
- return
+ if node.isremoved then
+ return
end
- if fn.onnode then
- fn.onnode(node, depth)
+ if fn.onnode then
+ fn.onnode(node, depth)
end
-
+
if #node.children > 0 then
if fn.onbranchenter then
fn.onbranchenter(node, depth)
end
- if fn.onbranch then
- fn.onbranch(node, depth)
+ if fn.onbranch then
+ fn.onbranch(node, depth)
end
dochildren(node, fn, depth + 1)
if fn.onbranchexit then
fn.onbranchexit(node, depth)
end
else
- if fn.onleaf then
- fn.onleaf(node, depth)
+ if fn.onleaf then
+ fn.onleaf(node, depth)
end
end
end
-
+
-- this goofy iterator allows nodes to be removed during the traversal
dochildren = function(parent, fn, depth)
local i = 1
@@ -213,7 +217,7 @@
end
end
end
-
+
-- set a default initial traversal depth, if one wasn't set
if not initialdepth then
initialdepth = 0