Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: fe0eb3855c9e
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 00e38f8d0fdc
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Aug 7, 2016

  1. 2
    Copy the full SHA
    553bfc9 View commit details
  2. Copy the full SHA
    49cde6a View commit details
  3. Copy the full SHA
    00e38f8 View commit details
Showing with 14 additions and 11 deletions.
  1. +13 −9 truffle/src/main/java/org/jruby/truffle/extra/TrufflePosixNodes.java
  2. +1 −2 truffle/src/main/ruby/core/dir.rb
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@
import org.jruby.truffle.builtins.Primitive;
import org.jruby.truffle.builtins.PrimitiveArrayArgumentsNode;
import org.jruby.truffle.core.rope.CodeRange;
import org.jruby.truffle.core.rope.LeafRope;
import org.jruby.truffle.core.rope.RopeNodes;
import org.jruby.truffle.core.rope.RopeNodesFactory;
import org.jruby.truffle.core.string.StringOperations;
@@ -394,7 +395,8 @@ public int chdir(DynamicObject path) {
final int result = posix().chdir(pathString);

if (result == 0) {
getContext().getJRubyRuntime().setCurrentDirectory(pathString);
final String cwd = posix().getcwd();
getContext().getJRubyRuntime().setCurrentDirectory(cwd);
}

return result;
@@ -565,7 +567,7 @@ public int rmdir(DynamicObject path) {

}

@CoreMethod(names = "getcwd", isModuleFunction = true, required = 2, unsafe = UnsafeGroup.IO)
@CoreMethod(names = "getcwd", isModuleFunction = true, unsafe = UnsafeGroup.IO)
public abstract static class GetcwdNode extends CoreMethodArrayArgumentsNode {

@Child private RopeNodes.MakeLeafRopeNode makeLeafRopeNode;
@@ -575,14 +577,16 @@ public GetcwdNode(RubyContext context, SourceSection sourceSection) {
makeLeafRopeNode = RopeNodesFactory.MakeLeafRopeNodeGen.create(null, null, null, null);
}

@CompilerDirectives.TruffleBoundary
@Specialization(guards = "isRubyString(resultPath)")
public DynamicObject getcwd(DynamicObject resultPath, int maxSize) {
// We just ignore maxSize - I think this is ok

@TruffleBoundary
@Specialization
public DynamicObject getcwd() {
final String cwd = posix().getcwd();
final String path = getContext().getJRubyRuntime().getCurrentDirectory();
StringOperations.setRope(resultPath, makeLeafRopeNode.executeMake(path.getBytes(StandardCharsets.UTF_8), Layouts.STRING.getRope(resultPath).getEncoding(), CodeRange.CR_UNKNOWN, NotProvided.INSTANCE));
return resultPath;
assert path.equals(cwd);

final byte[] bytes = cwd.getBytes(StandardCharsets.UTF_8);
final LeafRope rope = makeLeafRopeNode.executeMake(bytes, UTF8Encoding.INSTANCE, CodeRange.CR_UNKNOWN, NotProvided.INSTANCE);
return StringOperations.createString(getContext(), rope);
}

}
3 changes: 1 addition & 2 deletions truffle/src/main/ruby/core/dir.rb
Original file line number Diff line number Diff line change
@@ -233,8 +233,7 @@ def self.rmdir(path)
end

def self.getwd
buf = String.pattern Rubinius::PATH_MAX, 0
wd = Truffle::POSIX.getcwd(buf, buf.length)
wd = Truffle::POSIX.getcwd
Errno.handle unless wd
Rubinius::Type.external_string wd
end