Convert IFileStore to IPath in Eclipse RCP
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.
精彩评论