X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=ocaml%2Fguestfs_c_actions.c;h=4d7b350a5a0925bd36d9ccd9de00b7157306be55;hp=dd2f6f47523783bb5b74687f0e73127c803a233b;hb=bb07a7f858da5d07c57360e62c0ddfd24ce6be45;hpb=7bf3e1a43512293b1a3f78f880b57e7bbd372eae diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index dd2f6f4..4d7b350 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -2275,3 +2275,51 @@ ocaml_guestfs_blockdev_rereadpt (value gv, value devicev) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_upload (value gv, value filenamev, value remotefilenamev) +{ + CAMLparam3 (gv, filenamev, remotefilenamev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("upload: used handle after closing it"); + + const char *filename = String_val (filenamev); + const char *remotefilename = String_val (remotefilenamev); + int r; + + caml_enter_blocking_section (); + r = guestfs_upload (g, filename, remotefilename); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "upload"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_download (value gv, value remotefilenamev, value filenamev) +{ + CAMLparam3 (gv, remotefilenamev, filenamev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("download: used handle after closing it"); + + const char *remotefilename = String_val (remotefilenamev); + const char *filename = String_val (filenamev); + int r; + + caml_enter_blocking_section (); + r = guestfs_download (g, remotefilename, filename); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "download"); + + rv = Val_unit; + CAMLreturn (rv); +} +