[gnome-builder/wip/mwleeds/ide-config-provider: 15/17] Make the flatpak manifest search recursive



commit 0ce2efa43aa18f1e012519896de20da5a744d57a
Author: Matthew Leeds <mleeds redhat com>
Date:   Fri Dec 23 19:18:56 2016 -0600

    Make the flatpak manifest search recursive

 .../flatpak/gbp-flatpak-configuration-provider.c   |   55 ++++++++++++++------
 1 files changed, 39 insertions(+), 16 deletions(-)
---
diff --git a/plugins/flatpak/gbp-flatpak-configuration-provider.c 
b/plugins/flatpak/gbp-flatpak-configuration-provider.c
index 7d3bd09..5b726bf 100644
--- a/plugins/flatpak/gbp-flatpak-configuration-provider.c
+++ b/plugins/flatpak/gbp-flatpak-configuration-provider.c
@@ -136,22 +136,14 @@ guess_primary_module (JsonNode *modules_node,
   return NULL;
 }
 
-static GPtrArray *
-gbp_flatpak_configuration_provider_find_flatpak_manifests (GbpFlatpakConfigurationProvider *self,
-                                                           GCancellable                    *cancellable,
-                                                           GFile                           *directory,
-                                                           GError                         **error)
+static gboolean
+check_dir_for_manifests (GFile         *directory,
+                         GPtrArray     *manifests,
+                         GCancellable  *cancellable,
+                         GError       **error)
 {
   g_autoptr(GFileEnumerator) enumerator = NULL;
   GFileInfo *file_info = NULL;
-  GPtrArray *ar;
-
-  g_assert (GBP_IS_FLATPAK_CONFIGURATION_PROVIDER (self));
-  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
-  g_assert (G_IS_FILE (directory));
-
-  ar = g_ptr_array_new ();
-  g_ptr_array_set_free_func (ar, flatpak_manifest_free);
 
   enumerator = g_file_enumerate_children (directory,
                                           G_FILE_ATTRIBUTE_STANDARD_NAME,
@@ -159,7 +151,7 @@ gbp_flatpak_configuration_provider_find_flatpak_manifests (GbpFlatpakConfigurati
                                           cancellable,
                                           error);
   if (!enumerator)
-    return NULL;
+    return FALSE;
 
   while ((file_info = g_file_enumerator_next_file (enumerator, cancellable, NULL)))
     {
@@ -189,11 +181,18 @@ gbp_flatpak_configuration_provider_find_flatpak_manifests (GbpFlatpakConfigurati
       name = g_strdup (g_file_info_get_name (file_info));
       g_clear_object (&file_info);
 
-      if (name == NULL || file_type == G_FILE_TYPE_DIRECTORY)
+      if (name == NULL)
         continue;
 
       file = g_file_get_child (directory, name);
 
+      if (file_type == G_FILE_TYPE_DIRECTORY)
+        {
+          if (!check_dir_for_manifests (file, manifests, cancellable, error))
+            return FALSE;
+          continue;
+        }
+
       /* This regex is based on https://wiki.gnome.org/HowDoI/ChooseApplicationID */
       filename_regex = g_regex_new ("^[[:alnum:]-_]+\\.[[:alnum:]-_]+(\\.[[:alnum:]-_]+)*\\.json$",
                                     0, 0, NULL);
@@ -273,7 +272,31 @@ gbp_flatpak_configuration_provider_find_flatpak_manifests (GbpFlatpakConfigurati
             }
         }
 
-      g_ptr_array_add (ar, manifest);
+      g_ptr_array_add (manifests, manifest);
+    }
+
+  return TRUE;
+}
+
+static GPtrArray *
+gbp_flatpak_configuration_provider_find_flatpak_manifests (GbpFlatpakConfigurationProvider *self,
+                                                           GCancellable                    *cancellable,
+                                                           GFile                           *directory,
+                                                           GError                         **error)
+{
+  GPtrArray *ar;
+
+  g_assert (GBP_IS_FLATPAK_CONFIGURATION_PROVIDER (self));
+  g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
+  g_assert (G_IS_FILE (directory));
+
+  ar = g_ptr_array_new ();
+  g_ptr_array_set_free_func (ar, flatpak_manifest_free);
+
+  if (!check_dir_for_manifests (directory, ar, cancellable, error))
+    {
+      g_ptr_array_free (ar, TRUE);
+      return NULL;
     }
 
   return ar;


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