changeset 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 a81fb44bbdeb
children 8e1f4b31c39f
files ChangeLog lib/copy-file.c modules/copy-file
diffstat 3 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jan 11 01:54:25 2012 +0100
+++ b/ChangeLog	Wed Jan 11 02:01:45 2012 +0100
@@ -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.
--- a/lib/copy-file.c	Wed Jan 11 01:54:25 2012 +0100
+++ b/lib/copy-file.c	Wed Jan 11 02:01:45 2012 +0100
@@ -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
--- a/modules/copy-file	Wed Jan 11 01:54:25 2012 +0100
+++ b/modules/copy-file	Wed Jan 11 02:01:45 2012 +0100
@@ -14,6 +14,7 @@
 full-write
 gettext-h
 open
+quote
 safe-read
 stdlib
 unistd