From: Michael Albinus Date: Fri, 2 Oct 2009 13:20:14 +0000 (+0000) Subject: * net/ange-ftp.el (ange-ftp-generate-passwd-key): Check, whether X-Git-Tag: emacs-pretest-23.1.90~988 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b3ee21ac4fb0dd0ed6e585691526cdc0e73cf804;p=emacs.git * 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). --- diff --git a/lisp/net/ange-ftp.el b/lisp/net/ange-ftp.el index 60fe96623e1..40c1650076f 100644 --- a/lisp/net/ange-ftp.el +++ b/lisp/net/ange-ftp.el @@ -1176,7 +1176,7 @@ only return the directory part of FILE." ;;;; ------------------------------------------------------------ (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 @@ directory, so that Emacs will know its current contents." (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 @@ directory, so that Emacs will know its current contents." (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"