diff --git a/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/RSEFileStoreImpl.java b/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/RSEFileStoreImpl.java
index be8e0198880..f9019734474 100644
--- a/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/RSEFileStoreImpl.java
+++ b/rse/plugins/org.eclipse.rse.efs/src/org/eclipse/rse/internal/efs/RSEFileStoreImpl.java
@@ -650,7 +650,6 @@ public class RSEFileStoreImpl extends FileStore
* @see org.eclipse.core.filesystem.IFileStore#openOutputStream(int, org.eclipse.core.runtime.IProgressMonitor)
*/
public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException {
- boolean append = (options & EFS.APPEND) != 0;
cacheRemoteFile(null);
IRemoteFile remoteFile = getRemoteFileObject(monitor, false);
if (remoteFile==null) {
@@ -673,7 +672,13 @@ public class RSEFileStoreImpl extends FileStore
if (remoteFile.isFile()) {
try {
- return subSys.getOutputStream(remoteFile.getParentPath(), remoteFile.getName(), true, append, monitor);
+ // Convert from EFS option constants to IFileService option constants
+ if ((options & EFS.APPEND) != 0) {
+ options = IFileService.APPEND;
+ } else {
+ options = IFileService.NONE;
+ }
+ return subSys.getOutputStream(remoteFile.getParentPath(), remoteFile.getName(), true, options, monitor);
}
catch (SystemMessageException e) {
throw new CoreException(new Status(IStatus.ERROR,
diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java
index abd30959afc..b990adb37b8 100644
--- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java
+++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java
@@ -1978,12 +1978,12 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
mode = IUniversalDataStoreConstants.TEXT_MODE;
}
- DStoreOutputStream outputStream = new DStoreOutputStream(getDataStore(), remotePath, getEncoding(monitor), mode, unixStyle, false);
+ DStoreOutputStream outputStream = new DStoreOutputStream(getDataStore(), remotePath, getEncoding(monitor), mode, unixStyle, IFileService.NONE);
return outputStream;
}
- public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, boolean append, IProgressMonitor monitor) throws SystemMessageException {
+ public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException {
String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
int mode;
@@ -1996,7 +1996,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
mode = IUniversalDataStoreConstants.TEXT_MODE;
}
- DStoreOutputStream outputStream = new DStoreOutputStream(getDataStore(), remotePath, getEncoding(monitor), mode, unixStyle, append);
+ DStoreOutputStream outputStream = new DStoreOutputStream(getDataStore(), remotePath, getEncoding(monitor), mode, unixStyle, options);
return outputStream;
}
diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreOutputStream.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreOutputStream.java
index eeb2071d413..cc9a6fdfb76 100644
--- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreOutputStream.java
+++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreOutputStream.java
@@ -19,6 +19,7 @@ import java.io.OutputStream;
import org.eclipse.dstore.core.model.DataStore;
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
import org.eclipse.rse.dstore.universal.miners.UniversalByteStreamHandler;
+import org.eclipse.rse.services.files.IFileService;
public class DStoreOutputStream extends OutputStream
{
@@ -27,13 +28,13 @@ public class DStoreOutputStream extends OutputStream
private String _encoding;
private int _mode;
private boolean _firstWrite = true;
- private boolean _append;
+ private int _options;
private String _byteStreamHandlerId;
private String _localLineSep;
private String _targetLineSep;
private int _localLineSepLength;
- public DStoreOutputStream(DataStore dataStore, String remotePath, String encoding, int mode, boolean unixStyle, boolean append)
+ public DStoreOutputStream(DataStore dataStore, String remotePath, String encoding, int mode, boolean unixStyle, int options)
{
_dataStore = dataStore;
_remotePath = remotePath;
@@ -52,7 +53,7 @@ public class DStoreOutputStream extends OutputStream
}
_localLineSepLength = _localLineSep.length();
- _append = append;
+ _options = options;
}
public void close() throws IOException
@@ -78,7 +79,7 @@ public class DStoreOutputStream extends OutputStream
b = tempStr.getBytes(_encoding);
}
- if (_firstWrite && !_append)
+ if (_firstWrite && (_options & IFileService.APPEND) == 0)
{
_firstWrite = false;
@@ -134,7 +135,7 @@ public class DStoreOutputStream extends OutputStream
b = tempStr.getBytes(_encoding);
}
- if (_firstWrite && !_append)
+ if (_firstWrite && (_options & IFileService.APPEND) == 0)
{
_firstWrite = false;
// send first set of bytes
@@ -156,7 +157,7 @@ public class DStoreOutputStream extends OutputStream
String tempStr = new String(b, 0, 1);
b = tempStr.getBytes(_encoding);
}
- if (_firstWrite && !_append)
+ if (_firstWrite && (_options & IFileService.APPEND) == 0)
{
_firstWrite = false;
// send first set of bytes
diff --git a/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/internal/services/files/ftp/FTPService.java b/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/internal/services/files/ftp/FTPService.java
index c84c84ed21c..f0a8d1cb5b1 100644
--- a/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/internal/services/files/ftp/FTPService.java
+++ b/rse/plugins/org.eclipse.rse.services.files.ftp/src/org/eclipse/rse/internal/services/files/ftp/FTPService.java
@@ -1651,9 +1651,9 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
/*
* (non-Javadoc)
- * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, int, org.eclipse.core.runtime.IProgressMonitor)
*/
- public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, boolean append, IProgressMonitor monitor) throws SystemMessageException {
+ public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException {
remoteParent = checkEncoding(remoteParent);
remoteFile = checkEncoding(remoteFile);
@@ -1667,7 +1667,7 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
FTPClient ftpClient = cloneFTPClient(isBinary);
clearCache(remoteParent);
ftpClient.changeWorkingDirectory(remoteParent);
- if (!append){
+ if ((options & IFileService.APPEND) == 0){
stream = new FTPBufferedOutputStream(ftpClient.storeFileStream(remoteFile), ftpClient);
} else {
stream = new FTPBufferedOutputStream(ftpClient.appendFileStream(remoteFile), ftpClient);
diff --git a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java
index 13d2626b426..3915bf5f9fb 100644
--- a/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java
+++ b/rse/plugins/org.eclipse.rse.services.local/src/org/eclipse/rse/internal/services/local/files/LocalFileService.java
@@ -1656,14 +1656,14 @@ public class LocalFileService extends AbstractFileService implements IFileServic
/*
* (non-Javadoc)
- * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, int, org.eclipse.core.runtime.IProgressMonitor)
*/
- public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, boolean append, IProgressMonitor monitor) throws SystemMessageException {
+ public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException {
File file = new File(remoteParent, remoteFile);
OutputStream stream = null;
try {
- if (!append) {
+ if ((options & IFileService.APPEND) == 0) {
stream = new FileOutputStream(file);
} else {
stream = new FileOutputStream(file, true);
diff --git a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java
index d7438b75af7..30dd6419c80 100644
--- a/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java
+++ b/rse/plugins/org.eclipse.rse.services.ssh/src/org/eclipse/rse/internal/services/ssh/files/SftpFileService.java
@@ -1114,9 +1114,9 @@ public class SftpFileService extends AbstractFileService implements IFileService
/*
* (non-Javadoc)
- * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, int, org.eclipse.core.runtime.IProgressMonitor)
*/
- public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, boolean append, IProgressMonitor monitor) throws SystemMessageException {
+ public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException {
if (monitor == null) {
monitor = new NullProgressMonitor();
@@ -1131,7 +1131,7 @@ public class SftpFileService extends AbstractFileService implements IFileService
try {
SftpProgressMonitor sftpMonitor = new MyProgressMonitor(monitor);
int mode;
- if (!append) {
+ if ((options & IFileService.APPEND) == 0) {
mode = ChannelSftp.OVERWRITE;
} else {
mode = ChannelSftp.APPEND;
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java
index efe3e0e5396..8ce0b0a2b44 100644
--- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/AbstractFileService.java
@@ -208,7 +208,7 @@ public abstract class AbstractFileService implements IFileService
return null;
}
- public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, boolean append, IProgressMonitor monitor) throws SystemMessageException {
+ public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException {
return null;
}
}
\ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java
index a6f2a7e2124..116e74cda1d 100644
--- a/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java
+++ b/rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/services/files/IFileService.java
@@ -99,6 +99,19 @@ public interface IFileService extends IService
*/
public static final int FILE_TYPE_FILES_AND_FOLDERS = 0x0;
+ /**
+ * Options constant (value 1 <<0) for specifying a stream
+ * that will append data to a file.
+ *
+ * @see IFileService#getOutputStream(String, String, boolean, int, IProgressMonitor)
+ */
+ public static final int APPEND = 1 << 0;
+
+ /**
+ * Options constant (value 0) to indicate that no bit options are set.
+ */
+ public static final int NONE = 0;
+
/**
* Copy a file to the remote file system. The remote target is denoted by a
* string representing the parent and a string representing the file.
@@ -456,7 +469,7 @@ public interface IFileService extends IService
* @throws SystemMessageException if an error occurs.
* @since 2.0
* @deprecated As of 3.0M4, replaced by
- * {@link #getOutputStream(String, String, boolean, boolean, IProgressMonitor)}
+ * {@link #getOutputStream(String, String, boolean, int, IProgressMonitor)}
*/
public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException;
@@ -465,12 +478,12 @@ public interface IFileService extends IService
* @param remoteParent the absolute path of the parent.
* @param remoteFile the name of the remote file.
* @param isBinary true
if the file is a binary file, false
otherwise.
- * @param append true
if you want to append to a file, false
if you want to overwrite the file's contents.
+ * @param options bit wise or of option constants. Valid constants are {@link IFileService#APPEND} and {@link IFileService#NONE}
* @param monitor the progress monitor.
* @return the input stream to access the contents of the remote file.
* @throws SystemMessageException if an error occurs.
* @since 3.0
*/
- public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, boolean append, IProgressMonitor monitor) throws SystemMessageException;
+ public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException;
}
\ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java
index e6c6a05dc01..8160fe59dd1 100644
--- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java
+++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/FileServiceSubSystem.java
@@ -1029,8 +1029,8 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I
return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, isBinary, monitor), remoteParent, remoteFile, this);
}
- public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, boolean append, IProgressMonitor monitor) throws SystemMessageException {
- return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, isBinary, append, monitor), remoteParent, remoteFile, this);
+ public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException {
+ return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, isBinary, options, monitor), remoteParent, remoteFile, this);
}
}
\ No newline at end of file
diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFileSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFileSubSystem.java
index 3b09166ecaa..6a53f3cd402 100644
--- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFileSubSystem.java
+++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/subsystems/IRemoteFileSubSystem.java
@@ -659,7 +659,7 @@ public interface IRemoteFileSubSystem extends ISubSystem {
* @throws SystemMessageException if an error occurs.
* @since 2.0
* @deprecated As of 3.0M4, replaced by
- * {@link #getOutputStream(String, String, boolean, boolean, IProgressMonitor)}
+ * {@link #getOutputStream(String, String, boolean, int, IProgressMonitor)}
*/
public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException;
@@ -668,12 +668,12 @@ public interface IRemoteFileSubSystem extends ISubSystem {
* @param remoteParent the absolute path of the parent.
* @param remoteFile the name of the remote file.
* @param isBinary true
if the file is a binary file, false
otherwise.
- * @param append true
if you want to append to a file, false
if you want to overwrite the file's contents.
+ * @param options bit wise or of option constants. Valid constants are {@link IFileService#APPEND} and {@link IFileService#NONE}
* @return the input stream to access the contents of the remote file.
* @param monitor the progress monitor.
* @throws SystemMessageException if an error occurs.
* @since 3.0
*/
- public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, boolean append, IProgressMonitor monitor) throws SystemMessageException;
+ public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException;
}
\ No newline at end of file