[sound-juicer] Use g_file_make_directory_with_parents()



commit a3195a5e0e08d37a869ccd53ea2481bf15b68bf7
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Mon Aug 18 18:53:01 2014 +0200

    Use g_file_make_directory_with_parents()
    
    Now that this function is in glib, better to use it rather than bundle
    an older copy of this code.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=735006

 libjuicer/sj-util.c |   60 ---------------------------------------------------
 libjuicer/sj-util.h |    2 -
 src/sj-extracting.c |    2 +-
 3 files changed, 1 insertions(+), 63 deletions(-)
---
diff --git a/libjuicer/sj-util.c b/libjuicer/sj-util.c
index 4d98eaa..61a56c2 100644
--- a/libjuicer/sj-util.c
+++ b/libjuicer/sj-util.c
@@ -24,66 +24,6 @@
 #endif /* HAVE_CONFIG_H */
 #include "sj-util.h"
 
-/* Taken from #511367, will be in GLib soon */
-gboolean
-make_directory_with_parents (GFile         *file,
-                                   GCancellable  *cancellable,
-                                   GError       **error)
-{
-  gboolean result;
-  GFile *parent_file, *work_file;
-  GList *list = NULL, *l;
-  GError *my_error = NULL;
-
-  if (g_cancellable_set_error_if_cancelled (cancellable, error))
-    return FALSE;
-
-  result = g_file_make_directory (file, cancellable, &my_error);
-  if (result || my_error->code != G_IO_ERROR_NOT_FOUND)
-    {
-      if (my_error)
-        g_propagate_error (error, my_error);
-      return result;
-    }
-
-  work_file = file;
-
-  while (!result && my_error->code == G_IO_ERROR_NOT_FOUND)
-    {
-      g_clear_error (&my_error);
-
-      parent_file = g_file_get_parent (work_file);
-      if (parent_file == NULL)
-        break;
-      result = g_file_make_directory (parent_file, cancellable, &my_error);
-
-      if (!result && my_error->code == G_IO_ERROR_NOT_FOUND)
-        list = g_list_prepend (list, parent_file);
-
-      work_file = parent_file;
-    }
-
-  for (l = list; result && l; l = l->next)
-    {
-      result = g_file_make_directory ((GFile *) l->data, cancellable, &my_error);
-    }
-
-  /* Clean up */
-  while (list != NULL)
-    {
-      g_object_unref ((GFile *) list->data);
-      list = g_list_remove (list, list->data);
-    }
-
-  if (!result)
-    {
-      g_propagate_error (error, my_error);
-      return result;
-    }
-
-  return g_file_make_directory (file, cancellable, error);
-}
-
 /* Pass NULL to use g_free */
 void
 g_list_deep_free (GList *l, GFunc free_func)
diff --git a/libjuicer/sj-util.h b/libjuicer/sj-util.h
index 39af29d..f9ea18a 100644
--- a/libjuicer/sj-util.h
+++ b/libjuicer/sj-util.h
@@ -26,8 +26,6 @@
 #include <gio/gio.h>
 #include <gtk/gtk.h>
 
-gboolean make_directory_with_parents (GFile *uri, GCancellable  *cancellable, GError **error);
-
 void g_list_deep_free (GList *l, GFunc free_func);
 
 void sj_add_default_dirs (GtkFileChooser *dialog);
diff --git a/src/sj-extracting.c b/src/sj-extracting.c
index f68c6b6..ea04e19 100644
--- a/src/sj-extracting.c
+++ b/src/sj-extracting.c
@@ -370,7 +370,7 @@ create_directory_for (GFile *uri, GError **error)
 
   parent = g_file_get_parent (uri);
 
-  res = make_directory_with_parents (parent, NULL, &io_error);
+  res = g_file_make_directory_with_parents (parent, NULL, &io_error);
   if (!res) {
     if (io_error->code != G_IO_ERROR_EXISTS) {
       g_set_error (error, SJ_ERROR, SJ_ERROR_CD_PERMISSION_ERROR,


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