mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-04 16:33:40 +02:00
Allow calls to implementation of copy and write even if the type of the
2008-01-17 Alexander Larsson <alexl@redhat.com> * gfile.c: (g_file_copy): (g_file_move): Allow calls to implementation of copy and write even if the type of the file implementations is different. This can be used to implement native upload and download calls in a vfs. * glocalfile.c: (g_local_file_move): Protect against the case where move is called with one file not being local. Make sure we call the progress callback once in the native move operation so that the caller knows how many bytes were copied. svn path=/trunk/; revision=6324
This commit is contained in:
committed by
Alexander Larsson
parent
f1332511ee
commit
0026537f37
64
gio/gfile.c
64
gio/gfile.c
@@ -2115,14 +2115,38 @@ g_file_copy (GFile *source,
|
||||
if (g_cancellable_set_error_if_cancelled (cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (G_OBJECT_TYPE (source) == G_OBJECT_TYPE (destination))
|
||||
iface = G_FILE_GET_IFACE (destination);
|
||||
if (iface->copy)
|
||||
{
|
||||
my_error = NULL;
|
||||
res = (* iface->copy) (source, destination,
|
||||
flags, cancellable,
|
||||
progress_callback, progress_callback_data,
|
||||
&my_error);
|
||||
|
||||
if (res)
|
||||
return TRUE;
|
||||
|
||||
if (my_error->domain != G_IO_ERROR || my_error->code != G_IO_ERROR_NOT_SUPPORTED)
|
||||
{
|
||||
g_propagate_error (error, my_error);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* If the types are different, and the destination method failed
|
||||
also try the source method */
|
||||
if (G_OBJECT_TYPE (source) != G_OBJECT_TYPE (destination))
|
||||
{
|
||||
iface = G_FILE_GET_IFACE (source);
|
||||
|
||||
|
||||
if (iface->copy)
|
||||
{
|
||||
my_error = NULL;
|
||||
res = (* iface->copy) (source, destination, flags, cancellable, progress_callback, progress_callback_data, &my_error);
|
||||
res = (* iface->copy) (source, destination,
|
||||
flags, cancellable,
|
||||
progress_callback, progress_callback_data,
|
||||
&my_error);
|
||||
|
||||
if (res)
|
||||
return TRUE;
|
||||
@@ -2134,7 +2158,7 @@ g_file_copy (GFile *source,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return file_copy_fallback (source, destination, flags, cancellable,
|
||||
progress_callback, progress_callback_data,
|
||||
error);
|
||||
@@ -2209,14 +2233,38 @@ g_file_move (GFile *source,
|
||||
if (g_cancellable_set_error_if_cancelled (cancellable, error))
|
||||
return FALSE;
|
||||
|
||||
if (G_OBJECT_TYPE (source) == G_OBJECT_TYPE (destination))
|
||||
iface = G_FILE_GET_IFACE (destination);
|
||||
if (iface->move)
|
||||
{
|
||||
my_error = NULL;
|
||||
res = (* iface->move) (source, destination,
|
||||
flags, cancellable,
|
||||
progress_callback, progress_callback_data,
|
||||
&my_error);
|
||||
|
||||
if (res)
|
||||
return TRUE;
|
||||
|
||||
if (my_error->domain != G_IO_ERROR || my_error->code != G_IO_ERROR_NOT_SUPPORTED)
|
||||
{
|
||||
g_propagate_error (error, my_error);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* If the types are different, and the destination method failed
|
||||
also try the source method */
|
||||
if (G_OBJECT_TYPE (source) != G_OBJECT_TYPE (destination))
|
||||
{
|
||||
iface = G_FILE_GET_IFACE (source);
|
||||
|
||||
|
||||
if (iface->move)
|
||||
{
|
||||
my_error = NULL;
|
||||
res = (* iface->move) (source, destination, flags, cancellable, progress_callback, progress_callback_data, &my_error);
|
||||
res = (* iface->move) (source, destination,
|
||||
flags, cancellable,
|
||||
progress_callback, progress_callback_data,
|
||||
&my_error);
|
||||
|
||||
if (res)
|
||||
return TRUE;
|
||||
@@ -2228,7 +2276,7 @@ g_file_move (GFile *source,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (flags & G_FILE_COPY_NO_FALLBACK_FOR_MOVE)
|
||||
{
|
||||
g_set_error (error, G_IO_ERROR,
|
||||
|
Reference in New Issue
Block a user