From: Pino Toscano Date: Wed, 29 May 2019 09:48:42 +0000 (+0200) Subject: Add Augeas.mv X-Git-Tag: v0.6~6 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=afec0d966f7bd8df863672bb16de20bb641746e7;p=ocaml-augeas.git Add Augeas.mv Simple binding for aug_mv. --- diff --git a/augeas-c.c b/augeas-c.c index 7580497..d2a19b0 100644 --- a/augeas-c.c +++ b/augeas-c.c @@ -44,6 +44,7 @@ extern CAMLprim value ocaml_augeas_defvar (value tv, value namev, value exprv); extern CAMLprim value ocaml_augeas_get (value tv, value pathv); extern CAMLprim value ocaml_augeas_exists (value tv, value pathv); extern CAMLprim value ocaml_augeas_insert (value tv, value beforev, value pathv, value labelv); +extern CAMLprim value ocaml_augeas_mv (value tv, value srcv, value destv); extern CAMLprim value ocaml_augeas_rm (value tv, value pathv); extern CAMLprim value ocaml_augeas_match (value tv, value pathv); extern CAMLprim value ocaml_augeas_count_matches (value tv, value pathv); @@ -361,6 +362,21 @@ ocaml_augeas_insert (value tv, value beforev, value pathv, value labelv) CAMLreturn (Val_unit); } +/* val mv : t -> path -> path -> unit */ +CAMLprim value +ocaml_augeas_mv (value tv, value srcv, value destv) +{ + CAMLparam3 (tv, srcv, destv); + augeas_t t = Augeas_t_val (tv); + const char *src = String_val (srcv); + const char *dest = String_val (destv); + + if (aug_mv (t, src, dest) == -1) + raise_error (t, "Augeas.mv"); + + CAMLreturn (Val_unit); +} + /* val rm : t -> path -> int */ CAMLprim value ocaml_augeas_rm (value tv, value pathv) diff --git a/augeas.ml b/augeas.ml index e9dd26a..e2a2e67 100644 --- a/augeas.ml +++ b/augeas.ml @@ -82,6 +82,8 @@ external save : t -> unit = "ocaml_augeas_save" external load : t -> unit = "ocaml_augeas_load" +external mv : t -> path -> path -> unit + = "ocaml_augeas_mv" external set : t -> path -> value option -> unit = "ocaml_augeas_set" external transform : t -> string -> string -> transform_mode -> unit diff --git a/augeas.mli b/augeas.mli index af4b608..8e6ec6d 100644 --- a/augeas.mli +++ b/augeas.mli @@ -124,6 +124,9 @@ val matches : t -> path -> path list (** [matches t path] returns a list of path expressions of all nodes matching [path]. *) +val mv : t -> path -> path -> unit + (** [mv t src dest] moves a node. *) + val count_matches : t -> path -> int (** [count_matches t path] counts the number of nodes matching [path] but does not return them (see {!matches}). *)