summaryrefslogtreecommitdiffstats
path: root/ocaml
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-18 22:33:15 +0100
committerRichard Jones <rjones@redhat.com>2009-04-18 22:33:15 +0100
commitbb07a7f858da5d07c57360e62c0ddfd24ce6be45 (patch)
tree56201f1c514d8d79a56251b104c3d8a135fcbd39 /ocaml
parent7bf3e1a43512293b1a3f78f880b57e7bbd372eae (diff)
downloadlibguestfs-bb07a7f858da5d07c57360e62c0ddfd24ce6be45.tar.gz
libguestfs-bb07a7f858da5d07c57360e62c0ddfd24ce6be45.tar.xz
libguestfs-bb07a7f858da5d07c57360e62c0ddfd24ce6be45.zip
Begin to add the upload and download commands.
Diffstat (limited to 'ocaml')
-rw-r--r--ocaml/guestfs.ml2
-rw-r--r--ocaml/guestfs.mli6
-rw-r--r--ocaml/guestfs_c_actions.c48
3 files changed, 56 insertions, 0 deletions
diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml
index 0ea77c70..f45533bb 100644
--- a/ocaml/guestfs.ml
+++ b/ocaml/guestfs.ml
@@ -197,3 +197,5 @@ external blockdev_getsz : t -> string -> int64 = "ocaml_guestfs_blockdev_getsz"
external blockdev_getsize64 : t -> string -> int64 = "ocaml_guestfs_blockdev_getsize64"
external blockdev_flushbufs : t -> string -> unit = "ocaml_guestfs_blockdev_flushbufs"
external blockdev_rereadpt : t -> string -> unit = "ocaml_guestfs_blockdev_rereadpt"
+external upload : t -> string -> string -> unit = "ocaml_guestfs_upload"
+external download : t -> string -> string -> unit = "ocaml_guestfs_download"
diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli
index 6c763631..2257fc0c 100644
--- a/ocaml/guestfs.mli
+++ b/ocaml/guestfs.mli
@@ -370,3 +370,9 @@ val blockdev_flushbufs : t -> string -> unit
val blockdev_rereadpt : t -> string -> unit
(** reread partition table *)
+val upload : t -> string -> string -> unit
+(** upload a file from the local machine *)
+
+val download : t -> string -> string -> unit
+(** download a file to the local machine *)
+
diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c
index dd2f6f47..4d7b350a 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);
+}
+