* files.el (copy-directory): Handle symlinks (Bug#5982).
authorChong Yidong <cyd@stupidchicken.com>
Tue, 20 Apr 2010 22:28:26 +0000 (18:28 -0400)
committerChong Yidong <cyd@stupidchicken.com>
Tue, 20 Apr 2010 22:28:26 +0000 (18:28 -0400)
lisp/ChangeLog
lisp/files.el

index 6cf40c7..8a8f7ef 100644 (file)
@@ -1,5 +1,7 @@
 2010-04-20  Chong Yidong  <cyd@stupidchicken.com>
 
+       * files.el (copy-directory): Handle symlinks (Bug#5982).
+
        * progmodes/compile.el (compilation-next-error-function): Revert
        2009-10-12 change (Bug#5983).
 
index 99fa7dd..7634503 100644 (file)
@@ -4735,10 +4735,14 @@ this happens by default."
       (mapc
        (lambda (file)
         (let ((target (expand-file-name
-                       (file-name-nondirectory file) newname)))
-          (if (file-directory-p file)
-              (copy-directory file target keep-time parents)
-            (copy-file file target t keep-time))))
+                       (file-name-nondirectory file) newname))
+              (attrs (file-attributes file)))
+          (cond ((file-directory-p file)
+                 (copy-directory file target keep-time parents))
+                ((stringp (car attrs)) ; Symbolic link
+                 (make-symbolic-link (car attrs) target t))
+                (t
+                 (copy-file file target t keep-time)))))
        ;; We do not want to copy "." and "..".
        (directory-files        directory 'full directory-files-no-dot-files-regexp))