if (str.getByteList().length() == 0) {
return runtime.newFixnum(0);
}
try {
OpenFile myOpenFile = getOpenFileChecked();
myOpenFile.checkWritable(runtime);
context.getThread().beforeBlockingCall();
int written = fwrite(str.getByteList());
if (written == -1) {
// TODO: sys fail
}
// if not sync, we switch to write buffered mode
if (!myOpenFile.isSync()) {
myOpenFile.setWriteBuffered();
}
return runtime.newFixnum(written);
} catch (IOException ex) {
throw runtime.newIOErrorFromException(ex);