mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
g_file_make_directory_with_parents: clean up logic
Simplify logic by only looking at whether we have a GError and not also using return codes. https://bugzilla.gnome.org/show_bug.cgi?id=680823
This commit is contained in:
parent
5291190f46
commit
f899358156
22
gio/gfile.c
22
gio/gfile.c
@ -3360,7 +3360,6 @@ g_file_make_directory_with_parents (GFile *file,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
gboolean result;
|
||||
GFile *work_file = NULL;
|
||||
GList *list = NULL, *l;
|
||||
GError *my_error = NULL;
|
||||
@ -3370,17 +3369,17 @@ g_file_make_directory_with_parents (GFile *file,
|
||||
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)
|
||||
g_file_make_directory (file, cancellable, &my_error);
|
||||
if (my_error == NULL || my_error->code != G_IO_ERROR_NOT_FOUND)
|
||||
{
|
||||
if (my_error)
|
||||
g_propagate_error (error, my_error);
|
||||
return result;
|
||||
return my_error == NULL;
|
||||
}
|
||||
|
||||
work_file = g_object_ref (file);
|
||||
|
||||
while (!result && my_error->code == G_IO_ERROR_NOT_FOUND)
|
||||
while (my_error != NULL && my_error->code == G_IO_ERROR_NOT_FOUND)
|
||||
{
|
||||
GFile *parent_file;
|
||||
|
||||
@ -3389,21 +3388,20 @@ g_file_make_directory_with_parents (GFile *file,
|
||||
break;
|
||||
|
||||
g_clear_error (&my_error);
|
||||
|
||||
result = g_file_make_directory (parent_file, cancellable, &my_error);
|
||||
g_file_make_directory (parent_file, cancellable, &my_error);
|
||||
|
||||
g_object_unref (work_file);
|
||||
work_file = g_object_ref (parent_file);
|
||||
|
||||
if (!result && my_error->code == G_IO_ERROR_NOT_FOUND)
|
||||
if (my_error != NULL && my_error->code == G_IO_ERROR_NOT_FOUND)
|
||||
list = g_list_prepend (list, parent_file); /* Transfer ownership of ref */
|
||||
else
|
||||
g_object_unref (parent_file);
|
||||
}
|
||||
|
||||
for (l = list; result && l; l = l->next)
|
||||
for (l = list; my_error == NULL && l; l = l->next)
|
||||
{
|
||||
result = g_file_make_directory ((GFile *) l->data, cancellable, &my_error);
|
||||
g_file_make_directory ((GFile *) l->data, cancellable, &my_error);
|
||||
}
|
||||
|
||||
if (work_file)
|
||||
@ -3416,10 +3414,10 @@ g_file_make_directory_with_parents (GFile *file,
|
||||
list = g_list_remove (list, list->data);
|
||||
}
|
||||
|
||||
if (!result)
|
||||
if (my_error != NULL)
|
||||
{
|
||||
g_propagate_error (error, my_error);
|
||||
return result;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return g_file_make_directory (file, cancellable, error);
|
||||
|
Loading…
Reference in New Issue
Block a user