sound-juicer r2206 - in trunk: . libjuicer src
- From: rburton svn gnome org
- To: svn-commits-list gnome org
- Subject: sound-juicer r2206 - in trunk: . libjuicer src
- Date: Thu, 5 Jun 2008 10:32:51 +0000 (UTC)
Author: rburton
Date: Thu Jun 5 10:32:50 2008
New Revision: 2206
URL: http://svn.gnome.org/viewvc/sound-juicer?rev=2206&view=rev
Log:
2008-06-05 Ross Burton <ross burtonini com>
* libjuicer/sj-util.[ch]:
* src/sj-extracting.c:
Update to the latest make_directory_with_parents from bugzilla.
Modified:
trunk/ChangeLog
trunk/libjuicer/sj-util.c
trunk/libjuicer/sj-util.h
trunk/src/sj-extracting.c
Modified: trunk/libjuicer/sj-util.c
==============================================================================
--- trunk/libjuicer/sj-util.c (original)
+++ trunk/libjuicer/sj-util.c Thu Jun 5 10:32:50 2008
@@ -25,58 +25,64 @@
#endif /* HAVE_CONFIG_H */
#include "sj-util.h"
-/**
- * Stolen from gnome-vfs/programs/gnomevfs-mkdir.c (v1.3)
- */
+/* Taken from #511367, will be in GLib soon */
gboolean
-make_directory_with_parents (GFile * uri, GError **error_out)
+make_directory_with_parents (GFile *file,
+ GCancellable *cancellable,
+ GError **error)
{
- gboolean result;
- GFile *parent, *work_uri;
- GList *list = NULL;
- GError *error = NULL;
-
- result = g_file_make_directory (uri, NULL, &error);
- if (result || error->code != G_IO_ERROR_NOT_FOUND) {
- if (error_out)
- *error_out = error;
- return result;
- }
-
- work_uri = uri;
-
- while (!result && error->code == G_IO_ERROR_NOT_FOUND) {
- g_clear_error (&error);
-
- parent = g_file_get_parent (work_uri);
- result = g_file_make_directory (parent, NULL, &error);
-
- if (!result && error->code == G_IO_ERROR_NOT_FOUND)
- list = g_list_prepend (list, parent);
- work_uri = parent;
- }
-
- if (!result) {
- /* Clean up */
- while (list != NULL) {
- g_object_unref ((GFile *) list->data);
- list = g_list_remove (list, list->data);
- }
-
- if (error_out)
- *error_out = error;
- return result;
- }
-
- while (result && list != NULL) {
- result = g_file_make_directory ((GFile *) list->data, NULL, NULL);
-
- g_object_unref ((GFile *) list->data);
- list = g_list_remove (list, list->data);
- }
-
- result = g_file_make_directory (uri, NULL, error_out);
- return result;
+ 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 */
Modified: trunk/libjuicer/sj-util.h
==============================================================================
--- trunk/libjuicer/sj-util.h (original)
+++ trunk/libjuicer/sj-util.h Thu Jun 5 10:32:50 2008
@@ -27,7 +27,7 @@
#include <gio/gio.h>
#include <gtk/gtkfilechooser.h>
-gboolean make_directory_with_parents (GFile *uri, GError **error);
+gboolean make_directory_with_parents (GFile *uri, GCancellable *cancellable, GError **error);
void g_list_deep_free (GList *l, GFunc free_func);
Modified: trunk/src/sj-extracting.c
==============================================================================
--- trunk/src/sj-extracting.c (original)
+++ trunk/src/sj-extracting.c Thu Jun 5 10:32:50 2008
@@ -354,7 +354,7 @@
parent = g_file_get_parent (uri);
- res = make_directory_with_parents (parent, &io_error);
+ res = 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]