I am working at an eclipse plugin where the projects which exist in the Project Explorer view have a different workspace name than the actual path of the project. So considering a project located at D:\test when I try to get the project location, it points to D:\test_plugin_specific_suffix.
Is there a way to get an IFile from an absolute path (which points to the local path, D:\test\testfile.txt)?
I want to create a hyperlink to a specific file for which I have the absolute path. When I click on console on the hyperlink it should open in the editor the file.
You can use IWorkspaceRoot.findFilesForLocationURI to find the IFile corresponding to a absolute path (there might be more than one if you are
using links):
File file = new File(....absolue path);
URI location = file.toURI();
IFile[] files = ResourcesPlugin
.getWorkspace()
.getRoot()
.findFilesForLocationURI( location );