summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2015-04-26 16:43:21 +0600
committerDaniil Baturin <daniil@baturin.org>2015-04-26 16:43:21 +0600
commit3891244d49d3c65ef6da6b8644cfb9097b0d51b0 (patch)
tree45589a38e11e03b6af9edab7af25d4ab94ec24df /src
parent727deb901e3090653644a135c238c2f2878a4d8e (diff)
downloadvyconf-3891244d49d3c65ef6da6b8644cfb9097b0d51b0.tar.gz
vyconf-3891244d49d3c65ef6da6b8644cfb9097b0d51b0.zip
Add Vytree.exists for checking if path exists in a tree.
Diffstat (limited to 'src')
-rw-r--r--src/vytree.ml4
-rw-r--r--src/vytree.mli2
2 files changed, 6 insertions, 0 deletions
diff --git a/src/vytree.ml b/src/vytree.ml
index 3177e24..ed5efd2 100644
--- a/src/vytree.ml
+++ b/src/vytree.ml
@@ -93,6 +93,10 @@ let rec get node path =
| [name] -> find_or_fail node name
| name :: names -> get (find_or_fail node name) names
+let exists node path =
+ try ignore (get node path); true
+ with Nonexistent_path -> false
+
let get_existent_path node path =
let rec aux node path acc =
match path with
diff --git a/src/vytree.mli b/src/vytree.mli
index 4f57a0e..4b52727 100644
--- a/src/vytree.mli
+++ b/src/vytree.mli
@@ -30,3 +30,5 @@ val list_children : 'a t -> string list
val get : 'a t -> string list -> 'a t
val get_existent_path : 'a t -> string list -> string list
+
+val exists : 'a t -> string list -> bool