} else {
// Stream-based
inChannel = Channels.newChannel(process.getInputStream());
}
ChannelDescriptor main = new ChannelDescriptor(
inChannel);
main.setCanBeSeekable(false);
openFile.setMainStream(ChannelStream.open(getRuntime(), main));
}
if (openFile.isWritable() && process.hasOutput()) {
Channel outChannel;
if (process.getOutput() != null) {
// NIO-based
outChannel = process.getOutput();
} else {
outChannel = Channels.newChannel(process.getOutputStream());
}
ChannelDescriptor pipe = new ChannelDescriptor(
outChannel);
pipe.setCanBeSeekable(false);
if (openFile.getMainStream() != null) {
openFile.setPipeStream(ChannelStream.open(getRuntime(), pipe));
} else {
openFile.setMainStream(ChannelStream.open(getRuntime(), pipe));