[libgsystem] shutil: Make gs_shutil_cp_a copy ownership as well



commit f861ba48955b6c3a3a05cdadae510695db3b5a99
Author: Sjoerd Simons <sjoerd simons collabora co uk>
Date:   Tue Oct 29 09:26:45 2013 +0100

    shutil: Make gs_shutil_cp_a copy ownership as well
    
    Like cp -a gs_shutil_cp_a should really copy all directory metadata.
    This adds support for at least copying the ownership metadata
    (user/group).
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711057

 gsystem-shutil.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/gsystem-shutil.c b/gsystem-shutil.c
index a8dbc18..8416033 100644
--- a/gsystem-shutil.c
+++ b/gsystem-shutil.c
@@ -81,6 +81,16 @@ cp_internal_one_item (GFile         *src,
           goto out;
         }
 
+      if (chown (gs_file_get_path_cached (dest_child),
+                 g_file_info_get_attribute_uint32 (file_info, "unix::uid"),
+                 g_file_info_get_attribute_uint32 (file_info, "unix::gid")) == -1)
+        {
+          int errsv = errno;
+          g_set_error_literal (error, G_IO_ERROR, g_io_error_from_errno (errsv),
+                               g_strerror (errsv));
+          goto out;
+        }
+
       if (!cp_internal (src_child, dest_child, use_hardlinks, cancellable, error))
         goto out;
     }
@@ -132,7 +142,7 @@ cp_internal (GFile         *src,
   GFileInfo *file_info = NULL;
   GError *temp_error = NULL;
 
-  enumerator = g_file_enumerate_children (src, "standard::type,standard::name,unix::mode",
+  enumerator = g_file_enumerate_children (src, 
"standard::type,standard::name,unix::uid,unix::gid,unix::mode",
                                           G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
                                           cancellable, error);
   if (!enumerator)


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