Sorry, I did not put the whole file in the post.  Those are in the
init module.

static VALUE rbgio_init(VALUE self, VALUE path)
{
  VALUE arr, names;

  rb_iv_set(self, "@path", path);
  arr = rb_ary_new();
  names = rb_ary_new();
  rb_iv_set(self, "@attribute_array", arr);
  rb_iv_set(self, "@name_array", names);
  return self;
}

Thanks for looking.  I'm starting to suspect I have to do something to
initialize the library.  I have a call to gdk_init(argc, argv) in the
module initialization, but maybe there is something more?  Maybe I
can't use the library without creating a window?  Not sure.

Mike
On Mar 12, 8:06 am, Jason Roelofs <[email protected]> wrote:
> I see gets but no sets on those ivars you're trying to manipulate. I
> wouldn't assume that you're editing the values in-place instead of a
> copy of what the ivars contained unless you've proven that's what
> you've got (I think that sentence makes sense ...).
>
> Given that you're saying the code doesn't work, try adding the
> following 3 lines to the end of the method:
>
> rb_iv_set(self, "@attributes_array", arr);
> rb_iv_set(self, "@name_array", names);
> rb_iv_set(self, "@path", path);
>
> Jason
>
> On Thu, Mar 12, 2009 at 10:58 AM, mvargo <[email protected]> wrote:
>
> > I'm trying to use some functions from the Gnome GIO library to get
> > extended file attributes.  I'm doing this by writing a C extension
> > using the wonderful directions 
> > inhttp://www.rubycentral.com/pickaxe/ext_ruby.html.
> > All that being said, I don't really know Gnome or GTK+ at all, but I
> > thought my little code would be OK.
>
> > So I have the library built (rubygio.so) and the code all executes
> > fine.  Problem is the gio api calls don't return any info when I think
> > they should.  I'm guessing there is some initialization stuff I'm
> > missing or maybe I have to have a window going or something.  Any help
> > would be appreciated.
>
> > The C code to get the attributes looks like this:
>
> > static VALUE rbgio_load_attributes(VALUE self)
> > {
> >  VALUE arr = rb_iv_get(self, "@attribute_array");
> >  VALUE names = rb_iv_get(self, "@name_array");
> >  VALUE path = rb_iv_get(self, "@path");
>
> >  GFile *ptr = g_file_new_for_path(STR2CSTR(path));
> >  GError *gerror = NULL;
> >  GFileInfo *finfo = g_file_query_info(ptr, "*", 0, NULL, &gerror);
> >  if (finfo == NULL) {
> >    return INT2NUM(0);
> >  }
> >  char **attributes = g_file_info_list_attributes(finfo, "*");
> >  int i = 0;
> >  while (attributes[i] != NULL) {
> >    rb_ary_push(names, rb_str_new2(attributes[i]));
> >    rb_ary_push(arr, rb_str_new2(g_file_info_get_attribute_as_string
> > (finfo, attributes[i])));
> >    i++;
> >  }
> >  return INT2NUM(1)
> > }
>
> > Again it all runs (i've run it in gdb and examined variables).  The
> > GFile *ptr is a real address, the GFileInfo *finfo is a real thing and
> > the char** attributes is a valid list with no entries.
>
> > Any clues would be greatly appreciated.  I will put the extension out
> > there once completed.
>
> > Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to