mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Unidirectional transports and connections are now called simplex rather than batch. Bidirectional transports and connections are now called duplex rather than stream.
51 lines
1.1 KiB
Java
51 lines
1.1 KiB
Java
package net.sf.briar.plugins.file;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.OutputStream;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
|
|
import net.sf.briar.api.plugins.SimplexTransportWriter;
|
|
|
|
class FileTransportWriter implements SimplexTransportWriter {
|
|
|
|
private static final Logger LOG =
|
|
Logger.getLogger(FileTransportWriter.class.getName());
|
|
|
|
private final File file;
|
|
private final OutputStream out;
|
|
private final long capacity;
|
|
private final FilePlugin plugin;
|
|
|
|
FileTransportWriter(File file, OutputStream out, long capacity,
|
|
FilePlugin plugin) {
|
|
this.file = file;
|
|
this.out = out;
|
|
this.capacity = capacity;
|
|
this.plugin = plugin;
|
|
}
|
|
|
|
public long getCapacity() {
|
|
return capacity;
|
|
}
|
|
|
|
public OutputStream getOutputStream() {
|
|
return out;
|
|
}
|
|
|
|
public boolean shouldFlush() {
|
|
return false;
|
|
}
|
|
|
|
public void dispose(boolean exception) {
|
|
try {
|
|
out.close();
|
|
} catch(IOException e) {
|
|
if(LOG.isLoggable(Level.WARNING)) LOG.warning(e.toString());
|
|
}
|
|
if(exception) file.delete();
|
|
else plugin.writerFinished(file);
|
|
}
|
|
}
|