mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-06 15:55:47 +02:00
Bug 454063 - Use new Path.forPosix() API when handling remote paths.
Change-Id: I2a08f5f7d165acbb1d5b4e3226834b8cecf0fab3 Signed-off-by: Greg Watson <g.watson@computer.org>
This commit is contained in:
parent
9825f0f0cb
commit
76feaed504
7 changed files with 38 additions and 38 deletions
|
@ -18,9 +18,9 @@ import org.eclipse.core.filesystem.URIUtil;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.remote.core.IRemoteConnection;
|
import org.eclipse.remote.core.IRemoteConnection;
|
||||||
|
import org.eclipse.remote.core.IRemoteConnection.Service;
|
||||||
import org.eclipse.remote.core.IRemoteFileService;
|
import org.eclipse.remote.core.IRemoteFileService;
|
||||||
import org.eclipse.remote.core.IRemoteProcessService;
|
import org.eclipse.remote.core.IRemoteProcessService;
|
||||||
import org.eclipse.remote.core.IRemoteConnection.Service;
|
|
||||||
|
|
||||||
public class LocalFileService implements IRemoteFileService {
|
public class LocalFileService implements IRemoteFileService {
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class LocalFileService implements IRemoteFileService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IFileStore getResource(String path) {
|
public IFileStore getResource(String path) {
|
||||||
return EFS.getLocalFileSystem().getStore(new Path(path));
|
return EFS.getLocalFileSystem().getStore(Path.fromOSString(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class LocalProcessBuilder extends AbstractRemoteProcessBuilder {
|
||||||
if (dir == null) {
|
if (dir == null) {
|
||||||
String userDir = System.getProperty("user.dir"); //$NON-NLS-1$
|
String userDir = System.getProperty("user.dir"); //$NON-NLS-1$
|
||||||
if (userDir != null) {
|
if (userDir != null) {
|
||||||
dir = EFS.getLocalFileSystem().getStore(new Path(userDir));
|
dir = EFS.getLocalFileSystem().getStore(Path.fromOSString(userDir));
|
||||||
directory(dir);
|
directory(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -980,7 +980,7 @@ public class JSchConnection implements IRemoteConnectionControlService, IRemoteC
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setWorkingDirectory(String path) {
|
public void setWorkingDirectory(String path) {
|
||||||
if (new Path(path).isAbsolute()) {
|
if (Path.forPosix(path).isAbsolute()) {
|
||||||
fWorkingDir = path;
|
fWorkingDir = path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,9 @@ import org.eclipse.core.filesystem.IFileStore;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.remote.core.IRemoteConnection;
|
import org.eclipse.remote.core.IRemoteConnection;
|
||||||
|
import org.eclipse.remote.core.IRemoteConnection.Service;
|
||||||
import org.eclipse.remote.core.IRemoteFileService;
|
import org.eclipse.remote.core.IRemoteFileService;
|
||||||
import org.eclipse.remote.core.IRemoteProcessService;
|
import org.eclipse.remote.core.IRemoteProcessService;
|
||||||
import org.eclipse.remote.core.IRemoteConnection.Service;
|
|
||||||
|
|
||||||
public class JSchFileManager implements IRemoteFileService {
|
public class JSchFileManager implements IRemoteFileService {
|
||||||
|
|
||||||
|
@ -51,9 +51,9 @@ public class JSchFileManager implements IRemoteFileService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IFileStore getResource(String pathStr) {
|
public IFileStore getResource(String pathStr) {
|
||||||
IPath path = new Path(pathStr);
|
IPath path = Path.forPosix(pathStr);
|
||||||
if (!path.isAbsolute()) {
|
if (!path.isAbsolute()) {
|
||||||
path = new Path(getBaseDirectory()).append(path);
|
path = Path.forPosix(getBaseDirectory()).append(path);
|
||||||
}
|
}
|
||||||
return JschFileStore.getInstance(JSchFileSystem.getURIFor(fConnection.getName(), path.toString()));
|
return JschFileStore.getInstance(JSchFileSystem.getURIFor(fConnection.getName(), path.toString()));
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public class JSchFileManager implements IRemoteFileService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URI toURI(String path) {
|
public URI toURI(String path) {
|
||||||
return toURI(new Path(path));
|
return toURI(Path.forPosix(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class JschFileStore extends FileStore {
|
||||||
|
|
||||||
private JschFileStore(URI uri) {
|
private JschFileStore(URI uri) {
|
||||||
fURI = uri;
|
fURI = uri;
|
||||||
fRemotePath = new Path(uri.getPath());
|
fRemotePath = Path.forPosix(uri.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSchConnection checkConnection(IProgressMonitor monitor) throws RemoteConnectionException {
|
private JSchConnection checkConnection(IProgressMonitor monitor) throws RemoteConnectionException {
|
||||||
|
@ -224,8 +224,8 @@ public class JschFileStore extends FileStore {
|
||||||
if ((options & EFS.SHALLOW) == EFS.SHALLOW) {
|
if ((options & EFS.SHALLOW) == EFS.SHALLOW) {
|
||||||
IFileStore parent = getParent();
|
IFileStore parent = getParent();
|
||||||
if (parent != null && !parent.fetchInfo(EFS.NONE, subMon.newChild(9)).exists()) {
|
if (parent != null && !parent.fetchInfo(EFS.NONE, subMon.newChild(9)).exists()) {
|
||||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRITE, NLS.bind(
|
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRITE,
|
||||||
Messages.JschFileStore_The_parent_of_directory_does_not_exist, fRemotePath.toString()), null));
|
NLS.bind(Messages.JschFileStore_The_parent_of_directory_does_not_exist, fRemotePath.toString()), null));
|
||||||
}
|
}
|
||||||
if (subMon.isCanceled()) {
|
if (subMon.isCanceled()) {
|
||||||
return this;
|
return this;
|
||||||
|
@ -245,8 +245,8 @@ public class JschFileStore extends FileStore {
|
||||||
IFileInfo info = fetchInfo(EFS.NONE, subMon.newChild(10));
|
IFileInfo info = fetchInfo(EFS.NONE, subMon.newChild(10));
|
||||||
if (!subMon.isCanceled()) {
|
if (!subMon.isCanceled()) {
|
||||||
if (!info.exists()) {
|
if (!info.exists()) {
|
||||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRITE, NLS.bind(
|
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRITE,
|
||||||
Messages.JschFileStore_The_directory_could_not_be_created, fRemotePath.toString()), null));
|
NLS.bind(Messages.JschFileStore_The_directory_could_not_be_created, fRemotePath.toString()), null));
|
||||||
}
|
}
|
||||||
if (!info.isDirectory()) {
|
if (!info.isDirectory()) {
|
||||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRONG_TYPE,
|
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRONG_TYPE,
|
||||||
|
@ -271,12 +271,12 @@ public class JschFileStore extends FileStore {
|
||||||
IFileInfo info = fetchInfo(EFS.NONE, subMon.newChild(9));
|
IFileInfo info = fetchInfo(EFS.NONE, subMon.newChild(9));
|
||||||
if (!subMon.isCanceled()) {
|
if (!subMon.isCanceled()) {
|
||||||
if (!info.exists()) {
|
if (!info.exists()) {
|
||||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_READ, NLS.bind(
|
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_READ,
|
||||||
Messages.JschFileStore_File_doesnt_exist, fRemotePath.toString()), null));
|
NLS.bind(Messages.JschFileStore_File_doesnt_exist, fRemotePath.toString()), null));
|
||||||
}
|
}
|
||||||
if (info.isDirectory()) {
|
if (info.isDirectory()) {
|
||||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRONG_TYPE, NLS.bind(
|
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRONG_TYPE,
|
||||||
Messages.JschFileStore_Is_a_directory, fRemotePath.toString()), null));
|
NLS.bind(Messages.JschFileStore_Is_a_directory, fRemotePath.toString()), null));
|
||||||
}
|
}
|
||||||
GetInputStreamCommand command = new GetInputStreamCommand(connection, fRemotePath);
|
GetInputStreamCommand command = new GetInputStreamCommand(connection, fRemotePath);
|
||||||
return command.getResult(subMon.newChild(10));
|
return command.getResult(subMon.newChild(10));
|
||||||
|
@ -297,8 +297,8 @@ public class JschFileStore extends FileStore {
|
||||||
IFileInfo info = fetchInfo(EFS.NONE, subMon.newChild(9));
|
IFileInfo info = fetchInfo(EFS.NONE, subMon.newChild(9));
|
||||||
if (!subMon.isCanceled()) {
|
if (!subMon.isCanceled()) {
|
||||||
if (info.isDirectory()) {
|
if (info.isDirectory()) {
|
||||||
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRONG_TYPE, NLS.bind(
|
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRONG_TYPE,
|
||||||
Messages.JschFileStore_Is_a_directory, fRemotePath.toString()), null));
|
NLS.bind(Messages.JschFileStore_Is_a_directory, fRemotePath.toString()), null));
|
||||||
}
|
}
|
||||||
GetOutputStreamCommand command = new GetOutputStreamCommand(connection, options, fRemotePath);
|
GetOutputStreamCommand command = new GetOutputStreamCommand(connection, options, fRemotePath);
|
||||||
return command.getResult(subMon.newChild(10));
|
return command.getResult(subMon.newChild(10));
|
||||||
|
|
|
@ -83,8 +83,8 @@ public abstract class AbstractRemoteCommand<T> {
|
||||||
taskName.append(MessageFormat.format(Messages.AbstractRemoteCommand_format1, new Object[] { workToDate, size }));
|
taskName.append(MessageFormat.format(Messages.AbstractRemoteCommand_format1, new Object[] { workToDate, size }));
|
||||||
} else {
|
} else {
|
||||||
Double workPercent = new Double(fWorkPercentFactor * fWorkToDate);
|
Double workPercent = new Double(fWorkPercentFactor * fWorkToDate);
|
||||||
taskName.append(MessageFormat.format(Messages.AbstractRemoteCommand_format2, new Object[] { workToDate, size,
|
taskName.append(MessageFormat.format(Messages.AbstractRemoteCommand_format2,
|
||||||
fMaxWork, fMaxWorkSize, workPercent }));
|
new Object[] { workToDate, size, fMaxWork, fMaxWorkSize, workPercent }));
|
||||||
}
|
}
|
||||||
fMonitor.subTask(taskName.toString());
|
fMonitor.subTask(taskName.toString());
|
||||||
fMonitor.worked((int) count);
|
fMonitor.worked((int) count);
|
||||||
|
@ -107,7 +107,7 @@ public abstract class AbstractRemoteCommand<T> {
|
||||||
fMaxWork = max / 1024L;
|
fMaxWork = max / 1024L;
|
||||||
}
|
}
|
||||||
fWorkToDate = 0;
|
fWorkToDate = 0;
|
||||||
fMonitor.beginTask(new Path(src).lastSegment(), (int) max);
|
fMonitor.beginTask(Path.forPosix(src).lastSegment(), (int) max);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -586,15 +586,15 @@ public class RemoteResourceBrowserWidget extends Composite {
|
||||||
*/
|
*/
|
||||||
private IPath findInitialPath(String cwd, String initialPath) {
|
private IPath findInitialPath(String cwd, String initialPath) {
|
||||||
if (initialPath != null) {
|
if (initialPath != null) {
|
||||||
IPath path = new Path(initialPath);
|
IPath path = Path.forPosix(initialPath);
|
||||||
if (!path.isAbsolute()) {
|
if (!path.isAbsolute()) {
|
||||||
path = new Path(cwd).append(path);
|
path = Path.forPosix(cwd).append(path);
|
||||||
}
|
}
|
||||||
if (fFileMgr.getResource(path.toString()).fetchInfo().exists()) {
|
if (fFileMgr.getResource(path.toString()).fetchInfo().exists()) {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Path(cwd);
|
return Path.forPosix(cwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -702,7 +702,7 @@ public class RemoteResourceBrowserWidget extends Composite {
|
||||||
fRemotePathText.setText(path);
|
fRemotePathText.setText(path);
|
||||||
fRemotePathText.setSelection(fRemotePathText.getText().length());
|
fRemotePathText.setSelection(fRemotePathText.getText().length());
|
||||||
fResources.add(root);
|
fResources.add(root);
|
||||||
fRootPath = new Path(path);
|
fRootPath = Path.forPosix(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue