[glib] GFile: fix the *_async_thread()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GFile: fix the *_async_thread()
- Date: Fri, 19 Apr 2013 19:56:38 +0000 (UTC)
commit bd57c3f171d0775d8b1f0944f45a196b59fc79fd
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Apr 17 15:07:03 2013 +0200
GFile: fix the *_async_thread()
In the *_async_thread() functions, call the corresponding synchronous
function instead of calling the interface vfunc, which can be NULL.
In some cases the check for the vfunc == NULL was done, but to be
consistent it is better to always call the synchronous version (and the
code is simpler).
https://bugzilla.gnome.org/show_bug.cgi?id=548353
gio/gfile.c | 65 ++++++++-----------------------------------------------------
1 file changed, 8 insertions(+), 57 deletions(-)
---
diff --git a/gio/gfile.c b/gio/gfile.c
index 1ba0d3d..325c81b 100644
--- a/gio/gfile.c
+++ b/gio/gfile.c
@@ -5320,21 +5320,10 @@ open_read_async_thread (GTask *task,
gpointer task_data,
GCancellable *cancellable)
{
- GFileIface *iface;
GFileInputStream *stream;
GError *error = NULL;
- iface = G_FILE_GET_IFACE (object);
-
- if (iface->read_fn == NULL)
- {
- g_task_return_new_error (task, G_IO_ERROR,
- G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- return;
- }
-
- stream = iface->read_fn (G_FILE (object), cancellable, &error);
+ stream = g_file_read (G_FILE (object), cancellable, &error);
if (stream)
g_task_return_pointer (task, stream, g_object_unref);
else
@@ -5372,14 +5361,11 @@ append_to_async_thread (GTask *task,
gpointer task_data,
GCancellable *cancellable)
{
- GFileIface *iface;
GFileCreateFlags *data = task_data;
GFileOutputStream *stream;
GError *error = NULL;
- iface = G_FILE_GET_IFACE (source_object);
-
- stream = iface->append_to (G_FILE (source_object), *data, cancellable, &error);
+ stream = g_file_append_to (G_FILE (source_object), *data, cancellable, &error);
if (stream)
g_task_return_pointer (task, stream, g_object_unref);
else
@@ -5424,14 +5410,11 @@ create_async_thread (GTask *task,
gpointer task_data,
GCancellable *cancellable)
{
- GFileIface *iface;
GFileCreateFlags *data = task_data;
GFileOutputStream *stream;
GError *error = NULL;
- iface = G_FILE_GET_IFACE (source_object);
-
- stream = iface->create (G_FILE (source_object), *data, cancellable, &error);
+ stream = g_file_create (G_FILE (source_object), *data, cancellable, &error);
if (stream)
g_task_return_pointer (task, stream, g_object_unref);
else
@@ -5492,14 +5475,11 @@ replace_async_thread (GTask *task,
gpointer task_data,
GCancellable *cancellable)
{
- GFileIface *iface;
GFileOutputStream *stream;
ReplaceAsyncData *data = task_data;
GError *error = NULL;
- iface = G_FILE_GET_IFACE (source_object);
-
- stream = iface->replace (G_FILE (source_object),
+ stream = g_file_replace (G_FILE (source_object),
data->etag,
data->make_backup,
data->flags,
@@ -5554,15 +5534,9 @@ delete_async_thread (GTask *task,
gpointer task_data,
GCancellable *cancellable)
{
- GFile *file = object;
- GFileIface *iface;
GError *error = NULL;
- iface = G_FILE_GET_IFACE (object);
-
- if (iface->delete_file (file,
- cancellable,
- &error))
+ if (g_file_delete (G_FILE (object), cancellable, &error))
g_task_return_boolean (task, TRUE);
else
g_task_return_error (task, error);
@@ -5638,20 +5612,10 @@ open_readwrite_async_thread (GTask *task,
gpointer task_data,
GCancellable *cancellable)
{
- GFileIface *iface;
GFileIOStream *stream;
GError *error = NULL;
- iface = G_FILE_GET_IFACE (object);
-
- if (iface->open_readwrite == NULL)
- {
- g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- return;
- }
-
- stream = iface->open_readwrite (G_FILE (object), cancellable, &error);
+ stream = g_file_open_readwrite (G_FILE (object), cancellable, &error);
if (stream == NULL)
g_task_return_error (task, error);
@@ -5691,21 +5655,11 @@ create_readwrite_async_thread (GTask *task,
gpointer task_data,
GCancellable *cancellable)
{
- GFileIface *iface;
GFileCreateFlags *data = task_data;
GFileIOStream *stream;
GError *error = NULL;
- iface = G_FILE_GET_IFACE (object);
-
- if (iface->create_readwrite == NULL)
- {
- g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
- _("Operation not supported"));
- return;
- }
-
- stream = iface->create_readwrite (G_FILE (object), *data, cancellable, &error);
+ stream = g_file_create_readwrite (G_FILE (object), *data, cancellable, &error);
if (stream == NULL)
g_task_return_error (task, error);
@@ -5764,14 +5718,11 @@ replace_readwrite_async_thread (GTask *task,
gpointer task_data,
GCancellable *cancellable)
{
- GFileIface *iface;
GFileIOStream *stream;
GError *error = NULL;
ReplaceRWAsyncData *data = task_data;
- iface = G_FILE_GET_IFACE (object);
-
- stream = iface->replace_readwrite (G_FILE (object),
+ stream = g_file_replace_readwrite (G_FILE (object),
data->etag,
data->make_backup,
data->flags,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]