|Getting the File name and Path From EMF URI [message #630487]
||Sun, 03 October 2010 10:14
| Animesh Kumar
Registered: September 2010
I wanted to create a search implementation which shows filenames of all the files available in the workspace.
The result which I have is in the form of array of URIs (org.eclipse.emf.common.util.URI).
But i want to retrieve the file names and paths for them.
I followed two approaches for this:-
1) I tried getting the resource set and then getting the resource from the resource set.
-This approach works absolutely fine but the problem is that, for search if i want to retrieve filenames and their paths, getResource (or) getEobject will load the resources and then we can perform any action on them. This is very inefficient way of showing the search results as i just require the file names.
2) I tried getting the file for it and then getting the file name:-
IPath path = new Path(files[i].toPlatformString(true));//Here files[i] is the URI
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
String fileObject = file.getName();
Even Here I Have to get the File to retrieve the name.
Can anyone suggest me a way to get the file name and the absolute path of the file directly from the URI. The URI here is org.eclipse.emf.common.util.URI and not java.net.URI.
[Updated on: Sun, 03 October 2010 10:17]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.05704 seconds