1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-02 14:45:25 +02:00

[365780] [dstore] codepage conversion should only occur for different encodings

This commit is contained in:
David McKnight 2011-12-06 18:03:40 +00:00
parent a0429d8147
commit 2f4cea89e5

View file

@ -64,6 +64,7 @@
* David McKnight (IBM) - [298440] jar files in a directory can't be pasted to another system properly
* David McKnight (IBM) - [308770] [dstore] Remote Search using old server fails with NPE
* David McKnight (IBM) - [339548] [dstore] shouldn't attempt file conversion on empty files
* David McKnight (IBM) - [365780] [dstore] codepage conversion should only occur for different encodings
*******************************************************************************/
package org.eclipse.rse.internal.services.dstore.files;
@ -842,26 +843,29 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
if (!isBinary && fileLength > 0){ // do standard conversion if this is text!
String localEncoding = SystemEncodingUtil.getInstance().getLocalDefaultEncoding();
IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(encoding, this);
if (!localEncoding.equals(encoding)) {// only do conversion if the encodings are different and the length is non-zero
try {
codePageConverter.convertFileFromRemoteEncoding(remotePath, localFile, encoding, localEncoding, this);
}
catch (RuntimeException e){
Throwable ex = e.getCause();
StringBuffer msgTxtBuffer = new StringBuffer(RSEServicesMessages.FILEMSG_OPERATION_FAILED);
msgTxtBuffer.append('\n');
msgTxtBuffer.append('\n');
msgTxtBuffer.append(remotePath);
msgTxtBuffer.append('\n');
msgTxtBuffer.append(encoding);
msgTxtBuffer.append(" -> ");
msgTxtBuffer.append(localEncoding);
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IDStoreMessageIds.FILEMSG_IO_ERROR,
IStatus.ERROR, msgTxtBuffer.toString(), ex);
throw new SystemMessageException(msg);
IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(encoding, this);
try {
codePageConverter.convertFileFromRemoteEncoding(remotePath, localFile, encoding, localEncoding, this);
}
catch (RuntimeException e){
Throwable ex = e.getCause();
StringBuffer msgTxtBuffer = new StringBuffer(RSEServicesMessages.FILEMSG_OPERATION_FAILED);
msgTxtBuffer.append('\n');
msgTxtBuffer.append('\n');
msgTxtBuffer.append(remotePath);
msgTxtBuffer.append('\n');
msgTxtBuffer.append(encoding);
msgTxtBuffer.append(" -> ");
msgTxtBuffer.append(localEncoding);
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IDStoreMessageIds.FILEMSG_IO_ERROR,
IStatus.ERROR, msgTxtBuffer.toString(), ex);
throw new SystemMessageException(msg);
}
}
}
}
@ -1092,26 +1096,28 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
// do standard conversion if this is text!
if (!isBinaries[j] && fileLength > 0){ // do standard conversion if this is text! or if the file is empty
String localEncoding = SystemEncodingUtil.getInstance().getLocalDefaultEncoding();
IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(hostEncodings[j], this);
try {
codePageConverter.convertFileFromRemoteEncoding(remoteElement.getName(), localFile, hostEncodings[j], localEncoding, this);
}
catch (RuntimeException e){
Throwable ex = e.getCause();
StringBuffer msgTxtBuffer = new StringBuffer(RSEServicesMessages.FILEMSG_OPERATION_FAILED);
msgTxtBuffer.append('\n');
msgTxtBuffer.append('\n');
msgTxtBuffer.append(remoteFiles[j]);
msgTxtBuffer.append('\n');
msgTxtBuffer.append(hostEncodings[j]);
msgTxtBuffer.append(" -> ");
msgTxtBuffer.append(localEncoding);
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IDStoreMessageIds.FILEMSG_IO_ERROR,
IStatus.ERROR, msgTxtBuffer.toString(), ex);
throw new SystemMessageException(msg);
if (!localEncoding.equals(hostEncodings[j])){
IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(hostEncodings[j], this);
try {
codePageConverter.convertFileFromRemoteEncoding(remoteElement.getName(), localFile, hostEncodings[j], localEncoding, this);
}
catch (RuntimeException e){
Throwable ex = e.getCause();
StringBuffer msgTxtBuffer = new StringBuffer(RSEServicesMessages.FILEMSG_OPERATION_FAILED);
msgTxtBuffer.append('\n');
msgTxtBuffer.append('\n');
msgTxtBuffer.append(remoteFiles[j]);
msgTxtBuffer.append('\n');
msgTxtBuffer.append(hostEncodings[j]);
msgTxtBuffer.append(" -> ");
msgTxtBuffer.append(localEncoding);
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IDStoreMessageIds.FILEMSG_IO_ERROR,
IStatus.ERROR, msgTxtBuffer.toString(), ex);
throw new SystemMessageException(msg);
}
}
}
}