1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 07:05:24 +02:00

Bug 236334 - [ssh][encodings] Cannot copy files or folders with turkish or arabic names

This commit is contained in:
Martin Oberhuber 2010-11-25 09:07:49 +00:00
parent 2ac14ae969
commit 1fefdf21dc

View file

@ -1070,7 +1070,20 @@ public class SftpFileService extends AbstractFileService implements ISshService,
Channel channel = null;
try {
channel=fSessionProvider.getSession().openChannel("exec"); //$NON-NLS-1$
((ChannelExec)channel).setCommand(command);
try {
// ChannelExec#setCommand(byte[]) was added in JSch-0.1.38 only
((ChannelExec) channel).setCommand(command.getBytes(fJSchChannelEncoding));
} catch (NoSuchMethodError nsm) {
// Fallback for JSch-0.1.37 and below: always decodes in
// Platform Default Encoding!
byte[] bytesDesired = command.getBytes(fJSchChannelEncoding);
String stringToSend = new String(bytesDesired);
byte[] bytesSent = stringToSend.getBytes();
if (!bytesDesired.equals(bytesSent)) {
throw new UnsupportedEncodingException("Cannot encode for JSch as \"" + fJSchChannelEncoding + "\": " + command);
}
((ChannelExec) channel).setCommand(new String(bytesDesired));
}
//No user input
channel.setInputStream(null);