// Accessors //////////////////////////////////////////////////////////////////////////////
public boolean seen() { return seen; }
- public MIME.Headers headers() { return new MIME.Headers(new Stream(new ByteArrayInputStream(header)), true); }
+ public Headers headers() { return new Headers(new Stream(new ByteArrayInputStream(header)), true); }
public Message message(Cache cache) { try {
FileInputStream fis = null;
try {
- fis = new FileInputStream(cache.dir.getParent() + slash + name);
- return Message.newMessage(new Stream(fis));
+ return Message.newMessage(new Fountain.File(new File(cache.dir.getParent() + slash + name)));
} finally { if (fis != null) fis.close(); }
} catch (IOException e) { throw new MailException.IOException(e);
} catch (Message.Malformed e) { throw new MailException(e.getMessage()); }
public static Transaction create(File f) throws IOException {
final boolean seen = f.lastModified() == MAGIC_DATE;
final String name = f.getName();
- final byte[] header = new MIME.Headers(new Stream(new FileInputStream(f)), true).toString().getBytes();
+ final byte[] header = new Headers(new Stream(new FileInputStream(f)), true).getString().getBytes();
return new Transaction() {
public void executeOn(Object o, Date now) {
Cache cache = (Cache)o;
if (!f.exists() && !target.exists()) break;
Log.error(this, "aieeee!!!! target of add() already exists: " + target.getAbsolutePath());
}
- FileOutputStream fo = new FileOutputStream(f);
- Stream stream = new Stream(fo);
- message.dump(stream);
- fo.close();
+ Stream stream = new Stream(new FileOutputStream(f));
+ message.getStream().transcribe(stream);
+ stream.close();
f.renameTo(new File(fullname));
f = new File(fullname);
if ((flags & Mailbox.Flag.SEEN) == Mailbox.Flag.SEEN) f.setLastModified(MAGIC_DATE);
int cur = -1;
private Cache.Entry entry() { return cache.getLinear(cur); }
private File file() { return new File(cache.dir.getParent() + slash + entry().name); }
- public MIME.Headers head() { return done() ? null : entry().headers(); }
+ public Headers head() { return done() ? null : entry().headers(); }
public boolean done() { return cur >= cache.size(); }
public boolean next() { cur++; return !done(); }
public boolean seen() { return done() ? false : entry().seen(); }