Stream readStream = myOpenFile.getMainStream();
int c = -1;
int n = -1;
int newline = separator.get(separator.length() - 1) & 0xFF;
ByteList buf = new ByteList(0);
boolean update = false;
while (true) {
do {
readCheck(readStream);
readStream.clearerr();
try {
n = readStream.getline(buf, (byte) newline);
c = buf.length() > 0 ? buf.get(buf.length() - 1) & 0xff : -1;
} catch (EOFException e) {
n = -1;
}
if (n == -1) {
if (!readStream.isBlocking() && (readStream instanceof ChannelStream)) {
if(!(waitReadable(((ChannelStream)readStream).getDescriptor()))) {
throw runtime.newIOError("bad file descriptor: " + openFile.getPath());
}
continue;
} else {
break;
}
}
update = true;
} while (c != newline); // loop until we see the nth separator char
// if we hit EOF, we're done
if (n == -1) {
break;
}
// if we've found the last char of the separator,
// and we've found at least as many characters as separator length,
// and the last n characters of our buffer match the separator, we're done
if (c == newline && buf.length() >= separator.length() &&
0 == ByteList.memcmp(buf.unsafeBytes(), buf.begin + buf.realSize - separator.length(), separator.unsafeBytes(), separator.begin, separator.realSize)) {
break;
}
}
if (isParagraph) {