comparison lisp/files.el @ 106808:390461140f6c

* files.el (copy-directory): Compute target for recursive directories with identical names. (Bug#5343)
author Michael Albinus <michael.albinus@gmx.de>
date Tue, 12 Jan 2010 22:59:05 +0100
parents 4af83423a0f1
children 1d1d5d9bd884
comparison
equal deleted inserted replaced
106807:8f9c3a09d55a 106808:390461140f6c
4712 (funcall handler 'copy-directory directory newname keep-time parents) 4712 (funcall handler 'copy-directory directory newname keep-time parents)
4713 4713
4714 ;; Compute target name. 4714 ;; Compute target name.
4715 (setq directory (directory-file-name (expand-file-name directory)) 4715 (setq directory (directory-file-name (expand-file-name directory))
4716 newname (directory-file-name (expand-file-name newname))) 4716 newname (directory-file-name (expand-file-name newname)))
4717 (if (and (file-directory-p newname)
4718 (not (string-equal (file-name-nondirectory directory)
4719 (file-name-nondirectory newname))))
4720 (setq newname
4721 (expand-file-name (file-name-nondirectory directory) newname)))
4722 (if (not (file-directory-p newname)) (make-directory newname parents)) 4717 (if (not (file-directory-p newname)) (make-directory newname parents))
4723 4718
4724 ;; Copy recursively. 4719 ;; Copy recursively.
4725 (mapc 4720 (mapc
4726 (lambda (file) 4721 (lambda (file)
4727 (if (file-directory-p file) 4722 (let ((target (expand-file-name
4728 (copy-directory file newname keep-time parents) 4723 (file-name-nondirectory file) newname)))
4729 (copy-file file newname t keep-time))) 4724 (if (file-directory-p file)
4730 ;; We do not want to delete "." and "..". 4725 (copy-directory file target keep-time parents)
4726 (copy-file file target t keep-time))))
4727 ;; We do not want to copy "." and "..".
4731 (directory-files directory 'full directory-files-no-dot-files-regexp)) 4728 (directory-files directory 'full directory-files-no-dot-files-regexp))
4732 4729
4733 ;; Set directory attributes. 4730 ;; Set directory attributes.
4734 (set-file-modes newname (file-modes directory)) 4731 (set-file-modes newname (file-modes directory))
4735 (if keep-time 4732 (if keep-time