00001 using System;
00002 using IO = System.IO;
00003
00004 namespace Tamir.SharpSsh.java.io
00005 {
00009 public class JStream : IO.Stream
00010 {
00011 internal IO.Stream s;
00012 public JStream(IO.Stream s)
00013 {
00014 this.s = s;
00015 }
00016
00017 public override int Read(byte[] buffer, int offset, int count)
00018 {
00019 return s.Read(buffer, offset, count);
00020 }
00021
00022 public override int ReadByte()
00023 {
00024 return s.ReadByte();
00025 }
00026
00027 public int read(byte[] buffer, int offset, int count)
00028 {
00029 return Read(buffer, offset, count);
00030 }
00031
00032 public int read(byte[] buffer)
00033 {
00034 return Read(buffer, 0, buffer.Length);
00035 }
00036
00037 public int read()
00038 {
00039 return ReadByte();
00040 }
00041
00042 public void close()
00043 {
00044 this.Close();
00045 }
00046
00047 public override void Close()
00048 {
00049 s.Close ();
00050 }
00051
00052 public override void WriteByte(byte value)
00053 {
00054 s.WriteByte(value);
00055 }
00056
00057 public override void Write(byte[] buffer, int offset, int count)
00058 {
00059 s.Write(buffer, offset, count);
00060 }
00061
00062 public void write(byte[] buffer, int offset, int count)
00063 {
00064 Write(buffer, offset, count);
00065 }
00066
00067 public void write(byte[] buffer)
00068 {
00069 Write(buffer, 0, buffer.Length);
00070 }
00071
00072 public override bool CanRead
00073 {
00074 get {return s.CanRead;}
00075 }
00076 public override bool CanWrite
00077 {
00078 get
00079 {
00080 return s.CanWrite;
00081 }
00082 }
00083 public override bool CanSeek
00084 {
00085 get
00086 {
00087 return s.CanSeek;
00088 }
00089 }
00090 public override void Flush()
00091 {
00092 s.Flush();
00093 }
00094 public override long Length
00095 {
00096 get
00097 {
00098 return s.Length;
00099 }
00100 }
00101 public override long Position
00102 {
00103 get
00104 {
00105 return s.Position;
00106 }
00107 set
00108 {
00109 s.Position = value;
00110 }
00111 }
00112 public override void SetLength(long value)
00113 {
00114 s.SetLength(value);
00115 }
00116 public override long Seek(long offset, IO.SeekOrigin origin)
00117 {
00118 return s.Seek(offset, origin);
00119 }
00120
00121 public long skip(long len)
00122 {
00123
00124
00125 int i=0;
00126 int count = 0;
00127 byte[] buf = new byte[len];
00128 while(len>0)
00129 {
00130 i=Read(buf, count, (int)len);
00131 if(i<=0)
00132 {
00133 throw new Exception("inputstream is closed");
00134
00135 }
00136 count+=i;
00137 len-=i;
00138 }
00139 return count;
00140 }
00141
00142 public int available()
00143 {
00144 if(s is Tamir.Streams.PipedInputStream)
00145 {
00146 return ((Tamir.Streams.PipedInputStream)s).available();
00147 }
00148 throw new Exception("JStream.available() -- Method not implemented");
00149 }
00150
00151 public void flush()
00152 {
00153 s.Flush();
00154 }
00155 }
00156 }