1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-18 22:45:23 +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) - [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) - [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) - [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; 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! if (!isBinary && fileLength > 0){ // do standard conversion if this is text!
String localEncoding = SystemEncodingUtil.getInstance().getLocalDefaultEncoding(); 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 { IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(encoding, this);
codePageConverter.convertFileFromRemoteEncoding(remotePath, localFile, encoding, localEncoding, this);
} try {
catch (RuntimeException e){ codePageConverter.convertFileFromRemoteEncoding(remotePath, localFile, encoding, localEncoding, this);
Throwable ex = e.getCause(); }
StringBuffer msgTxtBuffer = new StringBuffer(RSEServicesMessages.FILEMSG_OPERATION_FAILED); catch (RuntimeException e){
msgTxtBuffer.append('\n'); Throwable ex = e.getCause();
msgTxtBuffer.append('\n'); StringBuffer msgTxtBuffer = new StringBuffer(RSEServicesMessages.FILEMSG_OPERATION_FAILED);
msgTxtBuffer.append(remotePath); msgTxtBuffer.append('\n');
msgTxtBuffer.append('\n'); msgTxtBuffer.append('\n');
msgTxtBuffer.append(encoding); msgTxtBuffer.append(remotePath);
msgTxtBuffer.append(" -> "); msgTxtBuffer.append('\n');
msgTxtBuffer.append(localEncoding); msgTxtBuffer.append(encoding);
msgTxtBuffer.append(" -> ");
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID, msgTxtBuffer.append(localEncoding);
IDStoreMessageIds.FILEMSG_IO_ERROR,
IStatus.ERROR, msgTxtBuffer.toString(), ex); SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
throw new SystemMessageException(msg); 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! // 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 if (!isBinaries[j] && fileLength > 0){ // do standard conversion if this is text! or if the file is empty
String localEncoding = SystemEncodingUtil.getInstance().getLocalDefaultEncoding(); String localEncoding = SystemEncodingUtil.getInstance().getLocalDefaultEncoding();
IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(hostEncodings[j], this); if (!localEncoding.equals(hostEncodings[j])){
IFileServiceCodePageConverter codePageConverter = CodePageConverterManager.getCodePageConverter(hostEncodings[j], this);
try {
codePageConverter.convertFileFromRemoteEncoding(remoteElement.getName(), localFile, hostEncodings[j], localEncoding, this); try {
} codePageConverter.convertFileFromRemoteEncoding(remoteElement.getName(), localFile, hostEncodings[j], localEncoding, this);
catch (RuntimeException e){ }
Throwable ex = e.getCause(); catch (RuntimeException e){
StringBuffer msgTxtBuffer = new StringBuffer(RSEServicesMessages.FILEMSG_OPERATION_FAILED); Throwable ex = e.getCause();
msgTxtBuffer.append('\n'); StringBuffer msgTxtBuffer = new StringBuffer(RSEServicesMessages.FILEMSG_OPERATION_FAILED);
msgTxtBuffer.append('\n'); msgTxtBuffer.append('\n');
msgTxtBuffer.append(remoteFiles[j]); msgTxtBuffer.append('\n');
msgTxtBuffer.append('\n'); msgTxtBuffer.append(remoteFiles[j]);
msgTxtBuffer.append(hostEncodings[j]); msgTxtBuffer.append('\n');
msgTxtBuffer.append(" -> "); msgTxtBuffer.append(hostEncodings[j]);
msgTxtBuffer.append(localEncoding); msgTxtBuffer.append(" -> ");
msgTxtBuffer.append(localEncoding);
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IDStoreMessageIds.FILEMSG_IO_ERROR, SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
IStatus.ERROR, msgTxtBuffer.toString(), ex); IDStoreMessageIds.FILEMSG_IO_ERROR,
throw new SystemMessageException(msg); IStatus.ERROR, msgTxtBuffer.toString(), ex);
throw new SystemMessageException(msg);
}
} }
} }
} }