#include #include #include #include"myresources.h" #define EXPECTED "This is a resource.\n" int main(int argc, char **argv) { GResource *res = myres_get_resource(); GError *err = NULL; GBytes *data = g_resources_lookup_data("/com/example/myprog/res1.txt", G_RESOURCE_LOOKUP_FLAGS_NONE, &err); if(data == NULL) { fprintf(stderr, "Data lookup failed: %s\n", err->message); return 1; } if(strcmp(g_bytes_get_data(data, NULL), EXPECTED) != 0) { fprintf(stderr, "Resource contents are wrong:\n %s\n", (const char*)g_bytes_get_data(data, NULL)); return 1; } fprintf(stderr, "All ok.\n"); g_bytes_unref(data); g_resource_unref(res); return 0; }