+2008-09-22 Nelson Benítez León <nbenitez@svn.gnome.org>
+
+ * gio/gioenums.h: Add new GFileCopyFlag, to leave target file with
+ default perms, instead of setting the source file perms, in a copy
+ operation.
+
+ * gio/gfile.c (g_file_copy_attributes)
+ (build_attribute_list_for_copy)
+ (should_copy): Not copy "unix::mode" attribute if we have received
+ G_FILE_COPY_TARGET_DEFAULT_PERMS flag.
+
2008-09-19 Hans Petter Jansson <hpj@novell.com>
Rewrite most of GHashTable to use open addressing with quadratic
static gboolean
should_copy (GFileAttributeInfo *info,
- gboolean as_move)
+ gboolean as_move,
+ gboolean skip_perms)
{
+ if (skip_perms && strcmp(info->name, "unix::mode") == 0)
+ return FALSE;
+
if (as_move)
return info->flags & G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED;
return info->flags & G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE;
static char *
build_attribute_list_for_copy (GFileAttributeInfoList *attributes,
GFileAttributeInfoList *namespaces,
- gboolean as_move)
+ gboolean as_move,
+ gboolean skip_perms)
{
GString *s;
gboolean first;
{
for (i = 0; i < attributes->n_infos; i++)
{
- if (should_copy (&attributes->infos[i], as_move))
+ if (should_copy (&attributes->infos[i], as_move, skip_perms))
{
if (first)
first = FALSE;
{
for (i = 0; i < namespaces->n_infos; i++)
{
- if (should_copy (&namespaces->infos[i], as_move))
+ if (should_copy (&namespaces->infos[i], as_move, FALSE))
{
if (first)
first = FALSE;
GFileInfo *info;
gboolean as_move;
gboolean source_nofollow_symlinks;
+ gboolean skip_perms;
as_move = flags & G_FILE_COPY_ALL_METADATA;
source_nofollow_symlinks = flags & G_FILE_COPY_NOFOLLOW_SYMLINKS;
+ skip_perms = flags & G_FILE_COPY_TARGET_DEFAULT_PERMS != 0;
/* Ignore errors here, if the target supports no attributes there is nothing to copy */
attributes = g_file_query_settable_attributes (destination, cancellable, NULL);
if (attributes == NULL && namespaces == NULL)
return TRUE;
- attrs_to_read = build_attribute_list_for_copy (attributes, namespaces, as_move);
+ attrs_to_read = build_attribute_list_for_copy (attributes, namespaces, as_move, skip_perms);
/* Ignore errors here, if we can't read some info (e.g. if it doesn't exist)
* we just don't copy it.
* @G_FILE_COPY_NOFOLLOW_SYMLINKS: Don't follow symlinks.
* @G_FILE_COPY_ALL_METADATA: Copy all file metadata instead of just default set used for copy (see #GFileInfo).
* @G_FILE_COPY_NO_FALLBACK_FOR_MOVE: Don't use copy and delete fallback if native move not supported.
+ * @G_FILE_COPY_TARGET_DEFAULT_PERMS: Leaves target file with default perms, instead of setting the source file perms.
*
* Flags used when copying or moving files.
*/
G_FILE_COPY_BACKUP = (1 << 1),
G_FILE_COPY_NOFOLLOW_SYMLINKS = (1 << 2),
G_FILE_COPY_ALL_METADATA = (1 << 3),
- G_FILE_COPY_NO_FALLBACK_FOR_MOVE = (1 << 4)
+ G_FILE_COPY_NO_FALLBACK_FOR_MOVE = (1 << 4),
+ G_FILE_COPY_TARGET_DEFAULT_PERMS = (1 << 5)
} GFileCopyFlags;