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:
parent
a0429d8147
commit
2f4cea89e5
1 changed files with 45 additions and 39 deletions
|
@ -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);
|
|
||||||
}
|
|
||||||
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,
|
try {
|
||||||
IDStoreMessageIds.FILEMSG_IO_ERROR,
|
codePageConverter.convertFileFromRemoteEncoding(remotePath, localFile, encoding, localEncoding, this);
|
||||||
IStatus.ERROR, msgTxtBuffer.toString(), ex);
|
}
|
||||||
throw new SystemMessageException(msg);
|
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!
|
// 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 {
|
try {
|
||||||
codePageConverter.convertFileFromRemoteEncoding(remoteElement.getName(), localFile, hostEncodings[j], localEncoding, this);
|
codePageConverter.convertFileFromRemoteEncoding(remoteElement.getName(), localFile, hostEncodings[j], localEncoding, this);
|
||||||
}
|
}
|
||||||
catch (RuntimeException e){
|
catch (RuntimeException e){
|
||||||
Throwable ex = e.getCause();
|
Throwable ex = e.getCause();
|
||||||
StringBuffer msgTxtBuffer = new StringBuffer(RSEServicesMessages.FILEMSG_OPERATION_FAILED);
|
StringBuffer msgTxtBuffer = new StringBuffer(RSEServicesMessages.FILEMSG_OPERATION_FAILED);
|
||||||
msgTxtBuffer.append('\n');
|
msgTxtBuffer.append('\n');
|
||||||
msgTxtBuffer.append('\n');
|
msgTxtBuffer.append('\n');
|
||||||
msgTxtBuffer.append(remoteFiles[j]);
|
msgTxtBuffer.append(remoteFiles[j]);
|
||||||
msgTxtBuffer.append('\n');
|
msgTxtBuffer.append('\n');
|
||||||
msgTxtBuffer.append(hostEncodings[j]);
|
msgTxtBuffer.append(hostEncodings[j]);
|
||||||
msgTxtBuffer.append(" -> ");
|
msgTxtBuffer.append(" -> ");
|
||||||
msgTxtBuffer.append(localEncoding);
|
msgTxtBuffer.append(localEncoding);
|
||||||
|
|
||||||
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
SystemMessage msg = new SimpleSystemMessage(Activator.PLUGIN_ID,
|
||||||
IDStoreMessageIds.FILEMSG_IO_ERROR,
|
IDStoreMessageIds.FILEMSG_IO_ERROR,
|
||||||
IStatus.ERROR, msgTxtBuffer.toString(), ex);
|
IStatus.ERROR, msgTxtBuffer.toString(), ex);
|
||||||
throw new SystemMessageException(msg);
|
throw new SystemMessageException(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue