Dave,
You should use build.getLocation(), not file.getLocation() or project.getLocation(), where build is the BuildScenario. The latter two will always resolve to the local filesystem, or null if the project is remote.
Greg On Sep 26, 2011, at 1:58 AM, Dave Wootton wrote:
Greg
I had what you proposed as my first
attempt, except that I had to add a call to toString() since the Path class
constructor only accepts String parameters, so I had the following
location = connection
.getRemoteServices()
.getFileManager(connection)
.toURI(new
Path(file.getLocation().append(file.getProjectRelativePath()).toString()));
I was still getting null for location,
so I added a print statement
System.out.println("File:
" + file.getLocation().append(file.getProjectRelativePath()).toString());
The output from the print statement
is File: C:/source/runtime-EclipseApplication-shallow/shallow_sync/shallow/shallow,
which is pointing to my local filesystem project location and the filename
itself appears twice
I tried changing the statement to
location = connection
.getRemoteServices()
.getFileManager(connection)
.toURI(new
Path(project.getLocation().append(file.getProjectRelativePath()).toString()));
That fixed the problem with the filename
appearuing twice but still does not resolve the location to the remote
file location, and I'm still getting null as a result.
Dave
|
Re: [ptp-dev] Getting
URI for file in a synchronized project |
Greg Watson
| to:
| Parallel Tools Platform general developers
|
09/23/2011 10:30 AM |
Please respond to Parallel Tools
Platform general developers
|
|
|
Dave,
This isn't quite what I said to do. You need to concatenate
the synchronized project location with the file name to obtain the path
on the remote machine, then pass this to toURI():
...toUri(new Path(build.getLocation()).append(file.getName()));
Greg
On Sep 22, 2011, at 9:43 PM, Dave Wootton wrote:
John, Roland
I'm trying to get a URI for a file that is in a synchronized project using
the following code
location = null;
try
{
if
(project.getNature(RemoteSyncNature.NATURE_ID)
!= null)
{
IManagedBuildInfo
buildInfo;
buildInfo
= ManagedBuildManager.getBuildInfo(project);
if
(buildInfo != null)
{
IConfiguration config;
config = buildInfo.getDefaultConfiguration();
if
(config != null)
{
BuildScenario build;
IRemoteConnection connection;
build = BuildConfigurationManager.getInstance()
.getBuildScenarioForBuildConfiguration(
config);
connection = build.getRemoteConnection();
location = connection
.getRemoteServices()
.getFileManager(connection)
.toURI(new
Path(file.getLocation().toString()));
}
}
} else
{
location
= file.getLocationURI();
}
} catch
(CoreException e) {
}
I'm starting with an IFile object named 'file' which I'm getting from an
IStructuredSelection object where the user has right clicked on a file
in the synchronized project and clicked my menu entry in the popup menu.
When the project is a synchronized project, location ends up being set
to null where the toURI method is returning null for the Path it is given.
file.getLocation.toString() is returning the full path to the requested
file on the local system, not the remote system, so it looks like the toURI
method is failing somewhere in translating this to a remote system URI.
Is this the correct way to get the remote file URI or should I be doing
this differently?
Also, I understand that ManagedBuildManager.getBuildInfo() returns null
if this is not a CDT project. Is this a correct assumption if the project
is a FORTRAN project or are FORTRAN projects not supported at this time?
I'm getting warnings complaining about discouraged access due to access
restrictions for RemoteSyncNature.NATUREID, BuildConfigurationManager.getBuildScenarioForBuildConfiguration,
BuildConfigurationManager.getInstance, BuildScenario.getRemoteConnection
and the classes BuildConfigurationManager, BuildScenario, and RemoteSyncNature.
Are these warnings anything that means I will have problems with this code?
Thanks
Dave_______________________________________________
ptp-dev mailing list
ptp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ptp-dev
_______________________________________________
ptp-dev mailing list
ptp-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/ptp-dev
_______________________________________________ ptp-dev mailing list ptp-dev@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/ptp-dev
|