copy-file: Refactor.
authorBruno Haible <bruno@clisp.org>
Wed, 11 Jan 2012 01:01:45 +0000 (02:01 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 12 Jan 2012 00:36:45 +0000 (01:36 +0100)
* 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.

ChangeLog
lib/copy-file.c
modules/copy-file

index 6e97da1..264528e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2012-01-10  Bruno Haible  <bruno@clisp.org>
 
+       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.
+
        acl: Export qcopy_acl.
        * lib/acl.h (qcopy_acl): New declaration.
        * lib/copy-acl.c (qcopy_acl): Make non-static.
index 8e79091..5bd6fa8 100644 (file)
@@ -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 @@ copy_file_preserving (const char *src_filename, const char *dest_filename)
 
   /* 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
index 6a35db2..1c50d55 100644 (file)
@@ -14,6 +14,7 @@ fstat
 full-write
 gettext-h
 open
+quote
 safe-read
 stdlib
 unistd