+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
(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)
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)
(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)