- public Mailbox.Iterator iterator() { return new FileBasedMailbox.Iterator(); }
- public int uidValidity() { return (int)(new File(path).lastModified() & 0xffffffL); }
-
- public int uidNext() { return uidNext(false); }
- public int uidNext(boolean inc) {
- try {
- uidNext = new File(path + slash + "UIDNEXT");
- if (!uidNext.exists()) {
- File tmp = new File(uidNext + "-");
- PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(tmp)));
- pw.println("1");
- pw.flush();
- pw.close();
- tmp.renameTo(uidNext);
- return 1;
- }
- FileInputStream fis = null;
- int ret = -1;
- try {
- fis = new FileInputStream(uidNext);
- BufferedReader br = new BufferedReader(new InputStreamReader(fis));
- ret = Integer.parseInt(br.readLine());
- if (inc) {
- File tmp = new File(uidNext + "-");
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(tmp);
- PrintWriter pw = new PrintWriter(new OutputStreamWriter(fos));
- pw.println(ret+1);
- pw.flush();
- } finally { if (fos != null) fos.close(); }
- tmp.renameTo(uidNext);
- }
- } finally { if (fis != null) fis.close(); }
- return ret;
- } catch (IOException e) { throw new MailException.IOException(e); }
- }
-
- public synchronized void add(Message message) { add(message, Mailbox.Flag.RECENT); }