[glib/resource-overlay-info: 1/2] gresource: Complete the overlay support



commit cebb3259982b41f5a25d38c094135a0fbcb6bf0d
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Nov 27 00:13:22 2018 -0500

    gresource: Complete the overlay support
    
    Unlike the other g_resources_ functions, g_resources_get_info
    was not respecting G_RESOURCE_OVERLAYS. Add this missing
    support.
    
    Closes: #1445

 gio/gresource.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
---
diff --git a/gio/gresource.c b/gio/gresource.c
index 2844f4808..e71db43ed 100644
--- a/gio/gresource.c
+++ b/gio/gresource.c
@@ -285,6 +285,27 @@ enumerate_overlay_dir (const gchar *candidate,
   return FALSE;
 }
 
+typedef struct {
+  gsize size;
+  guint32 flags;
+} InfoData;
+
+static gboolean
+get_overlay_info (const gchar *candidate,
+                  gpointer     user_data)
+{
+  InfoData *info = user_data;
+  GStatBuf buf;
+
+  if (g_stat (candidate, &buf) < 0)
+    return FALSE;
+
+  info->size = buf.st_size;
+  info->flags = G_RESOURCE_FLAGS_NONE;
+
+  return TRUE;
+}
+
 static gboolean
 g_resource_find_overlay (const gchar    *path,
                          CheckCandidate  check,
@@ -1251,6 +1272,17 @@ g_resources_get_info (const gchar           *path,
   gboolean res = FALSE;
   GList *l;
   gboolean r_res;
+  InfoData info;
+
+  if (g_resource_find_overlay (path, get_overlay_info, &info))
+    {
+      if (size)
+        *size = info.size;
+      if (flags)
+        *flags = info.flags;
+
+      return TRUE;
+    }
 
   register_lazy_static_resources ();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]