开发者

Convert IFileStore to IPath in Eclipse RCP

开发者 https://www.devze.com 2023-04-10 22:41 出处:网络
Given an IFileSto开发者_运维技巧re and knowledge that it represents a file in the local file system, how can it be converted to the IPath?I would go with this:

Given an IFileSto开发者_运维技巧re and knowledge that it represents a file in the local file system, how can it be converted to the IPath?


I would go with this:

File file = iFileStore().toLocalFile(0, null);
IPath path = Path.fromOSString(file.getCanonicalPath());

The other answer would probably work, but the answer here is likely safer.


Try this:

String path = iFileStore.getParent().getName();
...
IPath iPath = Path.fromPortableString(path);

You probably have to do some string manipulation on the path string where I have the ellipses.

Since you have the test bed, you can more easily determine what code goes in the ellipses. Feel free to update this answer with what you find.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号