Eclipse Community Forums Forum Search:

Home » Eclipse Projects » Eclipse Platform » Getting Linux path on Windows(ResourcesPlugin.getWorkspace().getRoot() returns "/")
Getting Linux path on Windows Tue, 24 May 2011 04:29
 MaximeLecourt Messages: 108Registered: February 2010 Location: France Senior Member
Hi,

I'm having trouble with paths under WindowsXP.

public IFile getFile(String path) {
IPath ipath = new Path(path);
IFile res = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(ipath);
if(res == null)
res = ResourcesPlugin.getWorkspace().getRoot().getFile(ipath);
return res;
}

I call that function with a windows path String.
The IPath is ok, device and path are still good.
But once I try to turn it to IFile, res looses the device, and returns a Linux path (so instead of D:\the\way\to\my.file, I get /the/way/to/my.file).

Any subsequent use of the resulting IFile fails, of course, as it searches a file with a Linux path on a Windows system.
Is that a bug or am I doing some things wrong ?

Thanks

Maxime

One day I shall master M2T, but that day has yet to come...
Re: Getting Linux path on Windows [message #673706 is a reply to message #673598] Tue, 24 May 2011 10:08
 Paul WebsterMessages: 6850Registered: July 2009 Location: Ottawa Senior Member
All paths within a workspace are "/the/way/to/my.file", as they're relative to the workspace root.

An IFile also only exists within the workspace, and so doesn't have information for dealing with devices.

What are you trying to do exactly? You seem to be working within a workspace. What are you trying to pass in as input? An absolute java.io.File path to a file that lives in a workspace?

PW

 Previous Topic: Binding conflicts Next Topic: Core expressions framework behaviour
Goto Forum:

Current Time: Fri Dec 06 06:53:00 EST 2013