View | Details | Raw Unified | Return to bug 208778
Collapse All | Expand All

(-)src/org/eclipse/rse/internal/services/local/files/LocalFileService.java (-12 / +3 lines)
Lines 1641-1664 Link Here
1641
	 * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(String, String, boolean, IProgressMonitor)
1641
	 * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(String, String, boolean, IProgressMonitor)
1642
	 */
1642
	 */
1643
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException {
1643
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException {
1644
		File file = new File(remoteParent, remoteFile);
1644
		int options = isBinary ? IFileService.NONE : IFileService.TEXT_MODE;
1645
		OutputStream stream = null;
1645
		return getOutputStream(remoteParent, remoteFile, options, monitor);
1646
		
1647
		try {
1648
			stream = new FileOutputStream(file);
1649
		}
1650
		catch (Exception e) {
1651
			throw new RemoteFileIOException(e);
1652
		}
1653
		
1654
		return stream;
1655
	}	
1646
	}	
1656
	
1647
	
1657
	/*
1648
	/*
1658
	 * (non-Javadoc)
1649
	 * (non-Javadoc)
1659
	 * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, int, org.eclipse.core.runtime.IProgressMonitor)
1650
	 * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, int, org.eclipse.core.runtime.IProgressMonitor)
1660
	 */
1651
	 */
1661
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException {
1652
	public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException {
1662
		File file = new File(remoteParent, remoteFile);
1653
		File file = new File(remoteParent, remoteFile);
1663
		OutputStream stream = null;
1654
		OutputStream stream = null;
1664
		
1655
		
(-)src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java (-16 / +4 lines)
Lines 1963-1990 Link Here
1963
	 * @see org.eclipse.rse.services.files.IFileService#getOutputStream(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, boolean)
1963
	 * @see org.eclipse.rse.services.files.IFileService#getOutputStream(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, boolean)
1964
	 */
1964
	 */
1965
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException {
1965
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException {
1966
		String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
1966
		int options = isBinary ? IFileService.NONE : IFileService.TEXT_MODE;
1967
		int mode;
1967
		return getOutputStream(remoteParent, remoteFile, options, monitor);
1968
1969
		if (isBinary)
1970
		{
1971
			mode = IUniversalDataStoreConstants.BINARY_MODE;
1972
		}
1973
		else
1974
		{
1975
			mode = IUniversalDataStoreConstants.TEXT_MODE;
1976
		}
1977
		
1978
		DStoreOutputStream outputStream = new DStoreOutputStream(getDataStore(), remotePath, getEncoding(monitor), mode, unixStyle, IFileService.NONE);
1979
		return outputStream;
1980
	}
1968
	}
1981
	
1969
	
1982
1970
1983
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException {
1971
	public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException {
1984
		String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
1972
		String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
1985
		int mode;
1973
		int mode;
1986
1974
1987
		if (isBinary)
1975
		if ((options & IFileService.TEXT_MODE) == 0)
1988
		{
1976
		{
1989
			mode = IUniversalDataStoreConstants.BINARY_MODE;
1977
			mode = IUniversalDataStoreConstants.BINARY_MODE;
1990
		}
1978
		}
(-)src/org/eclipse/rse/internal/efs/RSEFileStoreImpl.java (-1 / +1 lines)
Lines 678-684 Link Here
678
				} else {
678
				} else {
679
					options = IFileService.NONE;
679
					options = IFileService.NONE;
680
				}
680
				}
681
				return subSys.getOutputStream(remoteFile.getParentPath(), remoteFile.getName(), true, options, monitor);
681
				return subSys.getOutputStream(remoteFile.getParentPath(), remoteFile.getName(), options, monitor);
682
			}
682
			}
683
			catch (SystemMessageException e) {
683
			catch (SystemMessageException e) {
684
				throw new CoreException(new Status(IStatus.ERROR,
684
				throw new CoreException(new Status(IStatus.ERROR,
(-)src/org/eclipse/rse/services/files/AbstractFileService.java (-2 / +3 lines)
Lines 215-225 Link Here
215
	 * Gets the output stream to write/append to a remote file.
215
	 * Gets the output stream to write/append to a remote file.
216
	 * The default implementation returns <code>null</code>.
216
	 * The default implementation returns <code>null</code>.
217
	 * Clients can override to return an output stream to the file.
217
	 * Clients can override to return an output stream to the file.
218
	 * @see org.eclipse.rse.services.files.IFileService#getOutputStream(String, String, boolean, int, IProgressMonitor)
218
	 * @see org.eclipse.rse.services.files.IFileService#getOutputStream(String, String, int, IProgressMonitor)
219
	 */
219
	 */
220
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException {
220
	public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException {
221
		if ((options & IFileService.APPEND) == 0) {
221
		if ((options & IFileService.APPEND) == 0) {
222
			//forward to old deprecated implementation for backward compatibility with old services
222
			//forward to old deprecated implementation for backward compatibility with old services
223
			boolean isBinary = (options & IFileService.TEXT_MODE) == 0 ? true : false;
223
			return getOutputStream(remoteParent, remoteFile, isBinary, monitor);
224
			return getOutputStream(remoteParent, remoteFile, isBinary, monitor);
224
		}
225
		}
225
		return null;
226
		return null;
(-)src/org/eclipse/rse/services/files/IFileService.java (-5 / +12 lines)
Lines 104-114 Link Here
104
	 * Options constant (value 1 &lt;&lt;0) for specifying a stream 
104
	 * Options constant (value 1 &lt;&lt;0) for specifying a stream 
105
	 * that will append data to a file.
105
	 * that will append data to a file.
106
	 * 
106
	 * 
107
	 * @see IFileService#getOutputStream(String, String, boolean, int, IProgressMonitor)
107
	 * @see IFileService#getOutputStream(String, String, int, IProgressMonitor)
108
	 */
108
	 */
109
	public static final int APPEND = 1 << 0;
109
	public static final int APPEND = 1 << 0;
110
	
110
	
111
	/**
111
	/**
112
	 * Options constant (value 2 &lt;&lt;0) for specifying that a file
113
	 * is Text instead of the default Binary.
114
	 * 
115
	 * @see IFileService#getOutputStream(String, String, int, IProgressMonitor)
116
	 */
117
	public static final int TEXT_MODE = 2 << 0;
118
	
119
	/**
112
	 * Options constant (value 0) to indicate that no bit options are set.
120
	 * Options constant (value 0) to indicate that no bit options are set.
113
	 */
121
	 */
114
	public static final int NONE = 0;
122
	public static final int NONE = 0;
Lines 470-476 Link Here
470
	 * @throws SystemMessageException if an error occurs.
478
	 * @throws SystemMessageException if an error occurs.
471
	 * @since 2.0
479
	 * @since 2.0
472
	 * @deprecated  As of 3.0M4, replaced by
480
	 * @deprecated  As of 3.0M4, replaced by
473
	 *              {@link #getOutputStream(String, String, boolean, int, IProgressMonitor)}
481
	 *              {@link #getOutputStream(String, String, int, IProgressMonitor)}
474
	 */
482
	 */
475
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException;
483
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException;
476
  
484
  
Lines 478-491 Link Here
478
	 * Gets the output stream to write/append to a remote file. Clients should close the output stream when done.
486
	 * Gets the output stream to write/append to a remote file. Clients should close the output stream when done.
479
	 * @param remoteParent the absolute path of the parent.
487
	 * @param remoteParent the absolute path of the parent.
480
	 * @param remoteFile the name of the remote file.
488
	 * @param remoteFile the name of the remote file.
481
	 * @param isBinary <code>true</code> if the file is a binary file, <code>false</code> otherwise.
489
	 * @param options bit wise or of option constants.  Valid constants are {@link IFileService#APPEND}, {@link IFileService#TEXT_MODE}, and {@link IFileService#NONE}
482
	 * @param options bit wise or of option constants.  Valid constants are {@link IFileService#APPEND} and {@link IFileService#NONE}
483
	 * @param monitor the progress monitor.
490
	 * @param monitor the progress monitor.
484
	 * @return the input stream to access the contents of the remote file.
491
	 * @return the input stream to access the contents of the remote file.
485
	 * @throws SystemMessageException if an error occurs.
492
	 * @throws SystemMessageException if an error occurs.
486
	 * @since 3.0
493
	 * @since 3.0
487
	 */
494
	 */
488
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException;
495
	public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException;
489
496
490
	/**
497
	/**
491
	 * Indicates whether this file service supports code page conversion using
498
	 * Indicates whether this file service supports code page conversion using
(-)src/org/eclipse/rse/internal/services/files/ftp/FTPService.java (-21 / +4 lines)
Lines 1627-1659 Link Here
1627
	 * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
1627
	 * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
1628
	 */
1628
	 */
1629
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException {
1629
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException {
1630
    	remoteParent = checkEncoding(remoteParent);
1630
		int options = isBinary ? IFileService.NONE : IFileService.TEXT_MODE;
1631
    	remoteFile = checkEncoding(remoteFile);
1631
    	return getOutputStream(remoteParent, remoteFile, options, monitor);
1632
				
1633
		if (monitor != null && monitor.isCanceled()){
1634
			throw new RemoteFileCancelledException();
1635
		}
1636
		
1637
		OutputStream stream = null;
1638
		
1639
		try {
1640
			FTPClient ftpClient = cloneFTPClient(isBinary);
1641
			clearCache(remoteParent);
1642
			ftpClient.changeWorkingDirectory(remoteParent);
1643
			stream = new FTPBufferedOutputStream(ftpClient.storeFileStream(remoteFile), ftpClient);
1644
		}
1645
		catch (Exception e) {
1646
			throw new RemoteFileIOException(e);
1647
		}
1648
		
1649
		return stream;
1650
	}
1632
	}
1651
	
1633
	
1652
	/*
1634
	/*
1653
	 * (non-Javadoc)
1635
	 * (non-Javadoc)
1654
	 * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, int, org.eclipse.core.runtime.IProgressMonitor)
1636
	 * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, int, org.eclipse.core.runtime.IProgressMonitor)
1655
	 */
1637
	 */
1656
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException {
1638
	public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException {
1657
    	remoteParent = checkEncoding(remoteParent);
1639
    	remoteParent = checkEncoding(remoteParent);
1658
    	remoteFile = checkEncoding(remoteFile);
1640
    	remoteFile = checkEncoding(remoteFile);
1659
				
1641
				
Lines 1664-1669 Link Here
1664
		OutputStream stream = null;
1646
		OutputStream stream = null;
1665
		
1647
		
1666
		try {
1648
		try {
1649
			boolean isBinary = (options & IFileService.TEXT_MODE) == 0 ? true : false;
1667
			FTPClient ftpClient = cloneFTPClient(isBinary);
1650
			FTPClient ftpClient = cloneFTPClient(isBinary);
1668
			clearCache(remoteParent);
1651
			clearCache(remoteParent);
1669
			ftpClient.changeWorkingDirectory(remoteParent);
1652
			ftpClient.changeWorkingDirectory(remoteParent);
(-)src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFileSubSystem.java (-4 / +3 lines)
Lines 660-666 Link Here
660
	 * @throws SystemMessageException if an error occurs.
660
	 * @throws SystemMessageException if an error occurs.
661
	 * @since 2.0
661
	 * @since 2.0
662
	 * @deprecated  As of 3.0M4, replaced by
662
	 * @deprecated  As of 3.0M4, replaced by
663
	 *              {@link #getOutputStream(String, String, boolean, int, IProgressMonitor)}
663
	 *              {@link #getOutputStream(String, String, boolean, IProgressMonitor)}
664
	 */
664
	 */
665
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException;
665
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException;
666
666
Lines 668-681 Link Here
668
	 * Gets the output stream to write/append to a remote file. Clients should close the output stream when done. Implementations should not return <code>null</code>.
668
	 * Gets the output stream to write/append to a remote file. Clients should close the output stream when done. Implementations should not return <code>null</code>.
669
	 * @param remoteParent the absolute path of the parent.
669
	 * @param remoteParent the absolute path of the parent.
670
	 * @param remoteFile the name of the remote file.
670
	 * @param remoteFile the name of the remote file.
671
	 * @param isBinary <code>true</code> if the file is a binary file, <code>false</code> otherwise.
671
	 * @param options bit wise or of option constants.  Valid constants are {@link IFileService#APPEND}, {@link IFileService#TEXT_MODE}, and {@link IFileService#NONE}
672
	 * @param options bit wise or of option constants.  Valid constants are {@link IFileService#APPEND} and {@link IFileService#NONE}
673
	 * @return the input stream to access the contents of the remote file.
672
	 * @return the input stream to access the contents of the remote file.
674
	 * @param monitor the progress monitor.
673
	 * @param monitor the progress monitor.
675
	 * @throws SystemMessageException if an error occurs.
674
	 * @throws SystemMessageException if an error occurs.
676
	 * @since 3.0
675
	 * @since 3.0
677
	 */
676
	 */
678
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException;
677
	public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException;
679
678
680
	/**
679
	/**
681
	 * Indicates whether this file subsystem supports code page conversion using
680
	 * Indicates whether this file subsystem supports code page conversion using
(-)src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java (-2 / +2 lines)
Lines 1030-1037 Link Here
1030
		return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, isBinary, monitor), remoteParent, remoteFile, this);			
1030
		return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, isBinary, monitor), remoteParent, remoteFile, this);			
1031
	}
1031
	}
1032
1032
1033
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException {
1033
	public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException {
1034
		return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, isBinary, options, monitor), remoteParent, remoteFile, this);			
1034
		return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, options, monitor), remoteParent, remoteFile, this);			
1035
	}
1035
	}
1036
	
1036
	
1037
	/**
1037
	/**
(-)src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java (-31 / +4 lines)
Lines 1031-1038 Link Here
1031
				if (permNew != permOld) {
1031
				if (permNew != permOld) {
1032
					//getChannel("SftpFileService.setReadOnly").chmod(permNew, path); //$NON-NLS-1$
1032
					//getChannel("SftpFileService.setReadOnly").chmod(permNew, path); //$NON-NLS-1$
1033
					attr.setPERMISSIONS(permNew); 
1033
					attr.setPERMISSIONS(permNew); 
1034
					getChannel("SftpFileService.setReadOnly").setStat(recode(path), attr); //$NON-NLS-1$
1034
					getChannel("SftpFileService.setReadOnly").setStat(recode(path), attr); //$NON-NLS-1$					ok=true;
1035
					ok=true;
1036
					Activator.trace("SftpFileService.setReadOnly ok"); //$NON-NLS-1$
1035
					Activator.trace("SftpFileService.setReadOnly ok"); //$NON-NLS-1$
1037
				} else {
1036
				} else {
1038
					ok=true;
1037
					ok=true;
Lines 1080-1120 Link Here
1080
	 * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(String, String, boolean, IProgressMonitor)
1079
	 * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(String, String, boolean, IProgressMonitor)
1081
	 */
1080
	 */
1082
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException {
1081
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException {
1083
		
1082
		int options = isBinary ? IFileService.NONE : IFileService.TEXT_MODE;
1084
		if (monitor == null) {
1083
		return getOutputStream(remoteParent, remoteFile, options, monitor);
1085
			monitor = new NullProgressMonitor();
1086
		}
1087
		
1088
		OutputStream stream = null;
1089
		String dst = remoteParent;
1090
		if (remoteFile!=null) {
1091
			dst = concat(remoteParent, remoteFile);
1092
		}
1093
		
1094
		try {
1095
			SftpProgressMonitor sftpMonitor = new MyProgressMonitor(monitor);
1096
			int mode = ChannelSftp.OVERWRITE;
1097
			getChannel("SftpFileService.getOutputStream " + remoteFile); //check the session is healthy //$NON-NLS-1$
1098
			ChannelSftp channel = (ChannelSftp)fSessionProvider.getSession().openChannel("sftp"); //$NON-NLS-1$
1099
		    channel.connect();
1100
			stream = new SftpBufferedOutputStream(channel.put(recodeSafe(dst), sftpMonitor, mode), channel); 
1101
			Activator.trace("SftpFileService.getOutputStream " + remoteFile + " ok"); //$NON-NLS-1$ //$NON-NLS-2$
1102
		}
1103
		catch (Exception e) {
1104
			Activator.trace("SftpFileService.getOutputStream " + dst + " failed: " + e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
1105
			throw makeSystemMessageException(e);
1106
		}
1107
		if (monitor.isCanceled()) {
1108
			throw new RemoteFileCancelledException();
1109
		}
1110
		return stream;
1111
	}
1084
	}
1112
	
1085
	
1113
	/*
1086
	/*
1114
	 * (non-Javadoc)
1087
	 * (non-Javadoc)
1115
	 * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, int, org.eclipse.core.runtime.IProgressMonitor)
1088
	 * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, int, org.eclipse.core.runtime.IProgressMonitor)
1116
	 */
1089
	 */
1117
	public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException {
1090
	public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException {
1118
		
1091
		
1119
		if (monitor == null) {
1092
		if (monitor == null) {
1120
			monitor = new NullProgressMonitor();
1093
			monitor = new NullProgressMonitor();

Return to bug 208778