- public void delete(String m0) { delete(mailbox(m0,false)); }
- public void delete(Mailbox m) { if (!m.equals(inbox)) m.destroy(false); else throw new Bad("can't delete inbox"); }
+
+ public void delete(String m0) { mailboxTree(dirname(m0),false).rmdir(basename(m0)); }
+
+ public void rename(String from0, String to) {
+ Mailbox from = mailbox(from0, false);
+ if (from.equals(inbox)) { from.copy(Query.all(), mailbox(to, true)); }
+ else if (to.equalsIgnoreCase("inbox")) { from.copy(Query.all(), mailbox(to, true)); delete(from0); }
+ else mailboxTree(dirname(from0), false)
+ .rename(dirname(from0),
+ mailboxTree(dirname(to),
+ true /* required by IMAP */),
+ basename(to));
+ }
+