* elmo-util.el (elmo-delete-match-files): New function.
authorteranisi <teranisi>
Wed, 1 May 2002 07:54:02 +0000 (07:54 +0000)
committerteranisi <teranisi>
Wed, 1 May 2002 07:54:02 +0000 (07:54 +0000)
* elmo-localdir.el (elmo-folder-delete): Use elmo-delete-match-files
instead of elmo-delete-directory.

elmo/ChangeLog
elmo/elmo-localdir.el
elmo/elmo-util.el

index 5ec850e..7080578 100644 (file)
@@ -1,5 +1,10 @@
 2002-05-01  Yuuichi Teranishi  <teranisi@gohome.org>
 
+       * elmo-util.el (elmo-delete-match-files): New function.
+
+       * elmo-localdir.el (elmo-folder-delete): Use elmo-delete-match-files
+       instead of elmo-delete-directory.
+
        * elmo-shimbun.el (elmo-shimbun-get-headers): Bind
        elmo-hash-minimun-size as 63.
 
index b85d9c9..2fa24e5 100644 (file)
   (let ((dir (elmo-localdir-folder-directory-internal folder)))
     (if (not (file-directory-p dir))
        (error "No such directory: %s" dir)
-      (elmo-delete-directory dir t)
+      (elmo-delete-match-files dir "[0-9]+" t)
       t)))
 
 (luna-define-method elmo-folder-rename-internal ((folder elmo-localdir-folder)
index 90cc8be..34dddcd 100644 (file)
@@ -732,6 +732,18 @@ Return value is a cons cell of (STRUCTURE . REST)"
     (unless hierarchy
       (delete-directory path)))))
 
+(defun elmo-delete-match-files (path regexp &optional remove-if-empty)
+  "Delete directory files specified by PATH.
+If optional REMOVE-IF-EMPTY is non-nil, delete directory itself if
+the directory becomes empty after deletion."
+  (when (stringp path) ; nil is not permitted.
+    (dolist (file (directory-files path t regexp))
+      (delete-file file))
+    (if remove-if-empty
+       (ignore-errors 
+         (delete-directory path) ; should be removed if empty.
+         ))))
+
 (defun elmo-list-filter (l1 l2)
   "L1 is filter."
   (if (eq l1 t)