= "ocaml_augeas_rm"
external matches : t -> path -> path list
= "ocaml_augeas_match"
+external count_matches : t -> path -> int
+ = "ocaml_augeas_count_matches"
external save : t -> unit
= "ocaml_augeas_save"
(** [matches t path] returns a list of path expressions
of all nodes matching [path]. *)
+val count_matches : t -> path -> int
+ (** [count_matches t path] counts the number of nodes matching
+ [path] but does not return them (see {!matches}). *)
+
val save : t -> unit
(** [save t] saves all pending changes to disk. *)
r = aug_match (t, path, &matches);
if (r == -1)
- raise_error ("Augeas.match");
+ raise_error ("Augeas.matches");
/* Copy the paths to a list. */
rv = Val_int (0);
CAMLreturn (rv);
}
+/* val count_matches : t -> path -> int */
+CAMLprim value
+ocaml_augeas_count_matches (value tv, value pathv)
+{
+ CAMLparam2 (tv, pathv);
+ augeas_t t = Augeas_t_val (tv);
+ char *path = String_val (path);
+ int r;
+
+ r = aug_match (t, path, NULL);
+ if (r == -1)
+ raise_error ("Augeas.count_matches");
+
+ CAMLreturn (Val_int (r));
+}
+
/* val save : t -> unit */
CAMLprim value
ocaml_augeas_save (value tv)