当前位置: 首页>>代码示例>>C#>>正文


C# InputStream.Skip方法代码示例

本文整理汇总了C#中Sharpen.InputStream.Skip方法的典型用法代码示例。如果您正苦于以下问题:C# InputStream.Skip方法的具体用法?C# InputStream.Skip怎么用?C# InputStream.Skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sharpen.InputStream的用法示例。


在下文中一共展示了InputStream.Skip方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: _put

		/// <exception cref="NSch.SftpException"></exception>
		public virtual void _put(InputStream src, string dst, SftpProgressMonitor monitor
			, int mode)
		{
			try
			{
				((Channel.MyPipedInputStream)io_in).UpdateReadSide();
				byte[] dstb = Util.Str2byte(dst, fEncoding);
				long skip = 0;
				if (mode == RESUME || mode == APPEND)
				{
					try
					{
						SftpATTRS attr = _stat(dstb);
						skip = attr.GetSize();
					}
					catch (Exception)
					{
					}
				}
				//System.err.println(eee);
				if (mode == RESUME && skip > 0)
				{
					long skipped = src.Skip(skip);
					if (skipped < skip)
					{
						throw new SftpException(SSH_FX_FAILURE, "failed to resume for " + dst);
					}
				}
				if (mode == OVERWRITE)
				{
					SendOPENW(dstb);
				}
				else
				{
					SendOPENA(dstb);
				}
				ChannelHeader header = new ChannelHeader(this);
				header = Header(buf, header);
				int length = header.length;
				int type = header.type;
				Fill(buf, length);
				if (type != SSH_FXP_STATUS && type != SSH_FXP_HANDLE)
				{
					throw new SftpException(SSH_FX_FAILURE, "invalid type=" + type);
				}
				if (type == SSH_FXP_STATUS)
				{
					int i = buf.GetInt();
					ThrowStatusError(buf, i);
				}
				byte[] handle = buf.GetString();
				// handle
				byte[] data = null;
				bool dontcopy = true;
				if (!dontcopy)
				{
					// This case will not work anymore.
					data = new byte[obuf.buffer.Length - (5 + 13 + 21 + handle.Length + Session.buffer_margin
						)];
				}
				long offset = 0;
				if (mode == RESUME || mode == APPEND)
				{
					offset += skip;
				}
				int startid = seq;
				int ackcount = 0;
				int _s = 0;
				int _datalen = 0;
				if (!dontcopy)
				{
					// This case will not work anymore.
					_datalen = data.Length;
				}
				else
				{
					data = obuf.buffer;
					_s = 5 + 13 + 21 + handle.Length;
					_datalen = obuf.buffer.Length - _s - Session.buffer_margin;
				}
				int bulk_requests = rq.Size();
				while (true)
				{
					int nread = 0;
					int count = 0;
					int s = _s;
					int datalen = _datalen;
					do
					{
						nread = src.Read(data, s, datalen);
						if (nread > 0)
						{
							s += nread;
							datalen -= nread;
							count += nread;
						}
					}
					while (datalen > 0 && nread > 0);
					if (count <= 0)
//.........这里部分代码省略.........
开发者ID:LunarLanding,项目名称:ngit,代码行数:101,代码来源:ChannelSftp.cs

示例2: _put

		/// <exception cref="NSch.SftpException"></exception>
		public virtual void _put(InputStream src, string dst, SftpProgressMonitor monitor
			, int mode)
		{
			try
			{
				byte[] dstb = Util.Str2byte(dst, fEncoding);
				long skip = 0;
				if (mode == RESUME || mode == APPEND)
				{
					try
					{
						SftpATTRS attr = _stat(dstb);
						skip = attr.GetSize();
					}
					catch (Exception)
					{
					}
				}
				//System.err.println(eee);
				if (mode == RESUME && skip > 0)
				{
					long skipped = src.Skip(skip);
					if (skipped < skip)
					{
						throw new SftpException(SSH_FX_FAILURE, "failed to resume for " + dst);
					}
				}
				if (mode == OVERWRITE)
				{
					SendOPENW(dstb);
				}
				else
				{
					SendOPENA(dstb);
				}
				ChannelHeader header = new ChannelHeader(this);
				header = Header(buf, header);
				int length = header.length;
				int type = header.type;
				Fill(buf, length);
				if (type != SSH_FXP_STATUS && type != SSH_FXP_HANDLE)
				{
					throw new SftpException(SSH_FX_FAILURE, "invalid type=" + type);
				}
				if (type == SSH_FXP_STATUS)
				{
					int i = buf.GetInt();
					ThrowStatusError(buf, i);
				}
				byte[] handle = buf.GetString();
				// handle
				byte[] data = null;
				bool dontcopy = true;
				if (!dontcopy)
				{
					data = new byte[buf.buffer.Length - (5 + 13 + 21 + handle.Length + 32 + 20)];
				}
				// padding and mac
				long offset = 0;
				if (mode == RESUME || mode == APPEND)
				{
					offset += skip;
				}
				int startid = seq;
				int _ackid = seq;
				int ackcount = 0;
				while (true)
				{
					int nread = 0;
					int s = 0;
					int datalen = 0;
					int count = 0;
					if (!dontcopy)
					{
						datalen = data.Length - s;
					}
					else
					{
						data = buf.buffer;
						s = 5 + 13 + 21 + handle.Length;
						datalen = buf.buffer.Length - s - 32 - 20;
					}
					do
					{
						// padding and mac
						nread = src.Read(data, s, datalen);
						if (nread > 0)
						{
							s += nread;
							datalen -= nread;
							count += nread;
						}
					}
					while (datalen > 0 && nread > 0);
					if (count <= 0)
					{
						break;
					}
					int _i = count;
//.........这里部分代码省略.........
开发者ID:yayanyang,项目名称:monodevelop,代码行数:101,代码来源:ChannelSftp.cs

示例3: SkipFully

 /// <summary>Skip an entire region of an input stream.</summary>
 /// <remarks>
 /// Skip an entire region of an input stream.
 /// <p>
 /// The input stream's position is moved forward by the number of requested
 /// bytes, discarding them from the input. This method does not return until
 /// the exact number of bytes requested has been skipped.
 /// </remarks>
 /// <param name="fd">the stream to skip bytes from.</param>
 /// <param name="toSkip">total number of bytes to be discarded. Must be &gt;= 0.</param>
 /// <exception cref="Sharpen.EOFException">
 /// the stream ended before the requested number of bytes were
 /// skipped.
 /// </exception>
 /// <exception cref="System.IO.IOException">there was an error reading from the stream.
 /// 	</exception>
 public static void SkipFully(InputStream fd, long toSkip)
 {
     while (toSkip > 0)
     {
         long r = fd.Skip(toSkip);
         if (r <= 0)
         {
             throw new EOFException(JGitText.Get().shortSkipOfBlock);
         }
         toSkip -= r;
     }
 }
开发者ID:JamesChan,项目名称:ngit,代码行数:28,代码来源:IOUtil.cs


注:本文中的Sharpen.InputStream.Skip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。