What is the best way to handle directory across windows and Unix based file systems in Rascal MPL, such that user of the Rascal project can read and generate files in those OS appropriately?
Unifying file scheme/path across Windows and Unix based OS in Rascal
47 views Asked by Pius Arhanbhunde At
1
It depends on the situation.
home:///ortmp:///orproject://<name>, or useIO::findResources.+to get to the children:path + "myFile.rsc"will take care of the proper escaping, encoding and add the path separator/myPath.lsto get a list of entries in a folder. Also inutil::FileSystemthere are more operations that work on any location to get an overview of a filesystem.remove,lastModidied, etc. etc.|file:///C:Program%20Files/|as a literal in your analysis results or in your intermediateM3models. In this case, all your downstream analysis will work correctly, except that jumping to the code will not work properly (since the code on your Mac doesn't have that folder.clairthis does not work. They always producefile:///URIs.IO::relativizeis elemental here. It will give you the postfix unique path name by removing the given prefix, if it fits. Sorelativize(|file:///C:Program%20Files|, |file:///C:Program%20Files/Hello.txt|)producesrelative:///Hello.txt. Then you can add the relative path to the new path:newPath + relative.path. Such a transformation is lineair in the size of the model and could take a few seconds! Typically you wouldvisit { case loc l => ...}in a few lines of code that write all locations where necessary.|file:///C:Program%20Files/Hello.txt|, send it to the Windows machine and there when used bywriteFileit would have the desired effect.In short: