如何在eclipse插件开发中获取特定插件的首选项文件的绝对路径?

时间:2015-03-25 08:20:03

标签: eclipse eclipse-plugin eclipse-rcp

我想读取特定插件的首选项文件的绝对路径,该插件通常存储在:

Platform.getLocation() + "\.metadata\.plugins\org.eclipse.core.runtime\.settings\myPlugin.prefs"

有没有办法直接以某种方式使用eclipse提供Apis而不是硬编码路径的第二部分?

1 个答案:

答案 0 :(得分:1)

这应该给出正确的位置:

Bundle rt = Platform.getBundle(IPreferencesConstants.RUNTIME_NAME);

IPath path = Platform.getStateLocation(rt).append(".settings").append("myPlugin").addFileExtension("prefs");

实际位置计算在org.eclipse.core.internal.preferences.EclipsePreferences

相关问题