상속: OutputStream
예제 #1
0
		public virtual void SetUp()
		{
			@out = new PipedOutputStream();
			@in = new PipedInputStream(@out);
			timer = new InterruptTimer();
			@is = new TimeoutInputStream(@in, timer);
			@is.SetTimeout(timeout);
		}
예제 #2
0
		public virtual void SetUp()
		{
			@out = new PipedOutputStream();
			@in = new TimeoutOutputStreamTest.FullPipeInputStream(this, @out);
			timer = new InterruptTimer();
			os = new TimeoutOutputStream(@out, timer);
			os.SetTimeout(timeout);
		}
예제 #3
0
		public void TestBigWrite ()
		{
			PipedInputStream pin = new PipedInputStream ();
			PipedOutputStream pout = new PipedOutputStream (pin);
			
			Random r = new Random (0);
			byte[] data = new byte [PipedInputStream.PIPE_SIZE * 3];
			r.NextBytes (data);
			
			ThreadPool.QueueUserWorkItem (delegate {
				pout.Write (data);
				pout.Close ();
			});
			int n = 0;
			byte[] buffer = new byte [100];
			int nr;
			while ((nr = pin.Read (buffer)) != -1) {
				for (int i=0; i < nr; i++)
					Assert.AreEqual (buffer[i], data[n++], "Position " + n);
			}
		}
예제 #4
0
                public _Thread_365(InternalLocalPushConnection _enclosing, Repository dst, PipedInputStream
					 out_r, PipedOutputStream in_w, string baseArg1)
                    : base(baseArg1)
                {
                    this._enclosing = _enclosing;
                    this.dst = dst;
                    this.out_r = out_r;
                    this.in_w = in_w;
                }
예제 #5
0
 /// <exception cref="NGit.Errors.TransportException"></exception>
 public InternalLocalPushConnection(TransportLocal _enclosing)
     : base(_enclosing)
 {
     this._enclosing = _enclosing;
     Repository dst;
     try
     {
         dst = new FileRepository(this._enclosing.remoteGitDir);
     }
     catch (IOException)
     {
         throw new TransportException(this.uri, JGitText.Get().notAGitDirectory);
     }
     PipedInputStream in_r;
     PipedOutputStream in_w;
     PipedInputStream out_r;
     PipedOutputStream out_w;
     try
     {
         in_r = new PipedInputStream();
         in_w = new PipedOutputStream(in_r);
         out_r = new PipedInputStream();
         out_w = new PipedOutputStream(out_r);
     }
     catch (IOException err)
     {
         dst.Close();
         throw new TransportException(this.uri, JGitText.Get().cannotConnectPipes, err);
     }
     this.worker = new _Thread_365(this, dst, out_r, in_w, "JGit-Receive-Pack");
     // Client side of the pipes should report the problem.
     // Clients side will notice we went away, and report.
     // Ignore close failure, we probably crashed above.
     // Ignore close failure, we probably crashed above.
     this.worker.Start();
     this.Init(in_r, out_w);
     this.ReadAdvertisedRefs();
 }
예제 #6
0
 /// <exception cref="NGit.Errors.TransportException"></exception>
 public InternalLocalFetchConnection(TransportLocal _enclosing)
     : base(_enclosing)
 {
     this._enclosing = _enclosing;
     Repository dst;
     try
     {
         dst = new FileRepository(this._enclosing.remoteGitDir);
     }
     catch (IOException)
     {
         throw new TransportException(this.uri, JGitText.Get().notAGitDirectory);
     }
     PipedInputStream in_r;
     PipedOutputStream in_w;
     PipedInputStream out_r;
     PipedOutputStream out_w;
     try
     {
         in_r = new PipedInputStream();
         in_w = new PipedOutputStream(in_r);
         out_r = new _PipedInputStream_218();
         // The client (BasePackFetchConnection) can write
         // a huge burst before it reads again. We need to
         // force the buffer to be big enough, otherwise it
         // will deadlock both threads.
         out_w = new PipedOutputStream(out_r);
     }
     catch (IOException err)
     {
         dst.Close();
         throw new TransportException(this.uri, JGitText.Get().cannotConnectPipes, err);
     }
     this.worker = new _Thread_233(this, dst, out_r, in_w, "JGit-Upload-Pack");
     // Client side of the pipes should report the problem.
     // Clients side will notice we went away, and report.
     // Ignore close failure, we probably crashed above.
     // Ignore close failure, we probably crashed above.
     this.worker.Start();
     this.Init(in_r, out_w);
     this.ReadAdvertisedRefs();
 }
예제 #7
0
			/// <exception cref="System.IO.IOException"></exception>
			public FullPipeInputStream(TimeoutOutputStreamTest _enclosing, PipedOutputStream 
				src) : base(src)
			{
				this._enclosing = _enclosing;
				src.Write(new byte[PipedInputStream.PIPE_SIZE]);
			}
		public override void Run()
		{
			try
			{
				if (lport == -1)
				{
					Type c = Sharpen.Runtime.GetType(target);
					daemon = (ForwardedTCPIPDaemon)System.Activator.CreateInstance(c);
					PipedOutputStream @out = new PipedOutputStream();
					io.SetInputStream(new Channel.PassiveInputStream(this, @out, 32 * 1024), false);
					daemon.SetChannel(this, GetInputStream(), @out);
					object[] foo = GetPort(GetSession(), rport);
					daemon.SetArg((object[])foo[3]);
					new Sharpen.Thread(daemon).Start();
				}
				else
				{
					socket = (factory == null) ? Util.CreateSocket(target, lport, TIMEOUT) : factory.
						CreateSocket(target, lport);
					socket.NoDelay = true;
					io.SetInputStream(socket.GetInputStream());
					io.SetOutputStream(socket.GetOutputStream());
				}
				SendOpenConfirmation();
			}
			catch (Exception)
			{
				SendOpenFailure(SSH_OPEN_ADMINISTRATIVELY_PROHIBITED);
				close = true;
				Disconnect();
				return;
			}
			thread = Sharpen.Thread.CurrentThread();
			Buffer buf = new Buffer(rmpsize);
			Packet packet = new Packet(buf);
			int i = 0;
			try
			{
				while (thread != null && io != null && io.@in != null)
				{
					i = [email protected](buf.buffer, 14, buf.buffer.Length - 14 - 32 - 20);
					// padding and mac
					if (i <= 0)
					{
						Eof();
						break;
					}
					packet.Reset();
					if (close)
					{
						break;
					}
					buf.PutByte(unchecked((byte)Session.SSH_MSG_CHANNEL_DATA));
					buf.PutInt(recipient);
					buf.PutInt(i);
					buf.Skip(i);
					GetSession().Write(packet, this, i);
				}
			}
			catch (Exception)
			{
			}
			//System.err.println(e);
			//thread=null;
			//eof();
			Disconnect();
		}
예제 #9
0
		/// <exception cref="NSch.JSchException"></exception>
		public override void Start()
		{
			try
			{
				PipedOutputStream pos = new PipedOutputStream();
				io.SetOutputStream(pos);
				PipedInputStream pis = new Channel.MyPipedInputStream(this, pos, 32 * 1024);
				io.SetInputStream(pis);
				io_in = io.@in;
				if (io_in == null)
				{
					throw new JSchException("channel is down");
				}
				Request request = new RequestSftp();
				request.DoRequest(GetSession(), this);
				buf = new Buffer(rmpsize);
				packet = new Packet(buf);
				int i = 0;
				int length;
				int type;
				byte[] str;
				// send SSH_FXP_INIT
				SendINIT();
				// receive SSH_FXP_VERSION
				ChannelHeader header = new ChannelHeader(this);
				header = Header(buf, header);
				length = header.length;
				if (length > MAX_MSG_LENGTH)
				{
					throw new SftpException(SSH_FX_FAILURE, "Received message is too long: " + length
						);
				}
				type = header.type;
				// 2 -> SSH_FXP_VERSION
				server_version = header.rid;
				//System.err.println("SFTP protocol server-version="+server_version);
				if (length > 0)
				{
					extensions = new Hashtable();
					// extension data
					Fill(buf, length);
					byte[] extension_name = null;
					byte[] extension_data = null;
					while (length > 0)
					{
						extension_name = buf.GetString();
						length -= (4 + extension_name.Length);
						extension_data = buf.GetString();
						length -= (4 + extension_data.Length);
						extensions.Put(Util.Byte2str(extension_name), Util.Byte2str(extension_data));
					}
				}
				lcwd = new FilePath(".").GetCanonicalPath();
			}
			catch (Exception e)
			{
				//System.err.println(e);
				if (e is JSchException)
				{
					throw (JSchException)e;
				}
				if (e is Exception)
				{
					throw new JSchException(e.ToString(), (Exception)e);
				}
				throw new JSchException(e.ToString());
			}
		}
예제 #10
0
			/// <exception cref="System.IO.IOException"></exception>
			public override void Close()
			{
				if (this.@out != null)
				{
					[email protected]();
				}
				this.@out = null;
			}
예제 #11
0
			/// <exception cref="System.IO.IOException"></exception>
			public PassiveInputStream(Channel _enclosing, PipedOutputStream @out) : base(_enclosing
				)
			{
				this._enclosing = _enclosing;
				this.@out = @out;
			}
예제 #12
0
			/// <exception cref="System.IO.IOException"></exception>
			public PassiveInputStream(Channel _enclosing, PipedOutputStream @out, int size) : 
				base(_enclosing)
			{
				this._enclosing = _enclosing;
				//  public String toString(){
				//      return "Channel: type="+new String(type)+",id="+id+",recipient="+recipient+",window_size="+window_size+",packet_size="+packet_size;
				//  }
				this.@out = @out;
			}
예제 #13
0
			/// <exception cref="System.IO.IOException"></exception>
			public MyPipedInputStream(Channel _enclosing, PipedOutputStream @out, int size) : 
				base(@out)
			{
				this._enclosing = _enclosing;
				this.buffer = new byte[size];
			}
예제 #14
0
			/// <exception cref="System.IO.IOException"></exception>
			public MyPipedInputStream(Channel _enclosing, PipedOutputStream @out) : base(@out
				)
			{
				this._enclosing = _enclosing;
			}
예제 #15
0
		public PipedInputStream (PipedOutputStream os): this ()
		{
			os.Attach (this);
		}
예제 #16
0
 public PipedInputStream(PipedOutputStream os) : this()
 {
     os.Attach(this);
 }
예제 #17
0
		public ConsoleTextArea(string[] argv) : base()
		{
			history = new List<string>();
			console1 = new ConsoleWriter(this);
			console2 = new ConsoleWriter(this);
			@out = new TextWriter(console1, true);
			err = new TextWriter(console2, true);
			PipedOutputStream outPipe = new PipedOutputStream();
			inPipe = new PrintWriter(outPipe);
			@in = new PipedInputStream();
			try
			{
				outPipe.Connect(@in);
			}
			catch (IOException exc)
			{
				Sharpen.Runtime.PrintStackTrace(exc);
			}
			GetDocument().AddDocumentListener(this);
			AddKeyListener(this);
			SetLineWrap(true);
			SetFont(new Font("Monospaced", 0, 12));
		}