Skip to content
Snippets Groups Projects
Commit 97aee7d1 authored by Florian Angerer's avatar Florian Angerer
Browse files

Resolving relative source paths to known library paths.

parent 8f74fd54
Branches
No related tags found
No related merge requests found
...@@ -27,12 +27,14 @@ import java.io.IOException; ...@@ -27,12 +27,14 @@ import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import com.oracle.truffle.api.source.Source; import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection; import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.r.runtime.RSrcref.SrcrefFields; import com.oracle.truffle.r.runtime.RSrcref.SrcrefFields;
import com.oracle.truffle.r.runtime.context.RContext;
import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector;
import com.oracle.truffle.r.runtime.env.REnvironment; import com.oracle.truffle.r.runtime.env.REnvironment;
...@@ -200,8 +202,18 @@ public class RSource { ...@@ -200,8 +202,18 @@ public class RSource {
if (filename.isAbsolute()) { if (filename.isAbsolute()) {
return fromFileName(filename.toString(), false); return fromFileName(filename.toString(), false);
} }
Path rHomePath = Paths.get(REnvVars.rHome()); Path resolved = filename;
return fromFileName(rHomePath.resolve(filename).toString(), false); if (!filename.isAbsolute()) {
for (String libPath : RContext.getInstance().libraryPaths) {
resolved = Paths.get(libPath).resolve(filename);
if (Files.exists(resolved)) {
break;
}
}
} else {
resolved = filename;
}
return fromFileName(resolved.toString(), false);
} }
private static String getPath(REnvironment env, String name) { private static String getPath(REnvironment env, String name) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment