Index: trunk/ab5.0/ablib/src/Classes/System/IO/FileStream.ab
===================================================================
--- trunk/ab5.0/ablib/src/Classes/System/IO/FileStream.ab	(revision 560)
+++ trunk/ab5.0/ablib/src/Classes/System/IO/FileStream.ab	(revision 605)
@@ -1,85 +1,190 @@
+'Classes/System/IO/FileStream.ab
+
 Namespace System
 Namespace IO
 
-/* ほんとはmiscに入れるかかファイルを分けたほうがいいかもしれないが一先ず実装 */
-Enum FileOptions
-	None = 0
-	Asynchronous = FILE_FLAG_OVERLAPPED
-	DeleteOnClose = FILE_FLAG_DELETE_ON_CLOSE
-	Encrypted = FILE_ATTRIBUTE_ENCRYPTED
-	RandomAccess = FILE_FLAG_RANDOM_ACCESS
-	SequentialScan = FILE_FLAG_SEQUENTIAL_SCAN
-	WriteThrough = FILE_FLAG_WRITE_THROUGH
-End Enum
+/*
+(handle As IntPtr, access As FileAccess)
+(handle As IntPtr, access As FileAccess, ownsHandle As Boolean)
+(handle As IntPtr, access As FileAccess, ownsHandle As Boolean)
+(handle As IntPtr, access As FileAccess, ownsHandle As Boolean, isAsync As Boolean)
+(path As String, mode As FileMode)
+(path As String, mode As FileMode, access As FileAccess)
+(path As String, mode As FileMode, access As FileAccess, share As FileShare, useAsync As Boolean)
+(path As String, mode As FileMode, access As FileAccess, share As FileShare, options As FileOptions)
+(path As String, mode As FileMode, rights As FileSystemRights, share As FileShare, options As FileOptions)
+*/
 
 Class FileStream
 	Inherits Stream
-
-	handle As HANDLE
-
-	/*
-	ファイルハンドルからこれらを取得できれば、これらは入らないが
-	今のところは不明なので自前で実装するしかない
-	*/
-	filePath As String
-	fileMode As DWord
-	fileAccess As DWord
-	fileShare As DWord
-	fileOptions As DWord
-	ownsHandle As Boolean
-	
-	offset As QWord 'オーバーラップドIO用
-
-	Sub _Initialize(path As String, mode As FileMode, access As FileAccess, share As FileShare, options As FileOptions)
-		If ActiveBasic.IsNothing(path) Then
+Protected
+	Sub initialize(ac As DWord, owns As Boolean, isAsync As Boolean)
+		Imports ActiveBasic
+		ownsHandle = owns
+		If (ac And GENERIC_READ) = 0 Then
+			readFn = New Detail.Unreadable
+		End If
+		If (ac And GENERIC_WRITE) = 0 Then
+			writeFn = New Detail.Unwritable
+		End If
+		If GetFileType(handle) <> FILE_TYPE_DISK Then
+			seekFn = New Detail.Unseekable
+		End If
+		If isAsync Then
+			If IsNothing(seekFn) Then
+				seekFn = New Detail.OverlappedSeekable
+			End If
+			If IsNothing(readFn) Then
+				readFn = New Detail.OverlappedReadable
+			End If
+			If IsNothing(writeFn) Then
+				writeFn = New Detail.OverlappedWritable
+			End If
+		Else
+			If IsNothing(seekFn) Then
+				seekFn = New Detail.Seekable
+			End If
+			If IsNothing(readFn) Then
+				readFn = New Detail.Readable
+			End If
+			If IsNothing(writeFn) Then
+				writeFn = New Detail.Writable
+			End If
+		End If
+	End Sub
+
+	Sub openFile(path As String, mode As FileMode, rights As DWord, share As FileShare, ByRef options As FileOptions)
+		Imports ActiveBasic
+		If IsNothing(path) Then
 			Throw New ArgumentNullException("path")
 		ElseIf path.Length = 0 Then
-			Throw New ArgumentException
-		End If
-
-
-		Dim ac = access As DWord
+			Throw New ArgumentException("path.Length = 0")
+		End If
 		Dim sh = share As DWord
 		Dim mo = mode As DWord
 		Dim op = options As DWord
-'		If (Environment.OSVersion.Platform As DWord) <> (PlatformID.Win32NT As DWord) Then 'ToDo: なぜかアクセス違反になる
-			op And= Not FILE_FLAG_OVERLAPPED
-'		End If
-
-		This.handle=CreateFile(ToTCStr(path),ac,sh,ByVal NULL,mo,op,0)
-		If This.handle=INVALID_HANDLE_VALUE Then
+
+		If mode = FileMode.Append Then
+			mo = OPEN_ALWAYS
+			seekFn = New Detail.Unseekable
+		End If
+
+		Dim os = Environment.OSVersion
+		Dim platform = os.Platform As DWord
+		If platform = PlatformID.Win32Windows As DWord Or platform = PlatformID.Win32S As DWord Then
+			options = (op As DWord And Not FILE_FLAG_OVERLAPPED) As FileOptions
+		End If
+
+		handle = CreateFile(ToTCStr(path), rights, sh, ByVal NULL, mo, op, 0)
+		If handle = INVALID_HANDLE_VALUE Then
 		'エラー処理
 		'Throw ArgumentException
 		'Throw IOException
-		'Throw System.IO.FileNotFoundException 
-			This.handle=0
+		'Throw System.IO.FileNotFoundException
+			handle = 0
 			Detail.ThrowWinLastErrorIOException("Failed to open/create file.")
-			Exit Sub
-		End If
-
-		This.filePath = path
-		This.fileMode = mo
-		This.fileAccess = ac
-		This.fileShare = sh
-		This.fileOptions = op
-		This.offset = 0
-		This.ownsHandle = True
-
-		If FileMode.Append = This.fileMode Then
+		End If
+	
+		filePath = path
+
+		If mode = FileMode.Append Then
 			Seek(0, SeekOrigin.End)
 		End If
 	End Sub
 
+	Sub initWithOpen(path As String, mode As FileMode, access As FileAccess, share As FileShare, options As FileOptions)
+		openFile(path, mode, access As DWord, share, options)
+		initialize(access, True, UseOverlappled(options))
+	End Sub
+
+	Sub initWithOpen2(path As String, mode As FileMode, rights As DWord, share As FileShare, options As FileOptions)
+		openFile(path, mode, rights, share, options)
+		Dim ac = 0 As DWord
+		If (rights And GENERIC_READ) Or (rights And FILE_READ_DATA) Then
+			ac = (ac As DWord Or GENERIC_READ) As FileAccess
+		End If
+		If (rights And GENERIC_WRITE) Or (rights And FILE_WRITE_DATA) Then
+			ac = (ac As DWord Or GENERIC_WRITE) As FileAccess
+		End If
+		initialize(ac, True, UseOverlappled(options))
+	End Sub
+
+	Static Function UseOverlappled(options As FileOptions) As Boolean
+		Dim op = options As DWord
+		If op And FILE_FLAG_OVERLAPPED Then
+			UseOverlappled = True
+		Else
+			UseOverlappled = False
+		End If
+	End Function
+
+	Sub FileStream()
+	End Sub
 Public
-	/* コンストラクタ.NETと同じように実装は難しい、一先ず動くものを実装したが変更が必要だと思う */
+	/*!
+	@brief ファイルを開く。
+	@param[in] path ファイルパス
+	@param[in] mode 開き方
+	@param[in] rights 使用するアクセス権の指定
+	@param[in] share 共有方法
+	@param[in] option オプション
+	@date 2008/08/21
+	@auther Egtra
+	*/
+	Sub FileStream(path As String, mode As FileMode, rights As Security.AccessControl.FileSystemRights, share As FileShare, options As FileOptions)
+		initWithOpen2(path, mode, rights As DWord, share, options)
+	End Sub
+	/*!
+	@brief ファイルを開く。
+	@param[in] path ファイルパス
+	@param[in] mode 開き方
+	@param[in] access ファイルアクセスの指定
+	@param[in] share 共有方法
+	@param[in] option オプション
+	*/
 	Sub FileStream(path As String, mode As FileMode, access As FileAccess, share As FileShare, options As FileOptions)
-		_Initialize( path, mode, access, share, options )
-	End Sub
+		initWithOpen(path, mode, access, share, options)
+	End Sub
+	/*!
+	@brief ファイルを開く。
+	@param[in] path ファイルパス
+	@param[in] mode 開き方
+	@param[in] access ファイルアクセスの指定
+	@param[in] share 共有方法
+	@param[in] useAsync 非同期にするならTrue
+	@date 2008/08/21
+	@auther Egtra
+	*/
+	Sub FileStream(path As String, mode As FileMode, access As FileAccess, share As FileShare, useAsync As Boolean)
+		Dim options = FileOptions.None
+		If useAsync Then
+			options = FileOptions.Asynchronous
+		End If
+		initWithOpen(path, mode, access, share, options)
+	End Sub
+	/*!
+	@brief ファイルを開く。
+	@param[in] path ファイルパス
+	@param[in] mode 開き方
+	@param[in] access ファイルアクセスの指定
+	@param[in] share 共有方法
+	*/
 	Sub FileStream(path As String, mode As FileMode, access As FileAccess, share As FileShare)
-		_Initialize(path,mode,access,share,FileOptions.None)
-	End Sub
+		initWithOpen(path,mode,access,share,FileOptions.None)
+	End Sub
+	/*!
+	@brief ファイルを開く。
+	@param[in] path ファイルパス
+	@param[in] mode 開き方
+	@param[in] access ファイルアクセスの指定
+	*/
 	Sub FileStream(path As String, mode As FileMode, access As FileAccess)
-		_Initialize(path,mode,access,FileShare.None,FileOptions.None)
-	End Sub
+		initWithOpen(path,mode,access,FileShare.None,FileOptions.None)
+	End Sub
+	/*!
+	@brief ファイルを開く。
+	@param[in] path ファイルパス
+	@param[in] mode 開き方
+	*/
 	Sub FileStream(path As String, mode As FileMode)
 		Dim access As FileAccess
@@ -98,17 +203,20 @@
 				access=FileAccess.Write
 		End Select
-		_Initialize(path,mode,access,FileShare.None,FileOptions.None)
-	End Sub
-	/*
+		initWithOpen(path,mode,access,FileShare.None,FileOptions.None)
+	End Sub
+	/*!
+	@brief 既存ハンドルを基にストリームを作る。
+	@param[in] h ハンドル
+	@param[in] access ファイルアクセスの指定
+	@param[in] owns 所有権を保持するかどうか（TrueならDispose時に基のハンドルも閉じる）
+	@param[in] isAsync 重複IOを使用するかどうか
 	@date 2008/02/26
 	@auther Egtra
-	'不要になったら削除すること
-	*/
-	Sub FileStream(h As HANDLE, access As FileAccess, owns As Boolean)
+	@todo SafeFileHandle版に置き換えること
+	*/
+	Sub FileStream(h As HANDLE, access As FileAccess, owns = True As Boolean, isAsync = False As Boolean)
 		handle = h
-		fileAccess = access As DWord
-		ownsHandle = owns
-	End Sub
-
+		initialize(access, owns, isAsync)
+	End Sub
 Public
 	/*!
@@ -116,9 +224,5 @@
 	*/
 	Override Function CanRead() As Boolean
-		If This.fileAccess And GENERIC_READ Then
-			Return True
-		Else
-			Return False
-		End If
+		Return readFn.CanRead
 	End Function
 
@@ -127,15 +231,6 @@
 	*/
 	Override Function CanSeek() As Boolean
-		If GetFileType(This.handle)=FILE_TYPE_DISK Then
-			Return True
-		Else
-			Return False
-		End If
-	End Function
-
-'	Override Function CanTimeout() As Boolean
-'		/* ファイルがタイムアウトに対応しているかを返す */
-'		Return False /*今のところ対応していないのでFalse*/
-'	End Function*/
+		Return seekFn.CanSeek
+	End Function
 
 	/*!
@@ -143,42 +238,17 @@
 	*/
 	Override Function CanWrite() As Boolean
-		If This.fileAccess And GENERIC_WRITE Then
-			Return True
-		Else
-			Return False
-		End If
-	End Function
-
+		Return writeFn.CanWrite
+	End Function
+
+	/*!
+	@brief	保持しているハンドルを返す
+	*/
 	Function Handle() As HANDLE
 		Return handle
 	End Function
 
-	/*!
-	@brief	ファイルが非同期操作に対応しているかを返す
-	*/
-	Function IsAsync() As Boolean
-		If This.fileOptions And FILE_FLAG_OVERLAPPED /*FileOptions.Asynchronous*/ Then
-			Return True
-		Else
-			Return False
-		End If
-	End Function
-
-	Override Function Length() As Int64
-		disposedCheck()
-		If This.CanSeek() Then
-			Dim length = VarPtr(Length) As *ULARGE_INTEGER
-			length->LowPart = GetFileSize(This.handle, VarPtr(length->HighPart))
-			If LODWORD(Length) = INVALID_FILE_SIZE Then
-				Dim error = GetLastError()
-				If error <> NO_ERROR Then
-'					Detail.ThrowWinIOException("FileStream.Read: Failed to read.", error)
-				End If
-			End If
-			
-			If Length < 0 Then
-				Debug 'Throw OverflowException
-			End If
-		End If
+	Override Function Length() As QWord
+		disposedCheck()
+		Length = seekFn.Length(This)
 	End Function
 
@@ -186,77 +256,45 @@
 		Return This.filePath
 	End Function
-	
-	Override Sub Position(value As Int64)
-		disposedCheck()
-		If This.CanSeek() Then
-			If This.IsAsync() Then
-				offset = value As QWord
-			Else
-				Dim position As LARGE_INTEGER
-				position.LowPart=LODWORD(value)
-				position.HighPart=HIDWORD(value)
-				SetFilePointer(This.handle,position.LowPart,VarPtr(position.HighPart) As *DWord,FILE_BEGIN)
-			End If
-		End If
-	End Sub
-	Override Function Position() As Int64
-		disposedCheck()
-		If This.CanSeek() Then
-			If This.IsAsync() Then
-				Return offset As Int64
-			Else
-				Dim position As LARGE_INTEGER
-				ZeroMemory(VarPtr(position),SizeOf(LARGE_INTEGER))
-				position.LowPart=SetFilePointer(This.handle,position.LowPart,VarPtr(position.HighPart) As *DWord,FILE_CURRENT)
-				Return MAKEQWORD(position.LowPart,position.HighPart) As Int64
-			End If
-		End If
-	End Function
-
-/*	Override Sub ReadTimeout(value As Long)
-		'TODO
-	End Sub
-	Override Function ReadTimeout() As Long
-		'TODO
-	End Function*/
-
+
+	Override Sub Position(value As QWord)
+		disposedCheck()
+		seekFn.Position(This, value)
+	End Sub
+	Override Function Position() As QWord
+		disposedCheck()
+		Position = seekFn.Position(This)
+	End Function
+
+Public
 	/* Safe～Handle系の実装は要相談！！ */
 /*	Function SafeFileHandle() As SafeFileHandle
 	End Function*/
 
-	Override Sub WriteTimeout(value As Long)
-		'TODO
-	End Sub
-	Override Function WriteTimeout() As Long
-		'TODO
-	End Function
-	
-
 Public
 	Override Function BeginRead(buffer As *Byte, offset As Long, count As Long, callback As AsyncCallback, state As Object) As System.IAsyncResult
-		If This.IsAsync() Then
-		Else
-			Read(buffer,offset,count)
-		End If
+		disposedCheck()
+		If buffer = 0 Then
+			Throw New ArgumentNullException("FileStream.BeginRead", "buffer")
+		End If
+		BeginRead = readFn.BeginRead(This, buffer, offset, count, callback, state)
 	End Function
 
 	Override Function BeginWrite(buffer As *Byte, offset As Long, count As Long, callback As AsyncCallback, state As Object) As System.IAsyncResult
-		If This.IsAsync() Then
-		Else
-			Write(buffer,offset,count)
-		End If
-	End Function
-
-/*	CreateObjRef*/
-	
+		disposedCheck()
+		If buffer = 0 Then
+			Throw New ArgumentNullException("FileStream.BeginWrite", "buffer")
+		End If
+		BeginWrite = writeFn.BeginWrite(This, buffer, offset, count, callback, state)
+	End Function
+
 	Override Function EndRead(asyncResult As System.IAsyncResult) As Long
-		'TODO
+		disposedCheck()
+		EndRead = readFn.EndRead(This, asyncResult)
 	End Function
 
 	Override Sub EndWrite(asyncResult As System.IAsyncResult)
-		'TODO
-	End Sub
-
-/*	Equals*/
+		disposedCheck()
+		writeFn.EndWrite(This, asyncResult)
+	End Sub
 
 	Override Sub Flush()
@@ -264,5 +302,5 @@
 		Dim ret = FlushFileBuffers(This.handle)
 		If ret = FALSE Then
-'			Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
+			Detail.ThrowWinLastErrorIOException("FileStream.Flush: Failed to flush.")
 		End If
 	End Sub
@@ -272,21 +310,14 @@
 	End Function*/
 
-/*	GetLifetimeService*/
-
-/*	Override Function GetType() As TypeInfo
-		Return Super.GetType()
-	End Function*/
-
-/*	InitializeLifetimeService*/
-
-	Sub Lock(position As Int64, length As Int64)
+	Sub Lock(position As QWord, length As QWord)
 		disposedCheck()
 		If position < 0 Then
-			Throw New ArgumentOutOfRangeException("FileStream.Lock: An argument is negative value.", New System.Int64(position), "position")
+			Throw New ArgumentOutOfRangeException("FileStream.Lock: An argument is negative value.", New System.UInt64(position), "position")
 		ElseIf length < 0 Then
-			Throw New ArgumentOutOfRangeException("FileStream.Lock: An argument is negative value.", New System.Int64(length), "length")
-		End If
-		LockFile(handle, LODWORD(position As QWord), HIDWORD(position As QWord),
-			LODWORD(length As QWord), HIDWORD(length As QWord))
+			Throw New ArgumentOutOfRangeException("FileStream.Lock: An argument is negative value.", New System.UInt64(length), "length")
+		End If
+		If LockFile(handle, LODWORD(position), HIDWORD(position), LODWORD(length), HIDWORD(length)) = FALSE Then
+			Detail.ThrowWinLastErrorIOException("FileStream.Lock: Failed to lock.")
+		End If
 	End Sub
 
@@ -294,41 +325,7 @@
 		disposedCheck()
 		If buffer = 0 Then
-			Throw New ArgumentNullException("FileStream.Read: An argument is null value.", "buffer")
-		ElseIf Not This.CanRead() Then
-			Throw New NotSupportedException("FileStream.Read: This stream is not readable.")
-		End If
-
-		Dim ret As BOOL
-		Dim readBytes As DWord
-		If This.IsAsync() Then
-			Dim overlapped As OVERLAPPED
-			SetQWord(VarPtr(overlapped.Offset), offset)
-			overlapped.hEvent = CreateEvent(0, TRUE, FALSE, 0)
-			If overlapped.hEvent = 0 Then
-				Throw New OutOfMemoryException("FileStream.Read: Failed to create an event object.")
-			End If
-			Try
-				ret = ReadFile(This.handle, VarPtr(buffer[offset]), count, 0, overlapped)
-				If ret = FALSE Then
-					Dim error = GetLastError()
-					If error <> ERROR_IO_PENDING Then
-						Detail.ThrowWinIOException("FileStream.Read: Failed to read.", error)
-					End If
-				End If
-				ret = GetOverlappedResult(This.handle, overlapped, readBytes, TRUE)
-				If ret = FALSE Then
-					Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
-				End If
-				offset += Read
-			Finally
-				CloseHandle(overlapped.hEvent)
-			End Try
-		Else
-			ret = ReadFile(This.handle,VarPtr(buffer[offset]),count,VarPtr(readBytes),ByVal NULL)
-			If ret = FALSE Then
-				Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
-			End If
-		End If
-		Read = readBytes As Long
+			Throw New ArgumentNullException("FileStream.Read", "buffer")
+		End If
+		Read = readFn.Read(This, buffer, offset, count)
 	End Function
 
@@ -344,33 +341,5 @@
 	Override Function Seek(offset As Int64, origin As SeekOrigin) As Int64
 		disposedCheck()
-		If This.CanSeek() Then
-			If This.IsAsync() Then
-				Select Case origin
-					Case SeekOrigin.Begin
-						This.offset = offset
-					Case SeekOrigin.Current
-						This.offset += offset
-					Case SeekOrigin.End
-						This.offset = This.Length + offset
-				End Select
-				Seek = This.offset As Int64
-				If Seek < 0 Then
-'					Throw ArgumentException("FileStream.Seek: Cannot seek to negative offset.")
-				End If
-			Else
-				Dim seek = VarPtr(offset) As *ULARGE_INTEGER
-				Dim ret = SetFilePointer(This.handle, seek->LowPart, VarPtr(seek->HighPart), origin As DWord)
-				If ret = INVALID_SET_FILE_POINTER Then
-					Dim error = GetLastError()
-					If error = ERROR_NEGATIVE_SEEK Then
-'						Throw ArgumentException("FileStream.Seek: Cannot seek to negative offset.")
-					ElseIf error <> NO_ERROR Then
-'						Throw Detail.ThrowWinIOException("FileStream.Seek: Failed to seek.", error)
-					End If
-				End If
-				seek->LowPart = ret
-				Seek = offset
-			End If
-		End If
+		Seek = seekFn.Seek(This, offset, origin)
 	End Function
 
@@ -379,21 +348,8 @@
 	End Sub*/
 
-	Override Sub SetLength(value As Int64)
-		disposedCheck()
-		If This.CanWrite() and This.CanSeek() Then
-			If This.IsAsync() Then
-			Else
-				Dim current = This.Position()
-				This.Position(value)
-				Dim ret = SetEndOfFile(This.handle)
-				If ret = FALSE Then
-					Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
-				End If
-				Position = current
-			End If
-		End If
-	End Sub
-
-/*	Synchronized*/
+	Override Sub SetLength(value As QWord)
+		disposedCheck()
+		seekFn.SetLength(This, value)
+	End Sub
 
 	Override Function ToString() As String
@@ -401,15 +357,9 @@
 	End Function
 
-	Sub Unlock(position As Int64, length As Int64)
-		disposedCheck()
-		If position < 0 Then
-			Throw New ArgumentOutOfRangeException("FileStream.Lock: An argument is negative value.", New System.Int64(position), "position")
-		ElseIf length < 0 Then
-			Throw New ArgumentOutOfRangeException("FileStream.Lock: An argument is negative value.", New System.Int64(length), "length")
-		End If
-		Dim ret = UnlockFile(handle, LODWORD(position As QWord), HIDWORD(position As QWord),
-			LODWORD(length As QWord), HIDWORD(length As QWord))
+	Sub Unlock(position As QWord, length As QWord)
+		disposedCheck()
+		Dim ret = UnlockFile(handle, LODWORD(position), HIDWORD(position), LODWORD(length), HIDWORD(length))
 		If ret = FALSE Then
-			Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
+			Detail.ThrowWinLastErrorIOException("FileStream.Unlock failed")
 		End If
 	End Sub
@@ -417,20 +367,8 @@
 	Override Sub Write(buffer As *Byte, offset As Long, count As Long)
 		disposedCheck()
-		If This.CanWrite() Then
-			Dim writeBytes As DWord
-			If This.IsAsync() Then
-				Dim overlapped As OVERLAPPED
-				SetQWord(VarPtr(overlapped.Offset), offset)
-				overlapped.hEvent = CreateEvent(0, TRUE, FALSE, 0)
-				Dim ret = WriteFile(This.handle, VarPtr(buffer[offset]), count, 0, overlapped)
-				If ret <> FALSE Or GetLastError() = ERROR_IO_PENDING Then
-					GetOverlappedResult(This.handle, overlapped, writeBytes, TRUE)
-				End If
-				offset += writeBytes
-				CloseHandle(overlapped.hEvent)
-			Else
-				WriteFile(This.handle, VarPtr(buffer[offset]), count, VarPtr(writeBytes), ByVal NULL)
-			End If
-		End If
+		If buffer = 0 Then
+			Throw New ArgumentNullException("FileStream.Write", "buffer")
+		End If
+		writeFn.Write(This, buffer, offset, count)
 	End Sub
 
@@ -438,22 +376,22 @@
 	Override Sub Dispose(disposing As Boolean)
 		If handle <> 0 Then
-			Flush()
 			CloseHandle(InterlockedExchangePointer(ByVal VarPtr(handle), NULL))
 		End If
 	End Sub
 
-	Override Function CreateWaitHandle() As System.Threading.WaitHandle
-		Return New System.Threading.AutoResetEvent(False)
-	End Function
-
-Private
 	Sub disposedCheck()
 		If handle = 0 Then
-'			Throw ObjectDisposedException("FileStream: This stream has closed.")
-		End If
-	End Sub
-
+			Throw New ObjectDisposedException("FileStream: This stream has already closed.")
+		End If
+	End Sub
+
+Private
+	handle As HANDLE
+	seekFn As Detail.SeekFunctions
+	readFn As Detail.ReadFunctions
+	writeFn As Detail.WriteFunctions
+	filePath As String
+	ownsHandle As Boolean
 End Class
-
 
 End Namespace
