FileLocator.resolve(url) can use the FileLocator.resolve(url) method to translate the bundleentry://something/somewhere/x.txt to the correct file URL for /mnt/foo/somewhere/x.txt .
However, as also described in https://bugs.eclipse.org/bugs/show_bug.cgi?id=145096 , the URL is not escaped. As an example, if an Eclipse installation containing a reference package is in a directory containing a space, the URL returned by FileLocator.resolve still contains a space, and the url.toURI() call fails because of this.
- How can I manually remove all the required characters in the URL?
- How can I get a
File object based on the path relative to the current bundle?
As a reference, here is the code that crashes when trying to find the dir directory inside my .jar plugin file if this file is in a directory containing a space:
final IPath pathOfExampleProject = new Path("dir"); final Bundle bundle = Platform.getBundle(AproveIDs.PLUGIN_ID); final URL url = FileLocator.find(bundle, pathOfExampleProject, null); final URL url2 = FileLocator.toFileURL(url); url2.toURI();
eclipse eclipse-plugin
C-otto
source share