summaryrefslogtreecommitdiffstats
path: root/ruby/ext
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 /ruby/ext
parent7bf3e1a43512293b1a3f78f880b57e7bbd372eae (diff)
downloadlibguestfs-bb07a7f858da5d07c57360e62c0ddfd24ce6be45.tar.gz
libguestfs-bb07a7f858da5d07c57360e62c0ddfd24ce6be45.tar.xz
libguestfs-bb07a7f858da5d07c57360e62c0ddfd24ce6be45.zip
Begin to add the upload and download commands.
Diffstat (limited to 'ruby/ext')
-rw-r--r--ruby/ext/guestfs/_guestfs.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c
index cd4c2718..f73a3b78 100644
--- a/ruby/ext/guestfs/_guestfs.c
+++ b/ruby/ext/guestfs/_guestfs.c
@@ -1982,6 +1982,56 @@ static VALUE ruby_guestfs_blockdev_rereadpt (VALUE gv, VALUE devicev)
return Qnil;
}
+static VALUE ruby_guestfs_upload (VALUE gv, VALUE filenamev, VALUE remotefilenamev)
+{
+ guestfs_h *g;
+ Data_Get_Struct (gv, guestfs_h, g);
+ if (!g)
+ rb_raise (rb_eArgError, "%s: used handle after closing it", "upload");
+
+ const char *filename = StringValueCStr (filenamev);
+ if (!filename)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "filename", "upload");
+ const char *remotefilename = StringValueCStr (remotefilenamev);
+ if (!remotefilename)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "remotefilename", "upload");
+
+ int r;
+
+ r = guestfs_upload (g, filename, remotefilename);
+ if (r == -1)
+ rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+ return Qnil;
+}
+
+static VALUE ruby_guestfs_download (VALUE gv, VALUE remotefilenamev, VALUE filenamev)
+{
+ guestfs_h *g;
+ Data_Get_Struct (gv, guestfs_h, g);
+ if (!g)
+ rb_raise (rb_eArgError, "%s: used handle after closing it", "download");
+
+ const char *remotefilename = StringValueCStr (remotefilenamev);
+ if (!remotefilename)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "remotefilename", "download");
+ const char *filename = StringValueCStr (filenamev);
+ if (!filename)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "filename", "download");
+
+ int r;
+
+ r = guestfs_download (g, remotefilename, filename);
+ if (r == -1)
+ rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+ return Qnil;
+}
+
/* Initialize the module. */
void Init__guestfs ()
{
@@ -2156,4 +2206,8 @@ void Init__guestfs ()
ruby_guestfs_blockdev_flushbufs, 1);
rb_define_method (c_guestfs, "blockdev_rereadpt",
ruby_guestfs_blockdev_rereadpt, 1);
+ rb_define_method (c_guestfs, "upload",
+ ruby_guestfs_upload, 2);
+ rb_define_method (c_guestfs, "download",
+ ruby_guestfs_download, 2);
}