home *** CD-ROM | disk | FTP | other *** search
- package java.lang;
-
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
- import java.io.PipedInputStream;
- import java.io.PipedOutputStream;
- import java.util.Vector;
-
- class ProcessInputStream extends PipedInputStream implements Runnable {
- InputStream ins;
- OutputStream outs;
- // $FF: renamed from: p java.lang.UNIXProcess
- UNIXProcess field_0;
- byte[] writeBuf;
- boolean chaining;
- int inPos;
- Vector chain;
-
- ProcessInputStream(UNIXProcess var1, PipedOutputStream var2, InputStream var3) throws IOException {
- super(var2);
- this.field_0 = var1;
- this.outs = var2;
- this.ins = var3;
- this.writeBuf = null;
- this.chaining = false;
- this.inPos = 0;
- this.chain = new Vector();
- }
-
- protected synchronized void receive(int var1) throws IOException {
- if (this.chaining) {
- if (this.inPos == 1024) {
- this.writeBuf = new byte[1024];
- this.chain.addElement(this.writeBuf);
- this.inPos = 0;
- }
-
- this.writeBuf[this.inPos++] = (byte)var1;
- } else {
- super.receive(var1);
- if (super.in == super.out) {
- this.inPos = 0;
- this.chaining = true;
- this.writeBuf = new byte[1024];
- this.chain.addElement(this.writeBuf);
- }
-
- }
- }
-
- public synchronized int read() throws IOException {
- if (!this.chaining) {
- return super.read();
- } else {
- if (super.in == -1 && this.chain.size() != 0) {
- super.buffer = (byte[])this.chain.elementAt(0);
- this.chain.removeElementAt(0);
- super.in = super.out = 0;
- if (this.chain.size() == 0) {
- if (this.inPos == 0) {
- super.in = -1;
- } else if (this.inPos == 1024) {
- super.in = 0;
- } else {
- super.in = this.inPos;
- }
-
- this.chaining = false;
- }
- }
-
- return super.read();
- }
- }
-
- public int available() throws IOException {
- return super.available() + 1024 * this.chain.size();
- }
-
- public void run() {
- byte[] var1 = new byte[512];
-
- while(true) {
- try {
- int var2;
- if ((var2 = this.ins.read(var1)) < 0) {
- break;
- }
-
- this.outs.write(var1, 0, var2);
- } catch (IOException var4) {
- break;
- }
- }
-
- try {
- this.outs.close();
- } catch (IOException var3) {
- }
-
- this.field_0.decrNumReaders();
- }
- }
-