X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=ocaml%2Fguestfs_c_actions.c;h=0dcaf3f31ae7912f2fc964520eed0e59a8137ce4;hb=ff9c8dfcd178dcd3a35ae3e368b461f3bf44b2ad;hp=c64bcf09349281ba658cc91920a312b677d327b9;hpb=ca49c50e06834bbc68e21630a5552c57494f2b53;p=libguestfs.git diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index c64bcf0..0dcaf3f 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -3426,3 +3426,29 @@ ocaml_guestfs_resize2fs (value gv, value devicev) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_find (value gv, value directoryv) +{ + CAMLparam2 (gv, directoryv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("find: used handle after closing it"); + + const char *directory = String_val (directoryv); + int i; + char **r; + + caml_enter_blocking_section (); + r = guestfs_find (g, directory); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "find"); + + rv = caml_copy_string_array ((const char **) r); + for (i = 0; r[i] != NULL; ++i) free (r[i]); + free (r); + CAMLreturn (rv); +} +