diff lib/copy-file.c @ 16271:a9b070c205b2

copy-file: Refactor. * lib/copy-file.c: Include quote.h. (copy_file_preserving): Call qcopy_acl instead of copy_acl. Emit error message here. * modules/copy-file (Depends-on): Add quote.
author Bruno Haible <bruno@clisp.org>
date Wed, 11 Jan 2012 02:01:45 +0100
parents 8250f2777afc
children 8e1f4b31c39f
line wrap: on
line diff
--- a/lib/copy-file.c
+++ b/lib/copy-file.c
@@ -41,6 +41,7 @@
 #include "full-write.h"
 #include "acl.h"
 #include "binary-io.h"
+#include "quote.h"
 #include "gettext.h"
 #include "xalloc.h"
 
@@ -122,8 +123,14 @@
 
   /* Preserve the access permissions.  */
 #if USE_ACL
-  if (copy_acl (src_filename, src_fd, dest_filename, dest_fd, mode))
-    exit (EXIT_FAILURE);
+  switch (qcopy_acl (src_filename, src_fd, dest_filename, dest_fd, mode))
+    {
+    case -2:
+      error (EXIT_FAILURE, errno, "%s", quote (src_filename));
+    case -1:
+      error (EXIT_FAILURE, errno, _("preserving permissions for %s"),
+             quote (dest_filename));
+    }
 #else
   chmod (dest_filename, mode);
 #endif