1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-05 16:15:25 +02:00

[208778][api] Change new Streams Services API to use int options instead of boolean binary

This commit is contained in:
Martin Oberhuber 2008-01-07 14:58:38 +00:00
parent 78d1ca5e0b
commit 6136db1988
10 changed files with 47 additions and 104 deletions

View file

@ -1,12 +1,12 @@
feature@org.eclipse.rse=v20080107,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/features/org.eclipse.rse-feature
feature@org.eclipse.rse.core=v20080107,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/features/org.eclipse.rse.core-feature
feature@org.eclipse.rse.dstore=v20080102,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/features/org.eclipse.rse.dstore-feature
feature@org.eclipse.rse.dstore=v20080107,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/features/org.eclipse.rse.dstore-feature
feature@org.eclipse.rse.examples=v20071121,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/examples/org.eclipse.rse.examples-feature
feature@org.eclipse.rse.ftp=v20080107,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/features/org.eclipse.rse.ftp-feature
feature@org.eclipse.rse.local=v20080104,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/features/org.eclipse.rse.local-feature
feature@org.eclipse.rse.local=v20080107,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/features/org.eclipse.rse.local-feature
feature@org.eclipse.rse.remotecdt=v20071031,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/features/org.eclipse.rse.remotecdt-feature
feature@org.eclipse.rse.sdk=v20080107,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/features/org.eclipse.rse.sdk-feature
feature@org.eclipse.rse.ssh=v20071206,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/features/org.eclipse.rse.ssh-feature
feature@org.eclipse.rse.ssh=v20080107,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/features/org.eclipse.rse.ssh-feature
feature@org.eclipse.rse.telnet=v20071121,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/features/org.eclipse.rse.telnet-feature
feature@org.eclipse.rse.tests=v20071206,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/tests/org.eclipse.rse.tests-feature
plugin@org.eclipse.dstore.core=v20080102,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.dstore.core
@ -30,12 +30,12 @@ plugin@org.eclipse.rse.importexport=v20071106,:pserver:anonymous:none@dev.eclips
plugin@org.eclipse.rse.processes.ui=v20071031,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.processes.ui
plugin@org.eclipse.rse.remotecdt=v20071031,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/examples/org.eclipse.rse.remotecdt
plugin@org.eclipse.rse.sdk=v20071031,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.sdk
plugin@org.eclipse.rse.services.dstore=v20080102,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.services.dstore
plugin@org.eclipse.rse.services.files.ftp=v20071206,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.services.files.ftp
plugin@org.eclipse.rse.services.local=v20080104,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.services.local
plugin@org.eclipse.rse.services.ssh=v20071206,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.services.ssh
plugin@org.eclipse.rse.services.dstore=v20080107,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.services.dstore
plugin@org.eclipse.rse.services.files.ftp=v20080107,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.services.files.ftp
plugin@org.eclipse.rse.services.local=v20080107,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.services.local
plugin@org.eclipse.rse.services.ssh=v20080107,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.services.ssh
plugin@org.eclipse.rse.services.telnet=v20071106,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.services.telnet
plugin@org.eclipse.rse.services=v20080102,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.services
plugin@org.eclipse.rse.services=v20080107,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.services
plugin@org.eclipse.rse.shells.ui=v20080102,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.shells.ui
plugin@org.eclipse.rse.subsystems.files.core=v20080107,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.subsystems.files.core
plugin@org.eclipse.rse.subsystems.files.dstore=v20071106,:pserver:anonymous:none@dev.eclipse.org:/cvsroot/dsdp,,org.eclipse.tm.rse/plugins/org.eclipse.rse.subsystems.files.dstore

View file

@ -678,7 +678,7 @@ public class RSEFileStoreImpl extends FileStore
} else {
options = IFileService.NONE;
}
return subSys.getOutputStream(remoteFile.getParentPath(), remoteFile.getName(), true, options, monitor);
return subSys.getOutputStream(remoteFile.getParentPath(), remoteFile.getName(), options, monitor);
}
catch (SystemMessageException e) {
throw new CoreException(new Status(IStatus.ERROR,

View file

@ -2033,28 +2033,16 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer
* @see org.eclipse.rse.services.files.IFileService#getOutputStream(org.eclipse.core.runtime.IProgressMonitor, java.lang.String, java.lang.String, boolean)
*/
public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException {
String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
int mode;
if (isBinary)
{
mode = IUniversalDataStoreConstants.BINARY_MODE;
}
else
{
mode = IUniversalDataStoreConstants.TEXT_MODE;
}
DStoreOutputStream outputStream = new DStoreOutputStream(getDataStore(), remotePath, getEncoding(monitor), mode, unixStyle, IFileService.NONE);
return outputStream;
int options = isBinary ? IFileService.NONE : IFileService.TEXT_MODE;
return getOutputStream(remoteParent, remoteFile, options, monitor);
}
public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException {
public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException {
String remotePath = remoteParent + getSeparator(remoteParent) + remoteFile;
int mode;
if (isBinary)
if ((options & IFileService.TEXT_MODE) == 0)
{
mode = IUniversalDataStoreConstants.BINARY_MODE;
}

View file

@ -1627,33 +1627,15 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
* @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
*/
public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException {
remoteParent = checkEncoding(remoteParent);
remoteFile = checkEncoding(remoteFile);
if (monitor != null && monitor.isCanceled()){
throw new RemoteFileCancelledException();
}
OutputStream stream = null;
try {
FTPClient ftpClient = cloneFTPClient(isBinary);
clearCache(remoteParent);
ftpClient.changeWorkingDirectory(remoteParent);
stream = new FTPBufferedOutputStream(ftpClient.storeFileStream(remoteFile), ftpClient);
}
catch (Exception e) {
throw new RemoteFileIOException(e);
}
return stream;
int options = isBinary ? IFileService.NONE : IFileService.TEXT_MODE;
return getOutputStream(remoteParent, remoteFile, options, monitor);
}
/*
* (non-Javadoc)
* @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, int options, IProgressMonitor monitor) throws SystemMessageException {
public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException {
remoteParent = checkEncoding(remoteParent);
remoteFile = checkEncoding(remoteFile);
@ -1664,6 +1646,7 @@ public class FTPService extends AbstractFileService implements IFileService, IFT
OutputStream stream = null;
try {
boolean isBinary = (options & IFileService.TEXT_MODE) == 0 ? true : false;
FTPClient ftpClient = cloneFTPClient(isBinary);
clearCache(remoteParent);
ftpClient.changeWorkingDirectory(remoteParent);

View file

@ -1641,24 +1641,15 @@ public class LocalFileService extends AbstractFileService implements IFileServic
* @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(String, String, boolean, IProgressMonitor)
*/
public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException {
File file = new File(remoteParent, remoteFile);
OutputStream stream = null;
try {
stream = new FileOutputStream(file);
}
catch (Exception e) {
throw new RemoteFileIOException(e);
}
return stream;
int options = isBinary ? IFileService.NONE : IFileService.TEXT_MODE;
return getOutputStream(remoteParent, remoteFile, options, monitor);
}
/*
* (non-Javadoc)
* @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, int options, IProgressMonitor monitor) throws SystemMessageException {
public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException {
File file = new File(remoteParent, remoteFile);
OutputStream stream = null;

View file

@ -1031,8 +1031,7 @@ public class SftpFileService extends AbstractFileService implements IFileService
if (permNew != permOld) {
//getChannel("SftpFileService.setReadOnly").chmod(permNew, path); //$NON-NLS-1$
attr.setPERMISSIONS(permNew);
getChannel("SftpFileService.setReadOnly").setStat(recode(path), attr); //$NON-NLS-1$
ok=true;
getChannel("SftpFileService.setReadOnly").setStat(recode(path), attr); //$NON-NLS-1$ ok=true;
Activator.trace("SftpFileService.setReadOnly ok"); //$NON-NLS-1$
} else {
ok=true;
@ -1080,41 +1079,15 @@ public class SftpFileService extends AbstractFileService implements IFileService
* @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(String, String, boolean, IProgressMonitor)
*/
public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
OutputStream stream = null;
String dst = remoteParent;
if (remoteFile!=null) {
dst = concat(remoteParent, remoteFile);
}
try {
SftpProgressMonitor sftpMonitor = new MyProgressMonitor(monitor);
int mode = ChannelSftp.OVERWRITE;
getChannel("SftpFileService.getOutputStream " + remoteFile); //check the session is healthy //$NON-NLS-1$
ChannelSftp channel = (ChannelSftp)fSessionProvider.getSession().openChannel("sftp"); //$NON-NLS-1$
channel.connect();
stream = new SftpBufferedOutputStream(channel.put(recodeSafe(dst), sftpMonitor, mode), channel);
Activator.trace("SftpFileService.getOutputStream " + remoteFile + " ok"); //$NON-NLS-1$ //$NON-NLS-2$
}
catch (Exception e) {
Activator.trace("SftpFileService.getOutputStream " + dst + " failed: " + e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
throw makeSystemMessageException(e);
}
if (monitor.isCanceled()) {
throw new RemoteFileCancelledException();
}
return stream;
int options = isBinary ? IFileService.NONE : IFileService.TEXT_MODE;
return getOutputStream(remoteParent, remoteFile, options, monitor);
}
/*
* (non-Javadoc)
* @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, int options, IProgressMonitor monitor) throws SystemMessageException {
public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException {
if (monitor == null) {
monitor = new NullProgressMonitor();

View file

@ -215,11 +215,12 @@ public abstract class AbstractFileService implements IFileService
* Gets the output stream to write/append to a remote file.
* The default implementation returns <code>null</code>.
* Clients can override to return an output stream to the file.
* @see org.eclipse.rse.services.files.IFileService#getOutputStream(String, String, boolean, int, IProgressMonitor)
* @see org.eclipse.rse.services.files.IFileService#getOutputStream(String, String, int, IProgressMonitor)
*/
public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, int options, IProgressMonitor monitor) throws SystemMessageException {
public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException {
if ((options & IFileService.APPEND) == 0) {
//forward to old deprecated implementation for backward compatibility with old services
boolean isBinary = (options & IFileService.TEXT_MODE) == 0 ? true : false;
return getOutputStream(remoteParent, remoteFile, isBinary, monitor);
}
return null;

View file

@ -104,10 +104,21 @@ public interface IFileService extends IService
* Options constant (value 1 &lt;&lt;0) for specifying a stream
* that will append data to a file.
*
* @see IFileService#getOutputStream(String, String, boolean, int, IProgressMonitor)
* @see IFileService#getOutputStream(String, String, int, IProgressMonitor)
*/
public static final int APPEND = 1 << 0;
/**
* Options constant (value 2 &lt;&lt;0) for specifying that a file
* is Text instead of the default Binary.
*
* In Text mode, encoding conversions and line end conversions can be
* performed on the stream.
*
* @see IFileService#getOutputStream(String, String, int, IProgressMonitor)
*/
public static final int TEXT_MODE = 2 << 0;
/**
* Options constant (value 0) to indicate that no bit options are set.
*/
@ -469,8 +480,7 @@ public interface IFileService extends IService
* @return the input stream to access the contents of the remote file.
* @throws SystemMessageException if an error occurs.
* @since 2.0
* @deprecated As of 3.0M4, replaced by
* {@link #getOutputStream(String, String, boolean, int, IProgressMonitor)}
* @deprecated Use {@link #getOutputStream(String, String, int, IProgressMonitor)} instead
*/
public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException;
@ -478,14 +488,13 @@ public interface IFileService extends IService
* Gets the output stream to write/append to a remote file. Clients should close the output stream when done.
* @param remoteParent the absolute path of the parent.
* @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 options bit wise or of option constants. Valid constants are {@link IFileService#APPEND} and {@link IFileService#NONE}
* @param options bit wise or of option constants. Valid constants are {@link IFileService#APPEND}, {@link IFileService#TEXT_MODE}, 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, int options, IProgressMonitor monitor) throws SystemMessageException;
public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException;
/**
* Indicates whether this file service supports code page conversion using

View file

@ -1030,8 +1030,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, int options, IProgressMonitor monitor) throws SystemMessageException {
return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, isBinary, options, monitor), remoteParent, remoteFile, this);
public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException {
return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, options, monitor), remoteParent, remoteFile, this);
}
/**

View file

@ -659,8 +659,7 @@ public interface IRemoteFileSubSystem extends ISubSystem {
* @param monitor the progress monitor.
* @throws SystemMessageException if an error occurs.
* @since 2.0
* @deprecated As of 3.0M4, replaced by
* {@link #getOutputStream(String, String, boolean, int, IProgressMonitor)}
* @deprecated Use {@link #getOutputStream(String, String, boolean, IProgressMonitor)} instead
*/
public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException;
@ -668,14 +667,13 @@ public interface IRemoteFileSubSystem extends ISubSystem {
* 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>.
* @param remoteParent the absolute path of the parent.
* @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 options bit wise or of option constants. Valid constants are {@link IFileService#APPEND} and {@link IFileService#NONE}
* @param options bit wise or of option constants. Valid constants are {@link IFileService#APPEND}, {@link IFileService#TEXT_MODE}, 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, int options, IProgressMonitor monitor) throws SystemMessageException;
public OutputStream getOutputStream(String remoteParent, String remoteFile, int options, IProgressMonitor monitor) throws SystemMessageException;
/**
* Indicates whether this file subsystem supports code page conversion using