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 <mfva...@gmail.com> 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 in 
> http://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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to