问题描述
我想编写一个插件来处理当前在 Eclipse 中编辑的文件.但我不确定如何正确获取文件的完整路径.
I'd like to write a plugin that does something with the currently edited file in Eclipse. But I'm not sure how to properly get the file's full path.
这就是我现在所做的:
IFile file = (IFile) window.getActivePage().getActiveEditor.getEditorInput().
getAdapter(IFile.class);
现在我有一个 IFile 对象,我可以检索它的路径:
Now I have an IFile object, and I can retrieve it's path:
file.getFullPath().toOSString();
但是,这仍然只给了我相对于工作区的路径.我怎样才能从中获得绝对路径?
However this still only gives me the path relative to the workspace. How can I get the absolute path from that?
推荐答案
看起来你想要 IResource.getRawLocation().这会返回一个 IPath,如果你想更加确定你有一个绝对路径,它还有一个 makeAbsolute() 方法.
Looks like you want IResource.getRawLocation(). That returns an IPath, which also has a makeAbsolute() method if you want to be doubly sure you've got an absolute path.
这篇关于获取Eclipse中当前编辑文件的绝对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)