mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-15 13:05:22 +02:00
[189352] [dnd] Copy & Paste transfers binary although text mode specified
This commit is contained in:
parent
30d5479e4f
commit
fb3d2aed9f
2 changed files with 54 additions and 8 deletions
|
@ -14,6 +14,7 @@
|
||||||
* Kevin Doyle (IBM) - Fix 183870 - Display File Exists Error
|
* Kevin Doyle (IBM) - Fix 183870 - Display File Exists Error
|
||||||
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
* Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API
|
||||||
* Xuan Chen (IBM) - [189681] [dstore][linux] Refresh Folder in My Home messes up Refresh in Root
|
* Xuan Chen (IBM) - [189681] [dstore][linux] Refresh Folder in My Home messes up Refresh in Root
|
||||||
|
* Kushal Munir (IBM) - [189352] Replace with appropriate line end character on upload
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.internal.services.dstore.files;
|
package org.eclipse.rse.internal.services.dstore.files;
|
||||||
|
@ -71,6 +72,8 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
protected ISystemFileTypes _fileTypeRegistry;
|
protected ISystemFileTypes _fileTypeRegistry;
|
||||||
private String remoteEncoding;
|
private String remoteEncoding;
|
||||||
|
|
||||||
|
protected boolean unixStyle = false;
|
||||||
|
|
||||||
private static String _percentMsg = SystemMessage.sub(SystemMessage.sub(SystemMessage.sub(ServiceResources.DStore_Service_Percent_Complete_Message, "&0", "{0}"), "&1", "{1}"), "&2", "{2}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
|
private static String _percentMsg = SystemMessage.sub(SystemMessage.sub(SystemMessage.sub(ServiceResources.DStore_Service_Percent_Complete_Message, "&0", "{0}"), "&1", "{1}"), "&2", "{2}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
|
||||||
|
|
||||||
private static String[] _filterAttributes = {
|
private static String[] _filterAttributes = {
|
||||||
|
@ -392,6 +395,18 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
|
|
||||||
long totalSent = 0;
|
long totalSent = 0;
|
||||||
|
|
||||||
|
// line separator of local machine
|
||||||
|
String localLineSep = System.getProperty("line.separator"); //$NON-NLS-1$
|
||||||
|
|
||||||
|
// line separator of remote machine
|
||||||
|
String targetLineSep = "\n"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
if (!unixStyle) {
|
||||||
|
targetLineSep = "\r\n"; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
int localLineSepLength = localLineSep.length();
|
||||||
|
|
||||||
// upload bytes while available
|
// upload bytes while available
|
||||||
while (available > 0 && !isCancelled)
|
while (available > 0 && !isCancelled)
|
||||||
{
|
{
|
||||||
|
@ -412,11 +427,34 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
{
|
{
|
||||||
String tempStr = new String(buffer, 0, bytesRead, srcEncoding);
|
String tempStr = new String(buffer, 0, bytesRead, srcEncoding);
|
||||||
|
|
||||||
// hack for zOS - \r causes problems for compilers
|
// if the line end characters of the local and remote machines are different, we need to replace them
|
||||||
// if (osName != null && (osName.startsWith("z") || osName.equalsIgnoreCase("aix")))
|
if (!localLineSep.equals(targetLineSep)) {
|
||||||
// {
|
|
||||||
// tempStr = tempStr.replace('\r', ' ');
|
int index = tempStr.indexOf(localLineSep);
|
||||||
// }
|
|
||||||
|
StringBuffer buf = new StringBuffer();
|
||||||
|
|
||||||
|
boolean lineEndFound = false;
|
||||||
|
int lastIndex = 0;
|
||||||
|
|
||||||
|
while (index != -1) {
|
||||||
|
buf = buf.append(tempStr.substring(lastIndex, index));
|
||||||
|
buf = buf.append(targetLineSep);
|
||||||
|
|
||||||
|
if (!lineEndFound) {
|
||||||
|
lineEndFound = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastIndex = index+localLineSepLength;
|
||||||
|
|
||||||
|
index = tempStr.indexOf(localLineSep, lastIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lineEndFound) {
|
||||||
|
buf = buf.append(tempStr.substring(lastIndex));
|
||||||
|
tempStr = buf.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
convBytes = tempStr.getBytes(hostEncoding);
|
convBytes = tempStr.getBytes(hostEncoding);
|
||||||
|
|
||||||
|
@ -466,9 +504,6 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
String str = MessageFormat.format(_percentMsg, new Object[] {totalSentBuf, totalBuf, percentBuf});
|
String str = MessageFormat.format(_percentMsg, new Object[] {totalSentBuf, totalBuf, percentBuf});
|
||||||
monitor.subTask(str);
|
monitor.subTask(str);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
isCancelled = monitor.isCanceled();
|
isCancelled = monitor.isCanceled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1347,4 +1382,13 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
DStoreOutputStream outputStream = new DStoreOutputStream(getDataStore(), remotePath, getEncoding(monitor), mode);
|
DStoreOutputStream outputStream = new DStoreOutputStream(getDataStore(), remotePath, getEncoding(monitor), mode);
|
||||||
return outputStream;
|
return outputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether this is a Unix-style file system or a Windows-style file system. The
|
||||||
|
* default is Windows if this is not called. The creator of this class should call this to set the type of the file system.
|
||||||
|
* @param isUnixStyle <code>true<code> if this is a Unix-style file system, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
public void setIsUnixStyle(boolean isUnixStyle) {
|
||||||
|
this.unixStyle = isUnixStyle;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -13,6 +13,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
|
* Martin Oberhuber (Wind River) - [177523] Unify singleton getter methods
|
||||||
|
* Kushal Munir (IBM) - [189352] Set whether file service is Unix-style system or not
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.rse.subsystems.files.dstore;
|
package org.eclipse.rse.subsystems.files.dstore;
|
||||||
|
@ -134,6 +135,7 @@ public class DStoreFileSubSystemConfiguration extends FileServiceSubSystemConfig
|
||||||
{
|
{
|
||||||
DStoreConnectorService connectorService = (DStoreConnectorService)getConnectorService(host);
|
DStoreConnectorService connectorService = (DStoreConnectorService)getConnectorService(host);
|
||||||
DStoreFileService service = new DStoreFileService(connectorService, SystemFileTransferModeRegistry.getInstance(), RSEUIPlugin.getDefault());
|
DStoreFileService service = new DStoreFileService(connectorService, SystemFileTransferModeRegistry.getInstance(), RSEUIPlugin.getDefault());
|
||||||
|
service.setIsUnixStyle(isUnixStyle());
|
||||||
|
|
||||||
IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore();
|
IPreferenceStore store= RSEUIPlugin.getDefault().getPreferenceStore();
|
||||||
int downloadBufferSize = store.getInt(ISystemFilePreferencesConstants.DOWNLOAD_BUFFER_SIZE);
|
int downloadBufferSize = store.getInt(ISystemFilePreferencesConstants.DOWNLOAD_BUFFER_SIZE);
|
||||||
|
|
Loading…
Add table
Reference in a new issue