mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-19 06:05:56 +02:00
[208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND
This commit is contained in:
parent
a479f02926
commit
250570d64e
10 changed files with 48 additions and 29 deletions
|
@ -650,7 +650,6 @@ public class RSEFileStoreImpl extends FileStore
|
||||||
* @see org.eclipse.core.filesystem.IFileStore#openOutputStream(int, org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.core.filesystem.IFileStore#openOutputStream(int, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException {
|
public OutputStream openOutputStream(int options, IProgressMonitor monitor) throws CoreException {
|
||||||
boolean append = (options & EFS.APPEND) != 0;
|
|
||||||
cacheRemoteFile(null);
|
cacheRemoteFile(null);
|
||||||
IRemoteFile remoteFile = getRemoteFileObject(monitor, false);
|
IRemoteFile remoteFile = getRemoteFileObject(monitor, false);
|
||||||
if (remoteFile==null) {
|
if (remoteFile==null) {
|
||||||
|
@ -673,7 +672,13 @@ public class RSEFileStoreImpl extends FileStore
|
||||||
|
|
||||||
if (remoteFile.isFile()) {
|
if (remoteFile.isFile()) {
|
||||||
try {
|
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) {
|
catch (SystemMessageException e) {
|
||||||
throw new CoreException(new Status(IStatus.ERROR,
|
throw new CoreException(new Status(IStatus.ERROR,
|
||||||
|
|
|
@ -1978,12 +1978,12 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
mode = IUniversalDataStoreConstants.TEXT_MODE;
|
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;
|
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;
|
String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
|
||||||
int mode;
|
int mode;
|
||||||
|
|
||||||
|
@ -1996,7 +1996,7 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
|
||||||
mode = IUniversalDataStoreConstants.TEXT_MODE;
|
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;
|
return outputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import java.io.OutputStream;
|
||||||
import org.eclipse.dstore.core.model.DataStore;
|
import org.eclipse.dstore.core.model.DataStore;
|
||||||
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
|
import org.eclipse.rse.dstore.universal.miners.IUniversalDataStoreConstants;
|
||||||
import org.eclipse.rse.dstore.universal.miners.UniversalByteStreamHandler;
|
import org.eclipse.rse.dstore.universal.miners.UniversalByteStreamHandler;
|
||||||
|
import org.eclipse.rse.services.files.IFileService;
|
||||||
|
|
||||||
public class DStoreOutputStream extends OutputStream
|
public class DStoreOutputStream extends OutputStream
|
||||||
{
|
{
|
||||||
|
@ -27,13 +28,13 @@ public class DStoreOutputStream extends OutputStream
|
||||||
private String _encoding;
|
private String _encoding;
|
||||||
private int _mode;
|
private int _mode;
|
||||||
private boolean _firstWrite = true;
|
private boolean _firstWrite = true;
|
||||||
private boolean _append;
|
private int _options;
|
||||||
private String _byteStreamHandlerId;
|
private String _byteStreamHandlerId;
|
||||||
private String _localLineSep;
|
private String _localLineSep;
|
||||||
private String _targetLineSep;
|
private String _targetLineSep;
|
||||||
private int _localLineSepLength;
|
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;
|
_dataStore = dataStore;
|
||||||
_remotePath = remotePath;
|
_remotePath = remotePath;
|
||||||
|
@ -52,7 +53,7 @@ public class DStoreOutputStream extends OutputStream
|
||||||
}
|
}
|
||||||
|
|
||||||
_localLineSepLength = _localLineSep.length();
|
_localLineSepLength = _localLineSep.length();
|
||||||
_append = append;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() throws IOException
|
public void close() throws IOException
|
||||||
|
@ -78,7 +79,7 @@ public class DStoreOutputStream extends OutputStream
|
||||||
|
|
||||||
b = tempStr.getBytes(_encoding);
|
b = tempStr.getBytes(_encoding);
|
||||||
}
|
}
|
||||||
if (_firstWrite && !_append)
|
if (_firstWrite && (_options & IFileService.APPEND) == 0)
|
||||||
{
|
{
|
||||||
_firstWrite = false;
|
_firstWrite = false;
|
||||||
|
|
||||||
|
@ -134,7 +135,7 @@ public class DStoreOutputStream extends OutputStream
|
||||||
|
|
||||||
b = tempStr.getBytes(_encoding);
|
b = tempStr.getBytes(_encoding);
|
||||||
}
|
}
|
||||||
if (_firstWrite && !_append)
|
if (_firstWrite && (_options & IFileService.APPEND) == 0)
|
||||||
{
|
{
|
||||||
_firstWrite = false;
|
_firstWrite = false;
|
||||||
// send first set of bytes
|
// send first set of bytes
|
||||||
|
@ -156,7 +157,7 @@ public class DStoreOutputStream extends OutputStream
|
||||||
String tempStr = new String(b, 0, 1);
|
String tempStr = new String(b, 0, 1);
|
||||||
b = tempStr.getBytes(_encoding);
|
b = tempStr.getBytes(_encoding);
|
||||||
}
|
}
|
||||||
if (_firstWrite && !_append)
|
if (_firstWrite && (_options & IFileService.APPEND) == 0)
|
||||||
{
|
{
|
||||||
_firstWrite = false;
|
_firstWrite = false;
|
||||||
// send first set of bytes
|
// send first set of bytes
|
||||||
|
|
|
@ -1651,9 +1651,9 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (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);
|
remoteParent = checkEncoding(remoteParent);
|
||||||
remoteFile = checkEncoding(remoteFile);
|
remoteFile = checkEncoding(remoteFile);
|
||||||
|
|
||||||
|
@ -1667,7 +1667,7 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
|
||||||
FTPClient ftpClient = cloneFTPClient(isBinary);
|
FTPClient ftpClient = cloneFTPClient(isBinary);
|
||||||
clearCache(remoteParent);
|
clearCache(remoteParent);
|
||||||
ftpClient.changeWorkingDirectory(remoteParent);
|
ftpClient.changeWorkingDirectory(remoteParent);
|
||||||
if (!append){
|
if ((options & IFileService.APPEND) == 0){
|
||||||
stream = new FTPBufferedOutputStream(ftpClient.storeFileStream(remoteFile), ftpClient);
|
stream = new FTPBufferedOutputStream(ftpClient.storeFileStream(remoteFile), ftpClient);
|
||||||
} else {
|
} else {
|
||||||
stream = new FTPBufferedOutputStream(ftpClient.appendFileStream(remoteFile), ftpClient);
|
stream = new FTPBufferedOutputStream(ftpClient.appendFileStream(remoteFile), ftpClient);
|
||||||
|
|
|
@ -1656,14 +1656,14 @@ public class LocalFileService extends AbstractFileService implements IFileServic
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (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);
|
File file = new File(remoteParent, remoteFile);
|
||||||
OutputStream stream = null;
|
OutputStream stream = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!append) {
|
if ((options & IFileService.APPEND) == 0) {
|
||||||
stream = new FileOutputStream(file);
|
stream = new FileOutputStream(file);
|
||||||
} else {
|
} else {
|
||||||
stream = new FileOutputStream(file, true);
|
stream = new FileOutputStream(file, true);
|
||||||
|
|
|
@ -1114,9 +1114,9 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (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) {
|
if (monitor == null) {
|
||||||
monitor = new NullProgressMonitor();
|
monitor = new NullProgressMonitor();
|
||||||
|
@ -1131,7 +1131,7 @@ public class SftpFileService extends AbstractFileService implements IFileService
|
||||||
try {
|
try {
|
||||||
SftpProgressMonitor sftpMonitor = new MyProgressMonitor(monitor);
|
SftpProgressMonitor sftpMonitor = new MyProgressMonitor(monitor);
|
||||||
int mode;
|
int mode;
|
||||||
if (!append) {
|
if ((options & IFileService.APPEND) == 0) {
|
||||||
mode = ChannelSftp.OVERWRITE;
|
mode = ChannelSftp.OVERWRITE;
|
||||||
} else {
|
} else {
|
||||||
mode = ChannelSftp.APPEND;
|
mode = ChannelSftp.APPEND;
|
||||||
|
|
|
@ -208,7 +208,7 @@ public abstract class AbstractFileService implements IFileService
|
||||||
return null;
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -99,6 +99,19 @@ public interface IFileService extends IService
|
||||||
*/
|
*/
|
||||||
public static final int FILE_TYPE_FILES_AND_FOLDERS = 0x0;
|
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
|
* 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.
|
* 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.
|
* @throws SystemMessageException if an error occurs.
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
* @deprecated As of 3.0M4, replaced by
|
* @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;
|
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 remoteParent the absolute path of the parent.
|
||||||
* @param remoteFile the name of the remote file.
|
* @param remoteFile the name of the remote file.
|
||||||
* @param isBinary <code>true</code> if the file is a binary file, <code>false</code> otherwise.
|
* @param isBinary <code>true</code> if the file is a binary file, <code>false</code> otherwise.
|
||||||
* @param append <code>true</code> if you want to append to a file, <code>false</code> 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.
|
* @param monitor the progress monitor.
|
||||||
* @return the input stream to access the contents of the remote file.
|
* @return the input stream to access the contents of the remote file.
|
||||||
* @throws SystemMessageException if an error occurs.
|
* @throws SystemMessageException if an error occurs.
|
||||||
* @since 3.0
|
* @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;
|
||||||
|
|
||||||
}
|
}
|
|
@ -1029,8 +1029,8 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I
|
||||||
return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, isBinary, monitor), remoteParent, remoteFile, this);
|
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 {
|
public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException {
|
||||||
return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, isBinary, append, monitor), remoteParent, remoteFile, this);
|
return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, isBinary, options, monitor), remoteParent, remoteFile, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -659,7 +659,7 @@ public interface IRemoteFileSubSystem extends ISubSystem {
|
||||||
* @throws SystemMessageException if an error occurs.
|
* @throws SystemMessageException if an error occurs.
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
* @deprecated As of 3.0M4, replaced by
|
* @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;
|
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 remoteParent the absolute path of the parent.
|
||||||
* @param remoteFile the name of the remote file.
|
* @param remoteFile the name of the remote file.
|
||||||
* @param isBinary <code>true</code> if the file is a binary file, <code>false</code> otherwise.
|
* @param isBinary <code>true</code> if the file is a binary file, <code>false</code> otherwise.
|
||||||
* @param append <code>true</code> if you want to append to a file, <code>false</code> 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.
|
* @return the input stream to access the contents of the remote file.
|
||||||
* @param monitor the progress monitor.
|
* @param monitor the progress monitor.
|
||||||
* @throws SystemMessageException if an error occurs.
|
* @throws SystemMessageException if an error occurs.
|
||||||
* @since 3.0
|
* @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;
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue