comparison lisp/dired-aux.el @ 71928:87bfa39ee279

* dired-aux.el (dired-compress-file): Confirm again if gzipped file already exists.
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 17 Jul 2006 04:00:54 +0000
parents fda2aa003809
children 954bc7af1cb8 8a8e69664178
comparison
equal deleted inserted replaced
71927:dca11242db4e 71928:87bfa39ee279
743 newname)) 743 newname))
744 (t 744 (t
745 ;;; We don't recognize the file as compressed, so compress it. 745 ;;; We don't recognize the file as compressed, so compress it.
746 ;;; Try gzip; if we don't have that, use compress. 746 ;;; Try gzip; if we don't have that, use compress.
747 (condition-case nil 747 (condition-case nil
748 (if (not (dired-check-process (concat "Compressing " file) 748 (let ((out-name (concat file ".gz")))
749 "gzip" "-f" file)) 749 (and (or (not (file-exists-p out-name))
750 (let ((out-name 750 (y-or-n-p
751 (if (file-exists-p (concat file ".gz")) 751 (format "File %s already exists. Really compress? "
752 (concat file ".gz") 752 out-name)))
753 (concat file ".z")))) 753 (not (dired-check-process (concat "Compressing " file)
754 ;; Rename the compressed file to NEWNAME 754 "gzip" "-f" file))
755 ;; if it hasn't got that name already. 755 (or (file-exists-p out-name)
756 (if (and newname (not (equal newname out-name))) 756 (setq out-name (concat file ".z")))
757 (progn 757 ;; Rename the compressed file to NEWNAME
758 (rename-file out-name newname t) 758 ;; if it hasn't got that name already.
759 newname) 759 (if (and newname (not (equal newname out-name)))
760 out-name))) 760 (progn
761 (rename-file out-name newname t)
762 newname)
763 out-name)))
761 (file-error 764 (file-error
762 (if (not (dired-check-process (concat "Compressing " file) 765 (if (not (dired-check-process (concat "Compressing " file)
763 "compress" "-f" file)) 766 "compress" "-f" file))
764 ;; Don't use NEWNAME with `compress'. 767 ;; Don't use NEWNAME with `compress'.
765 (concat file ".Z")))))))) 768 (concat file ".Z"))))))))