Hi thanks for your answer. I totally confused Resource/Resource_s_ what was the reason i didnt found the correct API to use.
Works now like a charm! The only bummer, there is no simple Method to read a resource in as string - have to use a InputStream because FileUtils doesn't work with resources-uri's. Thanks anyway Günther Am Sonntag, den 05.02.2017, 12:28 +0000 schrieb Al Thomas: > > ----- Original Message ----- > > From: Günther Wutz <i...@gunibert.de> > > Sent: Sunday, 5 February 2017, 11:23 > > Subject: [Vala] Resource API inconsistent > > if i want to lookup resource data via the glib API, i would > > normally > > use g_resources_open_stream. This function call doesn't need a > > object. > > > The documentation at https://developer.gnome.org/gio/stable/GResource > .html#g-resource-open-stream gives the function signature as: > > > GInputStream * > g_resource_open_stream (GResource *resource, > const char *path, > GResourceLookupFlags lookup_flags, > GError **error); > > So that looks like it needs a GResource object to me. > > > > If its registered beforehand i can use it globally in my > > application. > > > If you use glib-compile-resources to produce a C file and then > compile > the C file into your Vala program the resources are registered > globally > as static resources. If you are doing that then you could use: > https://valadoc.org/gio-2.0/GLib.resources_open_stream.html > > I'm not finding that static function documented anywhere in the GNOME > documentation. > The closest I could find is: > https://developer.gnome.org/gio/stable/GResource.html#GStaticResource > This says "GStaticResource is an opaque data structure and can only > be > > accessed using the following functions", but doesn't list these > functions. > This could be an omission. Maybe because the resource uri scheme is > used by most people. > For example using a uri of > "resource:////templates/boot/fstab.mustache" > > to open the InputStream. > > > I've use the static method resources_lookup_data() in Vala/Genie, > but > > not tried the resource URI method. > > > > In contrast vala needs a Resource object to use this> function, > > which seems wrong. Am i missing something here? > > > The method in Vala matches the g_resource_open_stream > C API. This needs a GResource object as shown above. > > Al _______________________________________________ vala-list mailing list vala-list@gnome.org https://mail.gnome.org/mailman/listinfo/vala-list