Skip to content

Commit

Permalink
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import com.oracle.truffle.api.object.HiddenKey;
import com.oracle.truffle.api.source.SourceSection;
import jnr.constants.platform.Errno;
import org.jruby.truffle.nodes.objectstorage.ReadHeadObjectFieldNode;
import org.jruby.truffle.nodes.objectstorage.WriteHeadObjectFieldNode;
import org.jruby.truffle.runtime.RubyCallStack;
@@ -69,10 +70,18 @@ public DirOpenPrimitiveNode(DirOpenPrimitiveNode prev) {
@CompilerDirectives.TruffleBoundary
@Specialization
public RubyNilClass open(RubyBasicObject dir, RubyString path, RubyNilClass encoding) {
final String[] contents = new File(path.toString()).list();
// TODO CS 22-Apr-15 race conditions here

final File file = new File(path.toString());

if (!file.isDirectory()) {
throw new RaiseException(getContext().getCoreLibrary().errnoError(Errno.ENOTDIR.intValue(), this));
}

final String[] contents = file.list();

if (contents == null) {
throw new RaiseException(getContext().getCoreLibrary().fileNotFoundError(path.toString(), this));
throw new UnsupportedOperationException();
}

writeContentsNode.execute(dir, contents);
Original file line number Diff line number Diff line change
@@ -702,8 +702,7 @@ public RubyException errnoError(int errno, Node currentNode) {
return systemCallError(String.format("Unknown Error (%s)", errno), currentNode);
}

// TODO (nirvdrum 03-Apr-15): This should return the correct errno exception class.
return systemCallError(errnoObj.description(), currentNode);
return new RubyException(getErrnoClass(errnoObj), context.makeString(errnoObj.description()), RubyCallStack.getBacktrace(currentNode));
}

public RubyException indexError(String message, Node currentNode) {

0 comments on commit cf3bae6

Please sign in to comment.