0
我想读它通常储存在特定插件的首选项文件的绝对路径:如何在eclipse插件开发中获取特定插件的偏好文件的绝对路径?
Platform.getLocation() + "\.metadata\.plugins\org.eclipse.core.runtime\.settings\myPlugin.prefs"
有没有办法把它直接以某种方式使用eclipse提供的API,而不是硬编码第二路径的一部分?
我想读它通常储存在特定插件的首选项文件的绝对路径:如何在eclipse插件开发中获取特定插件的偏好文件的绝对路径?
Platform.getLocation() + "\.metadata\.plugins\org.eclipse.core.runtime\.settings\myPlugin.prefs"
有没有办法把它直接以某种方式使用eclipse提供的API,而不是硬编码第二路径的一部分?
这应该给正确的位置:
Bundle rt = Platform.getBundle(IPreferencesConstants.RUNTIME_NAME);
IPath path = Platform.getStateLocation(rt).append(".settings").append("myPlugin").addFileExtension("prefs");
的实际位置的计算是org.eclipse.core.internal.preferences.EclipsePreferences
谢谢,它看起来像我们没有任何暴露的API来做到这一点。那么你的解决方案应该是最好的方法,因为它只有一个硬编码的字符串“.settings”。 – 2015-03-25 10:40:31
你真正想要的路径,或者你只是想访问首? – 2015-03-25 08:36:55
我想要文件的绝对路径。 – 2015-03-25 08:45:08
如果你看看'InstancePreferences'类,那里有代码可以让你动态地构建路径,但它意味着访问一些Eclipse内部类(特别是'MetaDataKeeper.getMetaArea()。getStateLocation()') – 2015-03-25 09:10:37