RubyString oldNameString = RubyString.stringValue(oldName);
RubyString newNameString = RubyString.stringValue(newName);
String newNameJavaString = newNameString.getUnicodeValue();
String oldNameJavaString = oldNameString.getUnicodeValue();
JRubyFile oldFile = JRubyFile.create(runtime.getCurrentDirectory(), oldNameJavaString);
JRubyFile newFile = JRubyFile.create(runtime.getCurrentDirectory(), newNameJavaString);
if (!oldFile.exists() || !newFile.getParentFile().exists()) {
throw runtime.newErrnoENOENTError(oldNameJavaString + " or " + newNameJavaString);
}
JRubyFile dest = JRubyFile.create(runtime.getCurrentDirectory(), newNameJavaString);
if (oldFile.renameTo(dest)) { // rename is successful
return RubyFixnum.zero(runtime);
}