Ruby runtime = context.getRuntime();
for (int i = 0; i < args.length; i++) {
RubyString filename = get_path(context, args[i]);
runtime.checkSafeString(filename);
JRubyFile lToDelete = JRubyFile.create(runtime.getCurrentDirectory(), filename.getUnicodeValue());
boolean isSymlink = RubyFileTest.symlink_p(recv, filename).isTrue();
// Broken symlinks considered by exists() as non-existing,
// so we need to check for symlinks explicitly.
if (!lToDelete.exists() && !isSymlink) {
throw runtime.newErrnoENOENTError(filename.getUnicodeValue());
}
if (lToDelete.isDirectory() && !isSymlink) {
throw runtime.newErrnoEPERMError(filename.getUnicodeValue());
}
if (!lToDelete.delete()) {
throw runtime.newErrnoEACCESError(filename.getUnicodeValue());
}
}
return runtime.newFixnum(args.length);