changeset 62522:95e7ae46e475

(dired-copy-file-recursive): Handle symlinks in recursive copy.
author Richard M. Stallman <rms@gnu.org>
date Thu, 19 May 2005 15:42:01 +0000
parents 91bf7b558b82
children a463c8c59947
files lisp/dired-aux.el
diffstat 1 files changed, 23 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/dired-aux.el	Thu May 19 15:40:37 2005 +0000
+++ b/lisp/dired-aux.el	Thu May 19 15:42:01 2005 +0000
@@ -1135,23 +1135,29 @@
 
 (defun dired-copy-file-recursive (from to ok-flag &optional
 				       preserve-time top recursive)
-  (if (and recursive
-	   (eq t (car (file-attributes from))) ; A directory, no symbolic link.
-	   (or (eq recursive 'always)
-	       (yes-or-no-p (format "Recursive copies of %s " from))))
-      (let ((files (directory-files from nil dired-re-no-dot)))
-	(if (eq recursive 'top) (setq recursive 'always)) ; Don't ask any more.
-	(if (file-exists-p to)
-	    (or top (dired-handle-overwrite to))
-	  (make-directory to))
-	(while files
-	  (dired-copy-file-recursive
-	   (expand-file-name (car files) from)
-	   (expand-file-name (car files) to)
-	   ok-flag preserve-time nil recursive)
-	  (setq files (cdr files))))
-    (or top (dired-handle-overwrite to)) ; Just a file.
-    (copy-file from to ok-flag dired-copy-preserve-time)))
+  (let ((attrs (file-attributes from)))
+    (if (and recursive
+	     (eq t (car attrs))
+	     (or (eq recursive 'always)
+		 (yes-or-no-p (format "Recursive copies of %s " from))))
+	;; This is a directory.
+	(let ((files (directory-files from nil dired-re-no-dot)))
+	  (if (eq recursive 'top) (setq recursive 'always)) ; Don't ask any more.
+	  (if (file-exists-p to)
+	      (or top (dired-handle-overwrite to))
+	    (make-directory to))
+	  (while files
+	    (dired-copy-file-recursive
+	     (expand-file-name (car files) from)
+	     (expand-file-name (car files) to)
+	     ok-flag preserve-time nil recursive)
+	    (setq files (cdr files))))
+      ;; Not a directory.
+      (or top (dired-handle-overwrite to))
+      (if (stringp (car attrs))
+	  ;; It is a symlink
+	  (make-symbolic-link (car attrs) to ok-flag)
+	(copy-file from to ok-flag dired-copy-preserve-time)))))
 
 ;;;###autoload
 (defun dired-rename-file (file newname ok-if-already-exists)