mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-18 17:02:10 -10:00
* Uri.cs: Pragma disable warning 612 (Obsolete methods are being used by us internally). Ponder: should we instead move our methods to use new versions of the Obsoleted ones? 2006-03-11 Miguel de Icaza <[email protected]> * CodeNamespaceImportCollection.cs: It turns out that a lot of the errors flagged with "!" were just missing explicit interface implementations. Implement. 2006-03-11 Miguel de Icaza <[email protected]> * CodeDomConfigurationHandler.cs: Comment out unused methods. * TempFileCollection.cs: Implement explicitly some interface methods to get rid of the "!" errors on CorCompare. 2006-03-11 Miguel de Icaza <[email protected]> * Queue.cs: Flag as serializable. * LinkedList.cs (OnDeserialization): Fix signature. * SortedList.cs: Implement explicitly a few methods that were flagged by corcompare. 2006-03-11 Miguel de Icaza <[email protected]> * IOrderedDictionary.cs: Flag GetEnumerator as a "new" method to avoid warning. 2006-03-11 Miguel de Icaza <[email protected]> * ConfigurationSettings.cs (ChangeConfigurationSettings): Make internal to avoid warnings. This routine is called from System.Web with MethodInfo.Invoke. 2006-03-11 Miguel de Icaza <[email protected]> * DeflateStream.cs: Comment out DllImport that was not being used. 2006-03-11 Miguel de Icaza <[email protected]> * y * SerialPort.cs: Remove unused variable (writeBuffer). * SerialPortStream.cs (Dispose): override, not new. 2006-03-11 Miguel de Icaza <[email protected]> * WebClient.cs: Only expose the right methods to avoid warnings. * FtpDataStream.cs (Dispose): Fix signature. * FtpWebResponse.cs: Comment out keepAlive field (unused, sounds like we are missing features here). * IPAddress.cs: Move m_HashCode property to the end, and set pragmas to disable warnings. 2006-03-11 Miguel de Icaza <[email protected]> * MailAddress.cs: Comment out unused field to remove warning. 2006-03-11 Miguel de Icaza <[email protected]> * NetworkChange.cs: Use pragmas to eliminate warnings from events that we do not trigger yet. This is a candidate for using Aaron's NetworkManager code. But would make us depend on d-bus. * NetworkInformationException.cs: Use error_code for ErrorCode, instead of NativeErrorCode. Fixes warning. 2006-03-11 Miguel de Icaza <[email protected]> * AuthenticatedStream.cs: Fixed normative parameter names (yes, we need to do this everywhere one day). (Close): actually obey the "leaveInnerStreamOpen" setting from the constructor. 2006-03-11 Miguel de Icaza <[email protected]> * NetworkStream.cs (Dispose): Use the right signature depending on the profile being built. 2006-03-11 Miguel de Icaza <[email protected]> * X509Chain.cs: Flagged member as internal to avoid unused warning. * X500DistinguishedName.cs: Comment out unused names and move temporary unused variables inside the comments that were removed svn path=/trunk/mcs/; revision=57836
265 lines
6.0 KiB
C#
265 lines
6.0 KiB
C#
//
|
|
// System.Net.FtpDataStream.cs
|
|
//
|
|
// Authors:
|
|
// Carlos Alberto Cortez ([email protected])
|
|
//
|
|
// (c) Copyright 2006 Novell, Inc. (http://www.novell.com)
|
|
//
|
|
|
|
using System;
|
|
using System.IO;
|
|
using System.Net.Sockets;
|
|
using System.Runtime.Remoting.Messaging;
|
|
using System.Threading;
|
|
|
|
#if NET_2_0
|
|
|
|
namespace System.Net
|
|
{
|
|
class FtpDataStream : Stream, IDisposable
|
|
{
|
|
FtpWebRequest request;
|
|
NetworkStream networkStream;
|
|
bool disposed;
|
|
bool isRead;
|
|
int totalRead;
|
|
int contentLength;
|
|
|
|
ManualResetEvent closewh;
|
|
|
|
internal FtpDataStream (FtpWebRequest request, Socket socket, bool isRead)
|
|
{
|
|
if (request == null)
|
|
throw new ArgumentNullException ("request");
|
|
if (socket == null)
|
|
throw new ArgumentNullException ("socket");
|
|
if (!socket.Connected)
|
|
throw new ArgumentException ("socket");
|
|
|
|
this.request = request;
|
|
this.contentLength = socket.Available;
|
|
this.networkStream = new NetworkStream (socket, true);
|
|
this.isRead = isRead;
|
|
|
|
closewh = new ManualResetEvent (false);
|
|
}
|
|
|
|
public override bool CanRead {
|
|
get {
|
|
return isRead;
|
|
}
|
|
}
|
|
|
|
public override bool CanWrite {
|
|
get {
|
|
return !isRead;
|
|
}
|
|
}
|
|
|
|
public override bool CanSeek {
|
|
get {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public override long Length {
|
|
get {
|
|
throw new NotSupportedException ();
|
|
}
|
|
}
|
|
|
|
public override long Position {
|
|
get {
|
|
throw new NotSupportedException ();
|
|
}
|
|
set {
|
|
throw new NotSupportedException ();
|
|
}
|
|
}
|
|
|
|
internal NetworkStream NetworkStream {
|
|
get {
|
|
CheckDisposed ();
|
|
return networkStream;
|
|
}
|
|
}
|
|
|
|
public override void Close ()
|
|
{
|
|
((IDisposable) this).Dispose ();
|
|
}
|
|
|
|
public override void Flush ()
|
|
{
|
|
// Do nothing.
|
|
}
|
|
|
|
public override long Seek (long offset, SeekOrigin origin)
|
|
{
|
|
throw new NotSupportedException ();
|
|
}
|
|
|
|
public override void SetLength (long value)
|
|
{
|
|
throw new NotSupportedException ();
|
|
}
|
|
|
|
int ReadInternal (byte [] buffer, int offset, int size)
|
|
{
|
|
int nbytes;
|
|
try {
|
|
// Probably it would be better to have the socket here
|
|
nbytes = networkStream.Read (buffer, offset, size);
|
|
} catch (IOException exc) {
|
|
throw new ProtocolViolationException ("Server commited a protocol violation");
|
|
}
|
|
|
|
totalRead += nbytes;
|
|
if (nbytes == 0)
|
|
contentLength = totalRead;
|
|
if (totalRead >= contentLength)
|
|
request.SetTransferCompleted ();
|
|
|
|
return nbytes;
|
|
}
|
|
|
|
public override IAsyncResult BeginRead (byte [] buffer, int offset, int size, AsyncCallback cb, object state)
|
|
{
|
|
CheckDisposed ();
|
|
|
|
if (!isRead)
|
|
throw new NotSupportedException ();
|
|
if (buffer == null)
|
|
throw new ArgumentNullException ("buffer");
|
|
if (offset < 0 || offset > buffer.Length)
|
|
throw new ArgumentOutOfRangeException ("offset");
|
|
if (size < 0 || size > buffer.Length - offset)
|
|
throw new ArgumentOutOfRangeException ("offset+size");
|
|
|
|
ReadDelegate del = ReadInternal;
|
|
return del.BeginInvoke (buffer, offset, size, cb, state);
|
|
}
|
|
|
|
public override int EndRead (IAsyncResult asyncResult)
|
|
{
|
|
if (asyncResult == null)
|
|
throw new ArgumentNullException ("asyncResult");
|
|
|
|
AsyncResult ar = asyncResult as AsyncResult;
|
|
if (ar == null)
|
|
throw new ArgumentException ("Invalid asyncResult", "asyncResult");
|
|
|
|
ReadDelegate del = ar.AsyncDelegate as ReadDelegate;
|
|
if (del == null)
|
|
throw new ArgumentException ("Invalid asyncResult", "asyncResult");
|
|
|
|
return del.EndInvoke (asyncResult);
|
|
}
|
|
|
|
public override int Read (byte [] buffer, int offset, int size)
|
|
{
|
|
IAsyncResult ar = BeginRead (buffer, offset, size, null, null);
|
|
if (!ar.IsCompleted && !ar.AsyncWaitHandle.WaitOne (request.ReadWriteTimeout, false))
|
|
throw new WebException ("Read timed out.", WebExceptionStatus.Timeout);
|
|
|
|
return EndRead (ar);
|
|
}
|
|
|
|
|
|
delegate void WriteDelegate (byte [] buffer, int offset, int size);
|
|
|
|
void WriteInternal (byte [] buffer, int offset, int size)
|
|
{
|
|
try {
|
|
networkStream.Write (buffer, offset, size);
|
|
} catch (IOException exc) {
|
|
throw new ProtocolViolationException ();
|
|
}
|
|
}
|
|
|
|
public override IAsyncResult BeginWrite (byte [] buffer, int offset, int size, AsyncCallback cb, object state)
|
|
{
|
|
CheckDisposed ();
|
|
if (isRead)
|
|
throw new NotSupportedException ();
|
|
if (buffer == null)
|
|
throw new ArgumentNullException ("buffer");
|
|
if (offset < 0 || offset > buffer.Length)
|
|
throw new ArgumentOutOfRangeException ("offset");
|
|
if (size < 0 || size > buffer.Length - offset)
|
|
throw new ArgumentOutOfRangeException ("offset+size");
|
|
|
|
WriteDelegate del = WriteInternal;
|
|
return del.BeginInvoke (buffer, offset, size, cb, state);
|
|
}
|
|
|
|
public override void EndWrite (IAsyncResult asyncResult)
|
|
{
|
|
if (asyncResult == null)
|
|
throw new ArgumentNullException ("asyncResult");
|
|
|
|
AsyncResult ar = asyncResult as AsyncResult;
|
|
if (ar == null)
|
|
throw new ArgumentException ("Invalid asyncResult.", "asyncResult");
|
|
|
|
WriteDelegate del = ar.AsyncDelegate as WriteDelegate;
|
|
if (del == null)
|
|
throw new ArgumentException ("Invalid asyncResult.", "asyncResult");
|
|
|
|
del.EndInvoke (asyncResult);
|
|
}
|
|
|
|
public override void Write (byte [] buffer, int offset, int size)
|
|
{
|
|
IAsyncResult ar = BeginWrite (buffer, offset, size, null, null);
|
|
if (!ar.IsCompleted && !ar.AsyncWaitHandle.WaitOne (request.ReadWriteTimeout, false))
|
|
throw new WebException ("Read timed out.", WebExceptionStatus.Timeout);
|
|
|
|
EndWrite (ar);
|
|
}
|
|
|
|
~FtpDataStream ()
|
|
{
|
|
Dispose (false);
|
|
}
|
|
|
|
void IDisposable.Dispose ()
|
|
{
|
|
Dispose (true);
|
|
GC.SuppressFinalize (this);
|
|
}
|
|
|
|
protected override void Dispose (bool disposing)
|
|
{
|
|
if (disposed)
|
|
return;
|
|
|
|
disposed = true;
|
|
|
|
networkStream.Close ();
|
|
networkStream = null;
|
|
|
|
closewh.Set ();
|
|
}
|
|
|
|
void CheckDisposed ()
|
|
{
|
|
if (disposed)
|
|
throw new ObjectDisposedException (GetType ().FullName);
|
|
}
|
|
|
|
delegate int ReadDelegate (byte [] buffer, int offset, int size);
|
|
|
|
// We need to know whether the stream has been closed
|
|
internal ManualResetEvent CloseWaitHandle {
|
|
get {
|
|
return closewh;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|