Skip to content

Commit

Permalink
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/RubyContext.java
Original file line number Diff line number Diff line change
@@ -101,12 +101,15 @@ public class RubyContext extends ExecutionContext {

private final AttachmentsManager attachmentsManager;

private String currentDirectory;

public RubyContext(Ruby jrubyRuntime, TruffleLanguage.Env env) {
latestInstance = this;

this.jrubyRuntime = jrubyRuntime;
this.jrubyInterop = new JRubyInterop(this, jrubyRuntime);
this.env = env;
this.currentDirectory = System.getProperty("user.dir");

if (options.CALL_GRAPH) {
callGraph = new CallGraph();
@@ -372,4 +375,12 @@ public EncodingManager getEncodingManager() {
return encodingManager;
}

public String getCurrentDirectory() {
return currentDirectory;
}

public void setCurrentDirectory(String currentDirectory) {
this.currentDirectory = currentDirectory;
}

}
Original file line number Diff line number Diff line change
@@ -401,7 +401,7 @@ public int chdir(DynamicObject path) {

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

return result;
@@ -596,7 +596,7 @@ public GetcwdNode(RubyContext context, SourceSection sourceSection) {
@Specialization
public DynamicObject getcwd() {
final String cwd = posix().getcwd();
final String path = getContext().getJRubyRuntime().getCurrentDirectory();
final String path = getContext().getCurrentDirectory();
assert path.equals(cwd);

// TODO (nirvdrum 12-Sept-16) The rope table always returns UTF-8, but this call should be based on Encoding.default_external and reflect updates to that value.
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ public boolean isVerbose() {

@Override
public File getCurrentWorkingDirectory() {
return new File(context.getJRubyRuntime().getCurrentDirectory());
return new File(context.getCurrentDirectory());
}

@Override

0 comments on commit 27ad02c

Please sign in to comment.