Namespace System
Namespace IO


Class Stream
Public 'Protected
	Sub Stream():	End Sub
Public
	Virtual Sub ~Stream()
		This.Close()
	End Sub
Public
	Abstract Function CanRead() As Boolean
	Abstract Function CanSeek() As Boolean

	Virtual Function CanTimeout() As Boolean
		Return True
	End Function

	Abstract Function CanWrite() As Boolean
	Abstract Function Length() As Int64
	Abstract Sub Position(value As Int64)
	Abstract Function Position() As Int64

	Virtual Sub ReadTimeout(value As Long)
		' Throw InvalidOperationException
	End Sub

	Virtual Function ReadTimeout() As Long
		' Throw InvalidOperationException
	End Function

	Virtual Sub WriteTimeout(value As Long)
		' Throw InvalidOperationException
	End Sub

	Virtual Function WriteTimeout() As Long
		' Throw InvalidOperationException
	End Function

Public
	Virtual Function BeginRead(ByRef buffer[] As Byte, offset As Long, count As Long, callback As AsyncCallback, state As Object) As System.IAsyncResult:	End Function
	Virtual Function BeginWrite(ByRef buffer[] As Byte, offset As Long, count As Long, callback As AsyncCallback, state As Object) As System.IAsyncResult:	End Function
	Virtual Sub Close():	End Sub
	Virtual Function EndRead(ByRef asyncResult As System.IAsyncResult) As Long:	End Function
	Virtual Sub EndWrite(ByRef asyncResult As System.IAsyncResult):	End Sub
	Abstract Sub Flush()
	Abstract Function Read(buffer As *Byte, offset As Long, count As Long) As Long

	Virtual Function ReadByte() As Long
		Dim b As Byte
		Dim ret = Read(VarPtr(b), 0, 1)
		If ret <> 0 Then
			Return b
		Else
			Return -1
		End If
	End Function

	Abstract Function Seek(offset As Int64, origin As SeekOrigin) As Long
	Abstract Sub SetLength(value As Int64)
	Abstract Sub Write(buffer As *Byte, offset As Long, count As Long)

	Virtual Sub WriteByte(b As Byte)
		Write(VarPtr(b), 0, 1)
	End Sub
Protected
	Virtual Function CreateWaitHandle() As System.Threading.WaitHandle:	End Function
End Class


End Namespace
End Namespace
