diff options
author | Richard Jones <rjones@trick.home.annexia.org> | 2009-05-19 12:05:43 +0100 |
---|---|---|
committer | Richard Jones <rjones@trick.home.annexia.org> | 2009-05-19 12:05:43 +0100 |
commit | 1fc41b39dac877ccec1284da8bb14baa4df368b8 (patch) | |
tree | 74d0693b6d97d796b75847ace4815109c17b3198 /ruby/ext | |
parent | d1df2f342489bbbba086cae2bb95971c8e404cad (diff) | |
download | libguestfs-1fc41b39dac877ccec1284da8bb14baa4df368b8.tar.gz libguestfs-1fc41b39dac877ccec1284da8bb14baa4df368b8.tar.xz libguestfs-1fc41b39dac877ccec1284da8bb14baa4df368b8.zip |
Generated code for 'find' command.
Diffstat (limited to 'ruby/ext')
-rw-r--r-- | ruby/ext/guestfs/_guestfs.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/ruby/ext/guestfs/_guestfs.c b/ruby/ext/guestfs/_guestfs.c index d7a4aa32..2deda5d4 100644 --- a/ruby/ext/guestfs/_guestfs.c +++ b/ruby/ext/guestfs/_guestfs.c @@ -3115,6 +3115,35 @@ static VALUE ruby_guestfs_resize2fs (VALUE gv, VALUE devicev) return Qnil; } +static VALUE ruby_guestfs_find (VALUE gv, VALUE directoryv) +{ + guestfs_h *g; + Data_Get_Struct (gv, guestfs_h, g); + if (!g) + rb_raise (rb_eArgError, "%s: used handle after closing it", "find"); + + const char *directory = StringValueCStr (directoryv); + if (!directory) + rb_raise (rb_eTypeError, "expected string for parameter %s of %s", + "directory", "find"); + + char **r; + + r = guestfs_find (g, directory); + 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 () { @@ -3385,4 +3414,6 @@ void Init__guestfs () ruby_guestfs_lvresize, 2); rb_define_method (c_guestfs, "resize2fs", ruby_guestfs_resize2fs, 1); + rb_define_method (c_guestfs, "find", + ruby_guestfs_find, 1); } |