Skip to content

Commit

Permalink
[Truffle] ENOTDIR
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed May 19, 2015
1 parent 23726b3 commit f27b3b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Expand Up @@ -29,6 +29,7 @@ public static abstract class ExceptionErrnoErrorPrimitiveNode extends RubiniusPr
protected final int EBADF = Errno.EBADF.intValue();
protected final int EEXIST = Errno.EEXIST.intValue();
protected final int EACCES = Errno.EACCES.intValue();
protected final int ENOTDIR = Errno.ENOTDIR.intValue();

public ExceptionErrnoErrorPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
Expand Down Expand Up @@ -64,6 +65,10 @@ public RubyException eacces(RubyString message, int errno) {
return getContext().getCoreLibrary().permissionDeniedError(message.toString(), this);
}

@Specialization(guards = "errno == ENOTDIR")
public RubyException enotdir(RubyString message, int errno) {
return getContext().getCoreLibrary().notDirectoryError(message.toString(), this);
}

This comment has been minimized.

Copy link
@bjfish

bjfish May 19, 2015

Contributor

Should this be added to public static boolean isExceptionSupported(int errno) below?

This comment has been minimized.

Copy link
@eregon

eregon May 20, 2015

Member

I added and refactored in 9d7ed37


@CompilerDirectives.TruffleBoundary
@Specialization(guards = "!isExceptionSupported(errno)")
Expand Down
Expand Up @@ -1057,6 +1057,11 @@ public RubyException permissionDeniedError(String path, Node currentNode) {
return new RubyException(getErrnoClass(Errno.EACCES), context.makeString(String.format("Permission denied - %s", path)), RubyCallStack.getBacktrace(currentNode));
}

public RubyException notDirectoryError(String path, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return new RubyException(getErrnoClass(Errno.ENOTDIR), context.makeString(String.format("Not a directory - %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);
Expand Down

0 comments on commit f27b3b0

Please sign in to comment.