I have this logical location: |project://testProject/src/style.css|
which I would like to convert to its related physical location. The location is first passed on to a Java file, where I try to convert it using the URIResolverRegistry.getInstance().logicalToPhysical(theLoc);
method. The only problem is that it returns the exact location I passed it (the logical location). So it does not get converted. How come? Am I missing something? Or is there maybe another way to solve this?
Asked
Active
Viewed 99 times
2

Nicasso
- 265
- 1
- 7
-
1Often when we have this question, you actually want to use the UriResolverRegistry to get an input or output stream. That registry provides most abstractions needed. The only thing that is harder to do is when calling an external program. However, the most stable way is copying it to a known file location, and copying the result back. – Davy Landman May 25 '16 at 11:38
1 Answers
2
Actually, project
is supposed to be a "physical" URI already. If you want to convert it to an absolute path on the file system, then this is not supported directly.
However, if you are in an Eclipse context and you are free to depend on it, then rascal-eclipse offers this API:
IFile file = new ProjectURIResolver().resolveFile(myLoc);
String absolutePath = file.getLocation().toOSString();

Jurgen Vinju
- 6,393
- 1
- 15
- 26
-
2Note that you can also do this from within Rascal, under the assumption that you are in Eclipse and have the Eclipse-specific Rascal libraries available. If you import `util::Resources`, the function `location` will convert an Eclipse `project` URI into an actual file location, e.g., `location(|project://PHPAnalysis/src/lang/php/ast/AbstractSyntax.rsc|)` gives me back `|file:///Users/mhills/PHPAnalysis/rascal/php-analysis/src/lang/php/ast/AbstractSyntax.rsc|` on my laptop. – Mark Hills May 25 '16 at 17:11