Skip to content

Commit

Permalink
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -9,12 +9,14 @@
*/
package org.jruby.truffle.nodes.core;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyArray;
import org.jruby.truffle.runtime.core.RubyFile;
import org.jruby.truffle.runtime.core.RubyProc;
@@ -82,8 +84,8 @@ public int delete(RubyString path) {
}

if (!dir.delete()) {
// TODO(CS, 12-Jan-15) handle failure
throw new UnsupportedOperationException();
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().dirNotEmptyError(path.toString(), this));
}

return 0;
Original file line number Diff line number Diff line change
@@ -123,6 +123,7 @@ public class CoreLibrary {
private final RubyClass edomClass;
private final RubyClass einvalClass;
private final RubyClass enoentClass;
private final RubyClass enotemptyClass;
private final RubyClass encodingConverterClass;
private final RubyClass encodingCompatibilityErrorClass;
private final RubyClass methodClass;
@@ -230,7 +231,7 @@ public CoreLibrary(RubyContext context) {
edomClass = new RubyClass(context, errnoModule, systemCallErrorClass, "EDOM");
new RubyClass(context, errnoModule, systemCallErrorClass, "EEXIST");
enoentClass = new RubyClass(context, errnoModule, systemCallErrorClass, "ENOENT");
new RubyClass(context, errnoModule, systemCallErrorClass, "ENOTEMPTY");
enotemptyClass = new RubyClass(context, errnoModule, systemCallErrorClass, "ENOTEMPTY");
new RubyClass(context, errnoModule, systemCallErrorClass, "EPERM");
new RubyClass(context, errnoModule, systemCallErrorClass, "EXDEV");
einvalClass = new RubyClass(context, errnoModule, systemCallErrorClass, "EINVAL");
@@ -862,6 +863,11 @@ public RubyException fileNotFoundError(String fileName, Node currentNode) {
return new RubyException(enoentClass, context.makeString(String.format("No such file or directory - %s", fileName)), RubyCallStack.getBacktrace(currentNode));
}

public RubyException dirNotEmptyError(String path, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return new RubyException(enotemptyClass, context.makeString(String.format("Directory not empty - %s", path)), RubyCallStack.getBacktrace(currentNode));
}

public RubyException rangeError(int code, RubyEncoding encoding, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return rangeError(String.format("invalid codepoint %x in %s", code, encoding.getEncoding()), currentNode);

0 comments on commit 0139e27

Please sign in to comment.