mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 23:05:47 +02:00
[207100] decorated input stream and output streams for FileServiceSubSystem.getInputStream() and FileServiceSubSystem.getOutputSTream()
This commit is contained in:
parent
de09c1a031
commit
d6112286b0
3 changed files with 160 additions and 4 deletions
|
@ -818,18 +818,18 @@ public final class FileServiceSubSystem extends RemoteFileSubSystem implements I
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defers to the file service.
|
* Defers to the file service. The method is basically another way to do download.
|
||||||
* @see org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem#getInputStream(java.lang.String, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem#getInputStream(java.lang.String, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
public InputStream getInputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException {
|
public InputStream getInputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException {
|
||||||
return getFileService().getInputStream(remoteParent, remoteFile, isBinary, monitor);
|
return new FileSubSystemInputStream(getFileService().getInputStream(remoteParent, remoteFile, isBinary, monitor), remoteParent, remoteFile, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defers to the file service.
|
* Defers to the file service. The method is basically another way to do upload.
|
||||||
* @see org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem#getOutputStream(java.lang.String, java.lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.rse.subsystems.files.core.subsystems.RemoteFileSubSystem#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 {
|
public OutputStream getOutputStream(String remoteParent, String remoteFile, boolean isBinary, IProgressMonitor monitor) throws SystemMessageException {
|
||||||
return getFileService().getOutputStream(remoteParent, remoteFile, isBinary, monitor);
|
return new FileSubSystemOutputStream(getFileService().getOutputStream(remoteParent, remoteFile, isBinary, monitor), remoteParent, remoteFile, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,85 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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: David McKnight.
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* David McKnight (IBM) - [207100] decorated input stream
|
||||||
|
********************************************************************************/
|
||||||
|
package org.eclipse.rse.subsystems.files.core.servicesubsystem;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import org.eclipse.rse.core.RSECorePlugin;
|
||||||
|
import org.eclipse.rse.core.events.ISystemRemoteChangeEvents;
|
||||||
|
import org.eclipse.rse.core.events.SystemRemoteChangeEvent;
|
||||||
|
import org.eclipse.rse.core.model.ISystemRegistry;
|
||||||
|
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decorates an input stream that was created in the service layer.
|
||||||
|
* The purpose of this class is to notify download after the stream is closed.
|
||||||
|
*/
|
||||||
|
public class FileSubSystemInputStream extends InputStream {
|
||||||
|
|
||||||
|
private InputStream _inStream;
|
||||||
|
private String _remoteParent;
|
||||||
|
private String _remoteFile;
|
||||||
|
private IRemoteFileSubSystem _fs;
|
||||||
|
|
||||||
|
public FileSubSystemInputStream(InputStream inStream, String remoteParent, String remoteFile, IRemoteFileSubSystem fs)
|
||||||
|
{
|
||||||
|
_inStream = inStream;
|
||||||
|
_remoteParent = remoteParent;
|
||||||
|
_remoteFile = remoteFile;
|
||||||
|
_fs = fs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int available() throws IOException {
|
||||||
|
return _inStream.available();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() throws IOException {
|
||||||
|
_inStream.close();
|
||||||
|
|
||||||
|
// notify that the file was uploaded
|
||||||
|
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
|
||||||
|
|
||||||
|
sr.fireEvent(new SystemRemoteChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_UPLOADED, _remoteParent, _remoteFile, _fs));
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void mark(int readlimit) {
|
||||||
|
_inStream.mark(readlimit);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean markSupported() {
|
||||||
|
return _inStream.markSupported();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int read(byte[] b, int off, int len) throws IOException {
|
||||||
|
return _inStream.read(b, off, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int read(byte[] b) throws IOException {
|
||||||
|
return _inStream.read(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void reset() throws IOException {
|
||||||
|
_inStream.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long skip(long n) throws IOException {
|
||||||
|
return _inStream.skip(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int read() throws IOException {
|
||||||
|
return _inStream.read();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,71 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* 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: David McKnight.
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* David McKnight (IBM) - [207100] decorated output stream
|
||||||
|
********************************************************************************/
|
||||||
|
package org.eclipse.rse.subsystems.files.core.servicesubsystem;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
|
import org.eclipse.rse.core.RSECorePlugin;
|
||||||
|
import org.eclipse.rse.core.events.ISystemRemoteChangeEvents;
|
||||||
|
import org.eclipse.rse.core.events.SystemRemoteChangeEvent;
|
||||||
|
import org.eclipse.rse.core.model.ISystemRegistry;
|
||||||
|
import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFileSubSystem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decorates an output stream that was created in the service layer.
|
||||||
|
* The purpose of this class is to notify upload after the stream is closed.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class FileSubSystemOutputStream extends OutputStream {
|
||||||
|
|
||||||
|
private OutputStream _outStream;
|
||||||
|
private String _remoteParent;
|
||||||
|
private String _remoteFile;
|
||||||
|
private IRemoteFileSubSystem _fs;
|
||||||
|
|
||||||
|
|
||||||
|
public FileSubSystemOutputStream(OutputStream outStream, String remoteParent, String remoteFile, IRemoteFileSubSystem fs)
|
||||||
|
{
|
||||||
|
_outStream = outStream;
|
||||||
|
_remoteParent = remoteParent;
|
||||||
|
_remoteFile = remoteFile;
|
||||||
|
_fs = fs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() throws IOException {
|
||||||
|
_outStream.close();
|
||||||
|
|
||||||
|
// notify that the file was uploaded
|
||||||
|
ISystemRegistry sr = RSECorePlugin.getTheSystemRegistry();
|
||||||
|
|
||||||
|
sr.fireEvent(new SystemRemoteChangeEvent(ISystemRemoteChangeEvents.SYSTEM_REMOTE_RESOURCE_UPLOADED, _remoteParent, _remoteFile, _fs));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void flush() throws IOException {
|
||||||
|
_outStream.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(byte[] b, int off, int len) throws IOException {
|
||||||
|
_outStream.write(b, off, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(byte[] b) throws IOException {
|
||||||
|
_outStream.write(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(int b) throws IOException {
|
||||||
|
_outStream.write(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue