mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 23:58:54 +02:00
Bug 549298 – impossible to copy files with p (pipe) flag
2009-02-19 Alexander Larsson <alexl@redhat.com> Bug 549298 – impossible to copy files with p (pipe) flag * gfile.c: (file_copy_fallback): Error out if the source file is a special file svn path=/trunk/; revision=7885
This commit is contained in:
committed by
Alexander Larsson
parent
d439f9bfae
commit
0ee2b46405
@@ -1,3 +1,11 @@
|
|||||||
|
2009-02-19 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
|
Bug 549298 – impossible to copy files with p (pipe) flag
|
||||||
|
|
||||||
|
* gfile.c:
|
||||||
|
(file_copy_fallback):
|
||||||
|
Error out if the source file is a special file
|
||||||
|
|
||||||
2009-02-18 Alexander Larsson <alexl@redhat.com>
|
2009-02-18 Alexander Larsson <alexl@redhat.com>
|
||||||
|
|
||||||
Bug 560564 – Replacing a symlink with its linked file truncates the original file
|
Bug 560564 – Replacing a symlink with its linked file truncates the original file
|
||||||
|
46
gio/gfile.c
46
gio/gfile.c
@@ -2306,19 +2306,22 @@ file_copy_fallback (GFile *source,
|
|||||||
GFileInfo *info;
|
GFileInfo *info;
|
||||||
const char *target;
|
const char *target;
|
||||||
|
|
||||||
/* Maybe copy the symlink? */
|
/* need to know the file type */
|
||||||
if (flags & G_FILE_COPY_NOFOLLOW_SYMLINKS)
|
info = g_file_query_info (source,
|
||||||
{
|
G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET,
|
||||||
info = g_file_query_info (source,
|
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
||||||
G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET,
|
cancellable,
|
||||||
G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
|
error);
|
||||||
cancellable,
|
|
||||||
error);
|
|
||||||
if (info == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (g_file_info_get_file_type (info) == G_FILE_TYPE_SYMBOLIC_LINK &&
|
if (info == NULL)
|
||||||
(target = g_file_info_get_symlink_target (info)) != NULL)
|
return FALSE;
|
||||||
|
|
||||||
|
/* Maybe copy the symlink? */
|
||||||
|
if ((flags & G_FILE_COPY_NOFOLLOW_SYMLINKS) &&
|
||||||
|
g_file_info_get_file_type (info) == G_FILE_TYPE_SYMBOLIC_LINK)
|
||||||
|
{
|
||||||
|
target = g_file_info_get_symlink_target (info);
|
||||||
|
if (target)
|
||||||
{
|
{
|
||||||
if (!copy_symlink (destination, flags, cancellable, target, error))
|
if (!copy_symlink (destination, flags, cancellable, target, error))
|
||||||
{
|
{
|
||||||
@@ -2329,10 +2332,23 @@ file_copy_fallback (GFile *source,
|
|||||||
g_object_unref (info);
|
g_object_unref (info);
|
||||||
goto copied_file;
|
goto copied_file;
|
||||||
}
|
}
|
||||||
|
/* ... else fall back on a regular file copy */
|
||||||
g_object_unref (info);
|
g_object_unref (info);
|
||||||
}
|
}
|
||||||
|
/* Handle "special" files (pipes, device nodes, ...)? */
|
||||||
|
else if (g_file_info_get_file_type (info) == G_FILE_TYPE_SPECIAL)
|
||||||
|
{
|
||||||
|
/* FIXME: could try to recreate device nodes and others? */
|
||||||
|
|
||||||
|
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||||
|
_("Can't copy special file"));
|
||||||
|
g_object_unref (info);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
/* Everything else should just fall back on a regular copy. */
|
||||||
|
else
|
||||||
|
g_object_unref (info);
|
||||||
|
|
||||||
in = open_source_for_copy (source, destination, flags, cancellable, error);
|
in = open_source_for_copy (source, destination, flags, cancellable, error);
|
||||||
if (in == NULL)
|
if (in == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Reference in New Issue
Block a user