summaryrefslogtreecommitdiffstats
path: root/ruby
diff options
context:
space:
mode:
authorRichard Jones <rjones@trick.home.annexia.org>2009-06-22 08:20:42 +0100
committerRichard Jones <rjones@trick.home.annexia.org>2009-06-22 08:20:42 +0100
commitad8a256f54a6cb99f89bb444c8597a152a793dce (patch)
treef82b1ef05fe745c9cb2ec93275b9d0909f1a882e /ruby
parent05c34c1c1479bb07b31cfbf912743a8cf014a636 (diff)
downloadlibguestfs-ad8a256f54a6cb99f89bb444c8597a152a793dce.tar.gz
libguestfs-ad8a256f54a6cb99f89bb444c8597a152a793dce.tar.xz
libguestfs-ad8a256f54a6cb99f89bb444c8597a152a793dce.zip
Generated code for 'glob-expand'.
Diffstat (limited to 'ruby')
-rw-r--r--ruby/ext/guestfs/_guestfs.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c
index 81e36910..bcb6fefc 100644
--- a/ruby/ext/guestfs/_guestfs.c
+++ b/ruby/ext/guestfs/_guestfs.c
@@ -4055,6 +4055,35 @@ static VALUE ruby_guestfs_sh_lines (VALUE gv, VALUE commandv)
return rv;
}
+static VALUE ruby_guestfs_glob_expand (VALUE gv, VALUE patternv)
+{
+ guestfs_h *g;
+ Data_Get_Struct (gv, guestfs_h, g);
+ if (!g)
+ rb_raise (rb_eArgError, "%s: used handle after closing it", "glob_expand");
+
+ const char *pattern = StringValueCStr (patternv);
+ if (!pattern)
+ rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+ "pattern", "glob_expand");
+
+ char **r;
+
+ r = guestfs_glob_expand (g, pattern);
+ if (r == NULL)
+ rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+ int i, len = 0;
+ for (i = 0; r[i] != NULL; ++i) len++;
+ VALUE rv = rb_ary_new2 (len);
+ for (i = 0; r[i] != NULL; ++i) {
+ rb_ary_push (rv, rb_str_new2 (r[i]));
+ free (r[i]);
+ }
+ free (r);
+ return rv;
+}
+
/* Initialize the module. */
void Init__guestfs ()
{
@@ -4393,4 +4422,6 @@ void Init__guestfs ()
ruby_guestfs_sh, 1);
rb_define_method (c_guestfs, "sh_lines",
ruby_guestfs_sh_lines, 1);
+ rb_define_method (c_guestfs, "glob_expand",
+ ruby_guestfs_glob_expand, 1);
}