Mercurial > emacs
changeset 105382:7cb911a9baab
* net/ange-ftp.el (ange-ftp-generate-passwd-key): Check, whether
HOST and USER are strings. They are nil, when there are
incomplete entries in ~/.netrc, for example.
(ange-ftp-delete-directory): Implement RECURSIVE case. Change to
root directory ("device busy" error otherwise).
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Fri, 02 Oct 2009 13:20:14 +0000 |
parents | 0c7122fb98eb |
children | 56aa7f20f7da |
files | lisp/net/ange-ftp.el |
diffstat | 1 files changed, 18 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/net/ange-ftp.el Fri Oct 02 12:52:17 2009 +0000 +++ b/lisp/net/ange-ftp.el Fri Oct 02 13:20:14 2009 +0000 @@ -1176,7 +1176,7 @@ ;;;; ------------------------------------------------------------ (defmacro ange-ftp-generate-passwd-key (host user) - `(concat (downcase ,host) "/" ,user)) + `(and (stringp ,host) (stringp ,user) (concat (downcase ,host) "/" ,user))) (defmacro ange-ftp-lookup-passwd (host user) `(gethash (ange-ftp-generate-passwd-key ,host ,user) @@ -4067,6 +4067,15 @@ (defun ange-ftp-delete-directory (dir &optional recursive) (if (file-directory-p dir) (let ((parsed (ange-ftp-ftp-name dir))) + (if recursive + (mapc + (lambda (file) + (if (file-directory-p file) + (ange-ftp-delete-directory file recursive) + (delete-file file))) + ;; We do not want to delete "." and "..". + (directory-files + dir 'full "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))) (if parsed (let* ((host (nth 0 parsed)) (user (nth 1 parsed)) @@ -4083,11 +4092,14 @@ (ange-ftp-real-file-name-as-directory (nth 2 parsed))))) (abbr (ange-ftp-abbreviate-filename dir)) - ;; TODO: handle RECURSIVE. - (result (ange-ftp-send-cmd host user - (list 'rmdir name) - (format "Removing directory %s" - abbr)))) + (result + (progn + ;; CWD must not in this directory. + (ange-ftp-cd host user "/" 'noerror) + (ange-ftp-send-cmd host user + (list 'rmdir name) + (format "Removing directory %s" + abbr))))) (or (car result) (ange-ftp-error host user (format "Could not remove directory %s: %s"