C-O*_*tto 8 eclipse eclipse-plugin
该方法FileLocator.resolve(url)可用于将地址bundleentry://something/somewhere/x.txt转换为适当的文件URL /mnt/foo/somewhere/x.txt.
但是,这也记录在https://bugs.eclipse.org/bugs/show_bug.cgi?id=145096,URL不会被转义.例如,如果包含引用的bundle的Eclipse安装位于包含空格的目录中,则返回的URL FileLocator.resolve仍包含空格,因此调用url.toURI()失败.
File根据相对于当前包的路径获取对象?作为参考,如果该文件位于包含空格的目录中,则尝试查找dir插件.jar文件中的目录时,代码会失败:
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(); // Illegal character in path at index [...]
Run Code Online (Sandbox Code Playgroud)
我刚发现这段代码:
相关的行确实有帮助:
// We need to use the 3-arg constructor of URI in order to properly escape file system chars.
URI resolvedUri = new URI(resolvedUrl.getProtocol(), resolvedUrl.getPath(), null);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1134 次 |
| 最近记录: |