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 /ruby | |
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 'ruby')
-rw-r--r-- | ruby/ext/guestfs/_guestfs.c | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c index 3861d9b7..9971228f 100644 --- a/ruby/ext/guestfs/_guestfs.c +++ b/ruby/ext/guestfs/_guestfs.c @@ -2093,6 +2093,106 @@ static VALUE ruby_guestfs_checksum (VALUE gv, VALUE csumtypev, VALUE pathv) return rv; } +static VALUE ruby_guestfs_tar_in (VALUE gv, VALUE tarfilev, VALUE directoryv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "tar_in"); + + const char *tarfile = StringValueCStr (tarfilev); + if (!tarfile) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "tarfile", "tar_in"); + const char *directory = StringValueCStr (directoryv); + if (!directory) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "directory", "tar_in"); + + int r; + + r = guestfs_tar_in (g, tarfile, directory); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_tar_out (VALUE gv, VALUE directoryv, VALUE tarfilev) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "tar_out"); + + const char *directory = StringValueCStr (directoryv); + if (!directory) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "directory", "tar_out"); + const char *tarfile = StringValueCStr (tarfilev); + if (!tarfile) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "tarfile", "tar_out"); + + int r; + + r = guestfs_tar_out (g, directory, tarfile); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_tgz_in (VALUE gv, VALUE tarballv, VALUE directoryv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "tgz_in"); + + const char *tarball = StringValueCStr (tarballv); + if (!tarball) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "tarball", "tgz_in"); + const char *directory = StringValueCStr (directoryv); + if (!directory) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "directory", "tgz_in"); + + int r; + + r = guestfs_tgz_in (g, tarball, directory); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + +static VALUE ruby_guestfs_tgz_out (VALUE gv, VALUE directoryv, VALUE tarballv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "tgz_out"); + + const char *directory = StringValueCStr (directoryv); + if (!directory) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "directory", "tgz_out"); + const char *tarball = StringValueCStr (tarballv); + if (!tarball) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "tarball", "tgz_out"); + + int r; + + r = guestfs_tgz_out (g, directory, tarball); + if (r == -1) + rb_raise (e_Error, "%s", guestfs_last_error (g)); + + return Qnil; +} + /* Initialize the module. */ void Init__guestfs () { @@ -2277,4 +2377,12 @@ void Init__guestfs () ruby_guestfs_download, 2); rb_define_method (c_guestfs, "checksum", ruby_guestfs_checksum, 2); + rb_define_method (c_guestfs, "tar_in", + ruby_guestfs_tar_in, 2); + rb_define_method (c_guestfs, "tar_out", + ruby_guestfs_tar_out, 2); + rb_define_method (c_guestfs, "tgz_in", + ruby_guestfs_tgz_in, 2); + rb_define_method (c_guestfs, "tgz_out", + ruby_guestfs_tgz_out, 2); } |