* gnus-util.el (gnus-delete-directory): New function.
authorKatsumi Yamaoka <yamaoka@jpl.org>
Fri, 17 Dec 2004 10:27:43 +0000 (10:27 +0000)
committerKatsumi Yamaoka <yamaoka@jpl.org>
Fri, 17 Dec 2004 10:27:43 +0000 (10:27 +0000)
* gnus-agent.el (gnus-agent-delete-group): Use it.
* gnus-cache.el (gnus-cache-delete-group): Use it.

lisp/ChangeLog
lisp/gnus-agent.el
lisp/gnus-cache.el
lisp/gnus-util.el

index ad467f2..286155a 100644 (file)
@@ -1,3 +1,11 @@
+2004-12-17  Katsumi Yamaoka  <yamaoka@jpl.org>
+
+       * gnus-util.el (gnus-delete-directory): New function.
+
+       * gnus-agent.el (gnus-agent-delete-group): Use it.
+
+       * gnus-cache.el (gnus-cache-delete-group): Use it.
+
 2004-12-16  Katsumi Yamaoka  <yamaoka@jpl.org>
 
        * gnus-group.el (gnus-group-make-rss-group): Unify non-ASCII group
index 86c9a1d..bc13dd7 100644 (file)
@@ -905,7 +905,7 @@ next enabled. Depends upon the caller to determine whether group deletion is sup
         (path           (directory-file-name
                          (let (gnus-command-method command-method)
                            (gnus-agent-group-pathname group)))))
-    (gnus-delete-file path)
+    (gnus-delete-directory path)
 
     (let* ((real-group (gnus-group-real-name group)))
       (gnus-agent-save-group-info command-method real-group nil)
index 9b1eb8d..2985490 100644 (file)
@@ -759,7 +759,7 @@ next enabled. Depends upon the caller to determine whether group renaming is sup
 disabled, as the old cache files would corrupt gnus when the cache was
 next enabled. Depends upon the caller to determine whether group deletion is supported."
   (let ((dir (gnus-cache-file-name group "")))
-    (gnus-delete-file dir))
+    (gnus-delete-directory dir))
 
   (gnus-cache-delete-group-total-fetched-for group)
 
index e2e50a0..8aa4925 100644 (file)
@@ -701,6 +701,23 @@ Bind `print-quoted' and `print-readably' to t, and `print-length' and
   (when (file-exists-p file)
     (delete-file file)))
 
+(defun gnus-delete-directory (directory)
+  "Delete files in DIRECTORY.  Subdirectories remain.
+If there's no subdirectory, delete DIRECTORY as well."
+  (when (file-directory-p directory)
+    (let ((files (directory-files
+                 directory t "^\\([^.]\\|\\.\\([^.]\\|\\..\\)\\).*"))
+         file dir)
+      (while files
+       (setq file (pop files))
+       (if (eq t (car (file-attributes file)))
+           ;; `file' is a subdirectory.
+           (setq dir t)
+         ;; `file' is a file or a symlink.
+         (delete-file file)))
+      (unless dir
+       (delete-directory directory)))))
+
 (defun gnus-strip-whitespace (string)
   "Return STRING stripped of all whitespace."
   (while (string-match "[\r\n\t ]+" string)