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 3d84273413f..be8e0198880 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 @@ -24,6 +24,7 @@ * Martin Oberhuber (Wind River) - [191589] fix Rename by adding putInfo() for RSE EFS, and fetch symlink info * Martin Oberhuber (Wind River) - [199552] fix deadlock with dstore-backed efs access * David McKnight (IBM) - [207178] changing list APIs for file service and subsystems + * Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND ********************************************************************************/ package org.eclipse.rse.internal.efs; @@ -649,6 +650,7 @@ 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) { @@ -671,7 +673,7 @@ public class RSEFileStoreImpl extends FileStore if (remoteFile.isFile()) { try { - return subSys.getOutputStream(remoteFile.getParentPath(), remoteFile.getName(), true, monitor); + return subSys.getOutputStream(remoteFile.getParentPath(), remoteFile.getName(), true, append, 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 cdd722d261b..abd30959afc 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 @@ -28,6 +28,7 @@ * David McKnight (IBM) - [210109] store constants in IFileService rather than IFileServiceConstants * David McKnight (IBM) - [210812] for text transfer, need to honour the preference (instead of straight binary) * David McKnight (IBM) - [209704] [api] Ability to override default encoding conversion needed. + * Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND ********************************************************************************/ package org.eclipse.rse.internal.services.dstore.files; @@ -1977,7 +1978,25 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer mode = IUniversalDataStoreConstants.TEXT_MODE; } - DStoreOutputStream outputStream = new DStoreOutputStream(getDataStore(), remotePath, getEncoding(monitor), mode, unixStyle); + DStoreOutputStream outputStream = new DStoreOutputStream(getDataStore(), remotePath, getEncoding(monitor), mode, unixStyle, false); + return outputStream; + } + + + public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, boolean append, 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, append); 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 2e38f99a2aa..eeb2071d413 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 @@ -9,7 +9,7 @@ * component that contains this file: David McKnight. * * Contributors: - * {Name} (company) - description of contribution. + * Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND ********************************************************************************/ package org.eclipse.rse.internal.services.dstore.files; @@ -27,12 +27,13 @@ public class DStoreOutputStream extends OutputStream private String _encoding; private int _mode; private boolean _firstWrite = true; + private boolean _append; private String _byteStreamHandlerId; private String _localLineSep; private String _targetLineSep; private int _localLineSepLength; - public DStoreOutputStream(DataStore dataStore, String remotePath, String encoding, int mode, boolean unixStyle) + public DStoreOutputStream(DataStore dataStore, String remotePath, String encoding, int mode, boolean unixStyle, boolean append) { _dataStore = dataStore; _remotePath = remotePath; @@ -51,20 +52,17 @@ public class DStoreOutputStream extends OutputStream } _localLineSepLength = _localLineSep.length(); - } - - + _append = append; + } public void close() throws IOException { - // TODO Auto-generated method stub super.close(); } public void flush() throws IOException { - // TODO Auto-generated method stub super.flush(); } @@ -80,7 +78,7 @@ public class DStoreOutputStream extends OutputStream b = tempStr.getBytes(_encoding); } - if (_firstWrite) + if (_firstWrite && !_append) { _firstWrite = false; @@ -136,7 +134,7 @@ public class DStoreOutputStream extends OutputStream b = tempStr.getBytes(_encoding); } - if (_firstWrite) + if (_firstWrite && !_append) { _firstWrite = false; // send first set of bytes @@ -158,7 +156,7 @@ public class DStoreOutputStream extends OutputStream String tempStr = new String(b, 0, 1); b = tempStr.getBytes(_encoding); } - if (_firstWrite) + if (_firstWrite && !_append) { _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 723ffcc1693..c84c84ed21c 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 @@ -67,6 +67,7 @@ * David McKnight (IBM) - [207178] changing list APIs for file service and subsystems * Javier Montalvo Orus (Symbian) - [208912] Cannot expand /C on a VxWorks SSH Server * David McKnight (IBM) - [210109] store constants in IFileService rather than IFileServiceConstants + * Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND ********************************************************************************/ package org.eclipse.rse.internal.services.files.ftp; @@ -1648,6 +1649,37 @@ public class FTPService extends AbstractFileService implements IFileService, IFT return stream; } + /* + * (non-Javadoc) + * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, boolean, org.eclipse.core.runtime.IProgressMonitor) + */ + public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, boolean append, 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); + if (!append){ + stream = new FTPBufferedOutputStream(ftpClient.storeFileStream(remoteFile), ftpClient); + } else { + stream = new FTPBufferedOutputStream(ftpClient.appendFileStream(remoteFile), ftpClient); + } + } + catch (Exception e) { + throw new RemoteFileIOException(e); + } + + return stream; + } + private void setDataConnectionMode() { if(_ftpPropertySet != null) 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 851ccde9d21..13d2626b426 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 @@ -27,6 +27,7 @@ * Xuan Chen (IBM) - [209828] Need to move the Create operation to a job. * David McKnight (IBM) - [210109] store constants in IFileService rather than IFileServiceConstants * Xuan Chen (IBM) - [210555] [regression] NPE when deleting a file on SSH + * Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND ********************************************************************************/ package org.eclipse.rse.internal.services.local.files; @@ -1653,6 +1654,28 @@ public class LocalFileService extends AbstractFileService implements IFileServic return stream; } + /* + * (non-Javadoc) + * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, boolean, org.eclipse.core.runtime.IProgressMonitor) + */ + public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, boolean append, IProgressMonitor monitor) throws SystemMessageException { + File file = new File(remoteParent, remoteFile); + OutputStream stream = null; + + try { + if (!append) { + stream = new FileOutputStream(file); + } else { + stream = new FileOutputStream(file, true); + } + } + catch (Exception e) { + throw new RemoteFileIOException(e); + } + + return stream; + } + public SystemMessage getMessage(String messageID) { return (_msgProvider != null ? _msgProvider.getMessage(messageID) : super.getMessage(messageID)); } 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 d166373d395..d7438b75af7 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 @@ -18,6 +18,7 @@ * David McKnight (IBM) - [207178] changing list APIs for file service and subsystems * Martin Oberhuber (Wind River) - [208912] Cannot expand /C on a VxWorks SSH Server * David McKnight (IBM) - [210109] store constants in IFileService rather than IFileServiceConstants + * Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND *******************************************************************************/ package org.eclipse.rse.internal.services.ssh.files; @@ -1110,4 +1111,44 @@ public class SftpFileService extends AbstractFileService implements IFileService } return stream; } + + /* + * (non-Javadoc) + * @see org.eclipse.rse.services.files.AbstractFileService#getOutputStream(java.lang.String, java.lang.String, boolean, boolean, org.eclipse.core.runtime.IProgressMonitor) + */ + public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, boolean append, 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; + if (!append) { + mode = ChannelSftp.OVERWRITE; + } else { + mode = ChannelSftp.APPEND; + } + 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; + } } 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 075bde2520e..efe3e0e5396 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 @@ -20,6 +20,7 @@ * Martin Oberhuber (Wind River) - [210109] no need to declare IFileService constants in AbstractFileService * David McKnight (IBM) - [209704] [api] Ability to override default encoding conversion needed. * Xuan Chen (IBM) - [210555] [regression] NPE when deleting a file on SSH + * Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND ********************************************************************************/ package org.eclipse.rse.services.files; @@ -206,4 +207,8 @@ public abstract class AbstractFileService implements IFileService public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException { return null; } + + public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, boolean append, 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 62ff7e797c4..a6f2a7e2124 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 @@ -19,6 +19,7 @@ * David McKnight (IBM) - [162195] new APIs for upload multi and download multi * David McKnight (IBM) - [209552] API changes to use multiple and getting rid of deprecated * David McKnight (IBM) - [210109] store constants in IFileService rather than IFileServiceConstants + * Kevin Doyle (IBM) - [208778] new API getOutputSteam for getting an output stream in append mode ********************************************************************************/ package org.eclipse.rse.services.files; @@ -454,8 +455,22 @@ 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, boolean, IProgressMonitor)} */ public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException; + /** + * 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 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 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; } \ 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 f8d94a134d8..e6c6a05dc01 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 @@ -24,7 +24,8 @@ * David McKnight (IBM) - [207178] changing list APIs for file service and subsystems * David McKnight (IBM) - [162195] new APIs for upload multi and download multi * David McKnight (IBM) - [203114] don't treat XML files specially (no hidden prefs for bin vs text) - * David McKnight (IBM) - [209552] API changes to use multiple and getting rid of deprecated + * David McKnight (IBM) - [209552] API changes to use multiple and getting rid of deprecated + * Kevin Doyle (IBM) - [208778] [efs][api] RSEFileStore#getOutputStream() does not support EFS#APPEND *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.servicesubsystem; @@ -1028,4 +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); + } + } \ 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 6adf163f5a2..3b09166ecaa 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 @@ -18,6 +18,7 @@ * David McKnight (IBM) - [207178] changing list APIs for file service and subsystems * David McKnight (IBM) - [162195] new APIs for upload multi and download multi * David McKnight (IBM) - [209552] API changes to use multiple and getting rid of deprecated + * Kevin Doyle (IBM) - [208778] new API getOutputSteam for getting an output stream in append mode *******************************************************************************/ package org.eclipse.rse.subsystems.files.core.subsystems; @@ -657,7 +658,22 @@ 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, boolean, IProgressMonitor)} */ public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException; + /** + * Gets the output stream to write/append to a remote file. Clients should close the output stream when done. Implementations should not return null. + * @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. + * @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; + } \ No newline at end of file diff --git a/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF b/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF index ae84290391d..add89b5f4ac 100644 --- a/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF +++ b/rse/tests/org.eclipse.rse.tests/META-INF/MANIFEST.MF @@ -20,7 +20,8 @@ Require-Bundle: org.junit, org.eclipse.rse.services.files.ftp;bundle-version="[3.0.0,4.0.0)", org.eclipse.rse.subsystems.files.ftp;bundle-version="[3.0.0,4.0.0)", org.eclipse.core.filesystem, - org.eclipse.rse.files.ui + org.eclipse.rse.files.ui, + org.eclipse.rse.efs Eclipse-LazyStart: true Bundle-RequiredExecutionEnvironment: J2SE-1.4 Export-Package: org.eclipse.rse.tests, diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileAppendOutputSteamTestCase.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileAppendOutputSteamTestCase.java new file mode 100644 index 00000000000..de1b77fd21d --- /dev/null +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileAppendOutputSteamTestCase.java @@ -0,0 +1,242 @@ +/******************************************************************************** +* Copyright (c) 2007 IBM Corporation. All rights reserved. +* This program and the accompanying materials are made available under the terms +* of the Eclipse Public License v1.0 which accompanies this distribution, and is +* available at http://www.eclipse.org/legal/epl-v10.html +* +* Initial Contributors: +* The following IBM employees contributed to the Remote System Explorer +* component that contains this file: Kevin Doyle +* +* Contributors: +* {Name} (company) - description of contribution. +********************************************************************************/ + +package org.eclipse.rse.tests.subsystems.files; + +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URI; + +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.core.model.IHost; +import org.eclipse.rse.core.model.ISystemRegistry; +import org.eclipse.rse.core.model.SystemStartHere; +import org.eclipse.rse.core.subsystems.ISubSystem; +import org.eclipse.rse.internal.efs.RSEFileStore; +import org.eclipse.rse.services.clientserver.PathUtility; +import org.eclipse.rse.services.files.IFileService; +import org.eclipse.rse.subsystems.files.core.servicesubsystem.FileServiceSubSystem; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; +import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem; +import org.eclipse.rse.ui.ISystemPreferencesConstants; +import org.eclipse.rse.ui.RSEUIPlugin; +import org.eclipse.rse.ui.internal.model.SystemRegistry; + +public class FileAppendOutputSteamTestCase extends FileServiceBaseTest { + + private String SYSTEM_ADDRESS = "sles8rm";//"SLES8RM"; + private String USER_ID = "xxxxxx"; + private String PASSWORD = "xxxxxx"; //"xxxxxx"; + private IHost host = null; + private IRemoteFile tempDirectory; + + private IRemoteFileSubSystem getRemoteFileSubSystem(IHost host) { + IRemoteFileSubSystem fss = null; + ISystemRegistry sr = SystemStartHere.getSystemRegistry(); + ISubSystem[] ss = sr.getServiceSubSystems(host, IFileService.class); + for (int i=0; i + final int length = path.length(); + StringBuffer pathBuf = new StringBuffer(length + 3); + //There must be a leading slash in a hierarchical URI + if (length > 0 && (path.charAt(0) != '/')) + pathBuf.append('/'); + //additional double-slash for UNC paths to distinguish from host separator + if (path.startsWith("//")) //$NON-NLS-1$ + pathBuf.append('/').append('/'); + pathBuf.append(path); + // + return pathBuf.toString(); + } + + public void cleanup() throws Exception { + if (host != null) { + if (tempDirectory != null) { + IRemoteFileSubSystem fss = getRemoteFileSubSystem(host); + fss.delete(tempDirectory, new NullProgressMonitor()); + fss.disconnect(); + tempDirectory = null; + } + SystemRegistry.getInstance().deleteHost(host); + host = null; + } + } + + public void tearDown() throws Exception { + cleanup(); + super.tearDown(); + } +} diff --git a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceBaseTest.java b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceBaseTest.java index 3f7be06634f..a9fc11cbe22 100644 --- a/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceBaseTest.java +++ b/rse/tests/org.eclipse.rse.tests/src/org/eclipse/rse/tests/subsystems/files/FileServiceBaseTest.java @@ -239,8 +239,8 @@ public class FileServiceBaseTest extends RSEBaseConnectionTestCase { //---------------------------------------------------------------------- protected IFileStore createDir(IFileStore store, boolean clear) throws CoreException { if (clear && store.fetchInfo().exists()) - store.delete(EFS.NONE, null); - store.mkdir(EFS.NONE, null); + store.delete(EFS.NONE, new NullProgressMonitor()); + store.mkdir(EFS.NONE, new NullProgressMonitor()); IFileInfo info = store.fetchInfo(); assertTrue("createDir.1", info.exists()); assertTrue("createDir.1", info.isDirectory());