Skip to content

Commit

Permalink
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 0 additions & 1 deletion spec/truffle/tags/core/file/new_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@ public static abstract class ExceptionErrnoErrorPrimitiveNode extends RubiniusPr

protected final int ENOENT = Errno.ENOENT.intValue();
protected final int EBADF = Errno.EBADF.intValue();
protected final int EEXIST = Errno.EEXIST.intValue();

public ExceptionErrnoErrorPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
@@ -48,6 +49,11 @@ public RubyException ebadf(RubyNilClass message, int errno) {
return getContext().getCoreLibrary().badFileDescriptor(this);
}

@Specialization(guards = "errno == EEXIST")
public RubyException eexist(RubyString message, int errno) {
return getContext().getCoreLibrary().fileExistsError(message.toString(), this);
}

@CompilerDirectives.TruffleBoundary
@Specialization(guards = "!isExceptionSupported(errno)")
public RubyException unsupported(RubyString message, int errno) {
@@ -73,7 +79,7 @@ public RubyException unsupported(RubyNilClass message, int errno) {
}

public static boolean isExceptionSupported(int errno) {
return Errno.ENOENT.intValue() == errno || Errno.EBADF.intValue() == errno;
return Errno.ENOENT.intValue() == errno || Errno.EBADF.intValue() == errno || Errno.EEXIST.intValue() == errno;
}

}
Original file line number Diff line number Diff line change
@@ -936,6 +936,11 @@ public RubyException badFileDescriptor(Node currentNode) {
return new RubyException(getErrnoClass(Errno.EBADF), context.makeString("Bad file descriptor"), RubyCallStack.getBacktrace(currentNode));
}

public RubyException fileExistsError(String fileName, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return new RubyException(getErrnoClass(Errno.EEXIST), context.makeString(String.format("File exists - %s", fileName)), RubyCallStack.getBacktrace(currentNode));
}

public RubyException fileNotFoundError(String fileName, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return new RubyException(getErrnoClass(Errno.ENOENT), context.makeString(String.format("No such file or directory - %s", fileName)), RubyCallStack.getBacktrace(currentNode));

0 comments on commit 32ea50f

Please sign in to comment.