diff options
author | Richard Jones <rjones@redhat.com> | 2009-04-20 15:54:22 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-04-20 15:54:22 +0100 |
commit | 0232e722826cfda0f6042da983f9eb871f24e946 (patch) | |
tree | e08a414ae15cc70f60ed6275231f9ae050a033fe /ocaml | |
parent | 11350529fee2dbbcfda333bbe10d72f023dc2109 (diff) | |
download | libguestfs-0232e722826cfda0f6042da983f9eb871f24e946.tar.gz libguestfs-0232e722826cfda0f6042da983f9eb871f24e946.tar.xz libguestfs-0232e722826cfda0f6042da983f9eb871f24e946.zip |
Added tar-in, tar-out, tgz-in, tgz-out commands.
Diffstat (limited to 'ocaml')
-rw-r--r-- | ocaml/guestfs.ml | 4 | ||||
-rw-r--r-- | ocaml/guestfs.mli | 12 | ||||
-rw-r--r-- | ocaml/guestfs_c_actions.c | 96 |
3 files changed, 112 insertions, 0 deletions
diff --git a/ocaml/guestfs.ml b/ocaml/guestfs.ml index 337555c9..3ca33f7b 100644 --- a/ocaml/guestfs.ml +++ b/ocaml/guestfs.ml @@ -202,3 +202,7 @@ external blockdev_rereadpt : t -> string -> unit = "ocaml_guestfs_blockdev_rerea external upload : t -> string -> string -> unit = "ocaml_guestfs_upload" external download : t -> string -> string -> unit = "ocaml_guestfs_download" external checksum : t -> string -> string -> string = "ocaml_guestfs_checksum" +external tar_in : t -> string -> string -> unit = "ocaml_guestfs_tar_in" +external tar_out : t -> string -> string -> unit = "ocaml_guestfs_tar_out" +external tgz_in : t -> string -> string -> unit = "ocaml_guestfs_tgz_in" +external tgz_out : t -> string -> string -> unit = "ocaml_guestfs_tgz_out" diff --git a/ocaml/guestfs.mli b/ocaml/guestfs.mli index 4fd05dad..629e443e 100644 --- a/ocaml/guestfs.mli +++ b/ocaml/guestfs.mli @@ -385,3 +385,15 @@ val download : t -> string -> string -> unit val checksum : t -> string -> string -> string (** compute MD5, SHAx or CRC checksum of file *) +val tar_in : t -> string -> string -> unit +(** unpack tarfile to directory *) + +val tar_out : t -> string -> string -> unit +(** pack directory into tarfile *) + +val tgz_in : t -> string -> string -> unit +(** unpack compressed tarball to directory *) + +val tgz_out : t -> string -> string -> unit +(** pack directory into compressed tarball *) + diff --git a/ocaml/guestfs_c_actions.c b/ocaml/guestfs_c_actions.c index 882d5052..cfcf4e4c 100644 --- a/ocaml/guestfs_c_actions.c +++ b/ocaml/guestfs_c_actions.c @@ -2392,3 +2392,99 @@ ocaml_guestfs_checksum (value gv, value csumtypev, value pathv) CAMLreturn (rv); } +CAMLprim value +ocaml_guestfs_tar_in (value gv, value tarfilev, value directoryv) +{ + CAMLparam3 (gv, tarfilev, directoryv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("tar_in: used handle after closing it"); + + const char *tarfile = String_val (tarfilev); + const char *directory = String_val (directoryv); + int r; + + caml_enter_blocking_section (); + r = guestfs_tar_in (g, tarfile, directory); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "tar_in"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_tar_out (value gv, value directoryv, value tarfilev) +{ + CAMLparam3 (gv, directoryv, tarfilev); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("tar_out: used handle after closing it"); + + const char *directory = String_val (directoryv); + const char *tarfile = String_val (tarfilev); + int r; + + caml_enter_blocking_section (); + r = guestfs_tar_out (g, directory, tarfile); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "tar_out"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_tgz_in (value gv, value tarballv, value directoryv) +{ + CAMLparam3 (gv, tarballv, directoryv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("tgz_in: used handle after closing it"); + + const char *tarball = String_val (tarballv); + const char *directory = String_val (directoryv); + int r; + + caml_enter_blocking_section (); + r = guestfs_tgz_in (g, tarball, directory); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "tgz_in"); + + rv = Val_unit; + CAMLreturn (rv); +} + +CAMLprim value +ocaml_guestfs_tgz_out (value gv, value directoryv, value tarballv) +{ + CAMLparam3 (gv, directoryv, tarballv); + CAMLlocal1 (rv); + + guestfs_h *g = Guestfs_val (gv); + if (g == NULL) + caml_failwith ("tgz_out: used handle after closing it"); + + const char *directory = String_val (directoryv); + const char *tarball = String_val (tarballv); + int r; + + caml_enter_blocking_section (); + r = guestfs_tgz_out (g, directory, tarball); + caml_leave_blocking_section (); + if (r == -1) + ocaml_guestfs_raise_error (g, "tgz_out"); + + rv = Val_unit; + CAMLreturn (rv); +} + |