1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-01 21:35:40 +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:
Greg Watson 2015-04-06 15:51:48 -04:00
parent 9825f0f0cb
commit 76feaed504
7 changed files with 38 additions and 38 deletions

View file

@ -18,9 +18,9 @@ import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteConnection.Service;
import org.eclipse.remote.core.IRemoteFileService;
import org.eclipse.remote.core.IRemoteProcessService;
import org.eclipse.remote.core.IRemoteConnection.Service;
public class LocalFileService implements IRemoteFileService {
@ -53,7 +53,7 @@ public class LocalFileService implements IRemoteFileService {
@Override
public IFileStore getResource(String path) {
return EFS.getLocalFileSystem().getStore(new Path(path));
return EFS.getLocalFileSystem().getStore(Path.fromOSString(path));
}
@Override

View file

@ -70,7 +70,7 @@ public class LocalProcessBuilder extends AbstractRemoteProcessBuilder {
if (dir == null) {
String userDir = System.getProperty("user.dir"); //$NON-NLS-1$
if (userDir != null) {
dir = EFS.getLocalFileSystem().getStore(new Path(userDir));
dir = EFS.getLocalFileSystem().getStore(Path.fromOSString(userDir));
directory(dir);
}
}

View file

@ -980,7 +980,7 @@ public class JSchConnection implements IRemoteConnectionControlService, IRemoteC
*/
@Override
public void setWorkingDirectory(String path) {
if (new Path(path).isAbsolute()) {
if (Path.forPosix(path).isAbsolute()) {
fWorkingDir = path;
}
}

View file

@ -16,9 +16,9 @@ import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.remote.core.IRemoteConnection;
import org.eclipse.remote.core.IRemoteConnection.Service;
import org.eclipse.remote.core.IRemoteFileService;
import org.eclipse.remote.core.IRemoteProcessService;
import org.eclipse.remote.core.IRemoteConnection.Service;
public class JSchFileManager implements IRemoteFileService {
@ -51,9 +51,9 @@ public class JSchFileManager implements IRemoteFileService {
@Override
public IFileStore getResource(String pathStr) {
IPath path = new Path(pathStr);
IPath path = Path.forPosix(pathStr);
if (!path.isAbsolute()) {
path = new Path(getBaseDirectory()).append(path);
path = Path.forPosix(getBaseDirectory()).append(path);
}
return JschFileStore.getInstance(JSchFileSystem.getURIFor(fConnection.getName(), path.toString()));
}
@ -84,7 +84,7 @@ public class JSchFileManager implements IRemoteFileService {
@Override
public URI toURI(String path) {
return toURI(new Path(path));
return toURI(Path.forPosix(path));
}
}

View file

@ -68,7 +68,7 @@ public class JschFileStore extends FileStore {
private JschFileStore(URI uri) {
fURI = uri;
fRemotePath = new Path(uri.getPath());
fRemotePath = Path.forPosix(uri.getPath());
}
private JSchConnection checkConnection(IProgressMonitor monitor) throws RemoteConnectionException {
@ -224,8 +224,8 @@ public class JschFileStore extends FileStore {
if ((options & EFS.SHALLOW) == EFS.SHALLOW) {
IFileStore parent = getParent();
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(
Messages.JschFileStore_The_parent_of_directory_does_not_exist, fRemotePath.toString()), null));
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRITE,
NLS.bind(Messages.JschFileStore_The_parent_of_directory_does_not_exist, fRemotePath.toString()), null));
}
if (subMon.isCanceled()) {
return this;
@ -245,8 +245,8 @@ public class JschFileStore extends FileStore {
IFileInfo info = fetchInfo(EFS.NONE, subMon.newChild(10));
if (!subMon.isCanceled()) {
if (!info.exists()) {
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRITE, NLS.bind(
Messages.JschFileStore_The_directory_could_not_be_created, fRemotePath.toString()), null));
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRITE,
NLS.bind(Messages.JschFileStore_The_directory_could_not_be_created, fRemotePath.toString()), null));
}
if (!info.isDirectory()) {
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));
if (!subMon.isCanceled()) {
if (!info.exists()) {
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_READ, NLS.bind(
Messages.JschFileStore_File_doesnt_exist, fRemotePath.toString()), null));
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_READ,
NLS.bind(Messages.JschFileStore_File_doesnt_exist, fRemotePath.toString()), null));
}
if (info.isDirectory()) {
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRONG_TYPE, NLS.bind(
Messages.JschFileStore_Is_a_directory, fRemotePath.toString()), null));
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRONG_TYPE,
NLS.bind(Messages.JschFileStore_Is_a_directory, fRemotePath.toString()), null));
}
GetInputStreamCommand command = new GetInputStreamCommand(connection, fRemotePath);
return command.getResult(subMon.newChild(10));
@ -297,8 +297,8 @@ public class JschFileStore extends FileStore {
IFileInfo info = fetchInfo(EFS.NONE, subMon.newChild(9));
if (!subMon.isCanceled()) {
if (info.isDirectory()) {
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRONG_TYPE, NLS.bind(
Messages.JschFileStore_Is_a_directory, fRemotePath.toString()), null));
throw new CoreException(new Status(IStatus.ERROR, Activator.getUniqueIdentifier(), EFS.ERROR_WRONG_TYPE,
NLS.bind(Messages.JschFileStore_Is_a_directory, fRemotePath.toString()), null));
}
GetOutputStreamCommand command = new GetOutputStreamCommand(connection, options, fRemotePath);
return command.getResult(subMon.newChild(10));

View file

@ -83,8 +83,8 @@ public abstract class AbstractRemoteCommand<T> {
taskName.append(MessageFormat.format(Messages.AbstractRemoteCommand_format1, new Object[] { workToDate, size }));
} else {
Double workPercent = new Double(fWorkPercentFactor * fWorkToDate);
taskName.append(MessageFormat.format(Messages.AbstractRemoteCommand_format2, new Object[] { workToDate, size,
fMaxWork, fMaxWorkSize, workPercent }));
taskName.append(MessageFormat.format(Messages.AbstractRemoteCommand_format2,
new Object[] { workToDate, size, fMaxWork, fMaxWorkSize, workPercent }));
}
fMonitor.subTask(taskName.toString());
fMonitor.worked((int) count);
@ -107,7 +107,7 @@ public abstract class AbstractRemoteCommand<T> {
fMaxWork = max / 1024L;
}
fWorkToDate = 0;
fMonitor.beginTask(new Path(src).lastSegment(), (int) max);
fMonitor.beginTask(Path.forPosix(src).lastSegment(), (int) max);
}
}

View file

@ -528,19 +528,19 @@ public class RemoteResourceBrowserWidget extends Composite {
public void run() {
DelayedInputDialog dialog = new DelayedInputDialog(getShell(), Messages.RemoteResourceBrowserWidget_1,
Messages.RemoteResourceBrowserWidget_2, basePath.getName(), new IInputValidator() {
@Override
public String isValid(String newText) {
if (!newText.equals("")) { //$NON-NLS-1$
IFileStore newPath = path.getChild(newText);
if (newPath.fetchInfo().exists()) {
return Messages.RemoteResourceBrowserWidget_3;
}
} else {
return Messages.RemoteResourceBrowserWidget_4;
}
return null;
@Override
public String isValid(String newText) {
if (!newText.equals("")) { //$NON-NLS-1$
IFileStore newPath = path.getChild(newText);
if (newPath.fetchInfo().exists()) {
return Messages.RemoteResourceBrowserWidget_3;
}
});
} else {
return Messages.RemoteResourceBrowserWidget_4;
}
return null;
}
});
fValidateJob.setDialog(dialog);
if (dialog.open() == Dialog.OK) {
userPath[0] = dialog.getValue();
@ -586,15 +586,15 @@ public class RemoteResourceBrowserWidget extends Composite {
*/
private IPath findInitialPath(String cwd, String initialPath) {
if (initialPath != null) {
IPath path = new Path(initialPath);
IPath path = Path.forPosix(initialPath);
if (!path.isAbsolute()) {
path = new Path(cwd).append(path);
path = Path.forPosix(cwd).append(path);
}
if (fFileMgr.getResource(path.toString()).fetchInfo().exists()) {
return path;
}
}
return new Path(cwd);
return Path.forPosix(cwd);
}
/**
@ -702,7 +702,7 @@ public class RemoteResourceBrowserWidget extends Composite {
fRemotePathText.setText(path);
fRemotePathText.setSelection(fRemotePathText.getText().length());
fResources.add(root);
fRootPath = new Path(path);
fRootPath = Path.forPosix(path);
}
}