0

I have the same problem as the guy in this post: Get the absolute path of the currently edited file in Eclipse

but I dont understand how to do it. In the post they say that I should use IResource.getRawLocation() but how to I get the IResource from the current file that I am viewing?

IFile file2 = (IFile)workBench.getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorInput().getAdapter(IFile.class);

IPath path = file2.getRawLocation().makeAbsolute();
String ss = path.toString();

System.out.println(ss);

But this will still not give me the right path to the linked file, I get something like: /path/to/plugin/path/to/relative/path/to/file

Community
  • 1
  • 1
hidayat
  • 9,493
  • 13
  • 51
  • 66

1 Answers1

0

An IFile is-an IResource. You don't need to get one from another. Just call file2.getRawLocation(). If that's not working it's not because it's not an IResource.

Is the file in a jar/zip/any archive file? If so, it looks like that could be the correct absolute path.

Mark Peters
  • 80,126
  • 17
  • 159
  • 190