Inheritance: SmbComTransactionResponse
Example #1
0
        /// <summary>This stream class is unbuffered.</summary>
        /// <remarks>
        /// This stream class is unbuffered. Therefore this method will always
        /// return 0 for streams connected to regular files. However, a
        /// stream created from a Named Pipe this method will query the server using a
        /// "peek named pipe" operation and return the number of available bytes
        /// on the server.
        /// </remarks>
        /// <exception cref="System.IO.IOException"></exception>
        public override int Available()
        {
            SmbNamedPipe               pipe;
            TransPeekNamedPipe         req;
            TransPeekNamedPipeResponse resp;

            if (File.Type != SmbFile.TypeNamedPipe)
            {
                return(0);
            }
            try
            {
                pipe = (SmbNamedPipe)File;
                File.Open(SmbFile.OExcl, pipe.PipeType & 0xFF0000, SmbFile.AttrNormal
                          , 0);
                req  = new TransPeekNamedPipe(File.Unc, File.Fid);
                resp = new TransPeekNamedPipeResponse(pipe);
                pipe.Send(req, resp);
                if (resp.status == TransPeekNamedPipeResponse.StatusDisconnected || resp.status
                    == TransPeekNamedPipeResponse.StatusServerEndClosed)
                {
                    File.Opened = false;
                    return(0);
                }
                return(resp.Available);
            }
            catch (SmbException se)
            {
                throw SeToIoe(se);
            }
        }
		/// <summary>This stream class is unbuffered.</summary>
		/// <remarks>
		/// This stream class is unbuffered. Therefore this method will always
		/// return 0 for streams connected to regular files. However, a
		/// stream created from a Named Pipe this method will query the server using a
		/// "peek named pipe" operation and return the number of available bytes
		/// on the server.
		/// </remarks>
		/// <exception cref="System.IO.IOException"></exception>
		public override int Available()
		{
			SmbNamedPipe pipe;
			TransPeekNamedPipe req;
			TransPeekNamedPipeResponse resp;
			if (File.Type != SmbFile.TypeNamedPipe)
			{
				return 0;
			}
			try
			{
				pipe = (SmbNamedPipe)File;
				File.Open(SmbFile.OExcl, pipe.PipeType & 0xFF0000, SmbFile.AttrNormal
					, 0);
				req = new TransPeekNamedPipe(File.Unc, File.Fid);
				resp = new TransPeekNamedPipeResponse(pipe);
				pipe.Send(req, resp);
				if (resp.status == TransPeekNamedPipeResponse.StatusDisconnected || resp.status 
					== TransPeekNamedPipeResponse.StatusServerEndClosed)
				{
					File.Opened = false;
					return 0;
				}
				return resp.Available;
			}
			catch (SmbException se)
			{
				throw SeToIoe(se);
			}
		}