X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=ocaml%2Fguestfs_c_actions.c;h=1ce55f0ac1fbefd8dab02485fa76a1578c84cf11;hb=2eda36dbadd4687f7488a86eea9313bbe30cde82;hp=e4dc509990708543c88788fc856d25d4f8fb52dc;hpb=4211c7a258debd236017a19c70965bc1b3658edb;p=libguestfs.git diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index e4dc509..1ce55f0 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -4248,3 +4248,29 @@ ocaml_guestfs_sh_lines (value gv, value commandv) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_glob_expand (value gv, value patternv) +{ + CAMLparam2 (gv, patternv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("glob_expand: used handle after closing it"); + + const char *pattern = String_val (patternv); + int i; + char **r; + + caml_enter_blocking_section (); + r = guestfs_glob_expand (g, pattern); + caml_leave_blocking_section (); + if (r == NULL) + ocaml_guestfs_raise_error (g, "glob_expand"); + + rv = caml_copy_string_array ((const char **) r); + for (i = 0; r[i] != NULL; ++i) free (r[i]); + free (r); + CAMLreturn (rv); +} +