glib r7526 - in trunk: . gio



Author: nbenitez
Date: Sun Sep 21 23:53:40 2008
New Revision: 7526
URL: http://svn.gnome.org/viewvc/glib?rev=7526&view=rev

Log:
Add new GFileCopyFlag

Modified:
   trunk/ChangeLog
   trunk/gio/gfile.c
   trunk/gio/gioenums.h

Modified: trunk/gio/gfile.c
==============================================================================
--- trunk/gio/gfile.c	(original)
+++ trunk/gio/gfile.c	Sun Sep 21 23:53:40 2008
@@ -2056,8 +2056,12 @@
 
 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;
@@ -2066,7 +2070,8 @@
 static char *
 build_attribute_list_for_copy (GFileAttributeInfoList *attributes,
 			       GFileAttributeInfoList *namespaces,
-			       gboolean                as_move)
+			       gboolean                as_move,
+			       gboolean                skip_perms)
 {
   GString *s;
   gboolean first;
@@ -2079,7 +2084,7 @@
     {
       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;
@@ -2095,7 +2100,7 @@
     {
       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;
@@ -2142,9 +2147,11 @@
   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);
@@ -2153,7 +2160,7 @@
   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. 

Modified: trunk/gio/gioenums.h
==============================================================================
--- trunk/gio/gioenums.h	(original)
+++ trunk/gio/gioenums.h	Sun Sep 21 23:53:40 2008
@@ -198,6 +198,7 @@
  * @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.
  */
@@ -207,7 +208,8 @@
   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;
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]