Changeset 391 for trunk/Include/Classes


Ignore:
Timestamp:
Dec 7, 2007, 12:21:58 AM (16 years ago)
Author:
イグトランス (egtra)
Message:

FileStream非同期読み書きの修正、例外処理の追加。

Location:
trunk/Include/Classes
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Include/Classes/ActiveBasic/Strings/SPrintF.ab

    r388 r391  
    818818
    819819    Dim sb = New System.Text.StringBuilder
     820    If sb.Length = &hfeeefeee Then Debug
    820821    With sb
    821822        Dim prefixFunc = tr.Prefix
    822823        Dim prefix = prefixFunc(x, flags)
    823824        sb.Append(prefix)
     825        If sb.Length = &hfeeefeee Then Debug
    824826
    825827        Dim prefixLen = 0 As DWord
     
    832834        Dim bufStartPos = convertFunc(buf, x, flags)
    833835
     836        If sb.Length = &hfeeefeee Then Debug
    834837        Dim len = (tr.MaxSize - bufStartPos) As Long
    835838        If len < 0 Then
     
    841844
    842845        .Append(buf, bufStartPos + 1, len)
     846        If sb.Length = &hfeeefeee Then Debug
    843847
    844848        AdjustFieldWidth(sb, field, flags And (Not (Sign Or Blank)), prefixLen)
     849        If sb.Length = &hfeeefeee Then Debug
    845850    End With
    846851    FormatIntegerEx = sb.ToString()
  • trunk/Include/Classes/ActiveBasic/Strings/Strings.ab

    r385 r391  
    199199
    200200Namespace Detail
    201 Function Split(s As String, c As StrChar) As System.Collections.ArrayList
    202     Split = New System.Collections.ArrayList
     201Function Split(s As String, c As StrChar) As System.Collections.Generic.List<String>
     202    Split = New System.Collections.Generic.List<String>
    203203
    204204    Dim last = 0 As Long
  • trunk/Include/Classes/System/Exception.ab

    r385 r391  
    33#require <Classes/ActiveBasic/misc.ab>
    44
     5Namespace ActiveBasic
    56'右のコメントは対応するCOR_E_ナントカのコード
    67Const AB_E_EXCEPTION = &h80041500 '80131500
     
    1213Const AB_E_NOTSUPPORTED = &h80041515 '80131515
    1314Const AB_E_PLATFORMNOTSUPPORTED = &h80041539 '80131539
     15
     16End Namespace
    1417
    1518/*
     
    5760    Sub Exception()
    5861        init(GetType().FullName, Nothing)
    59         hr = AB_E_EXCEPTION
     62        hr = ActiveBasic.AB_E_EXCEPTION
    6063    End Sub
    6164    /*!
     
    6568    Sub Exception(message As String)
    6669        init(message, Nothing)
    67         hr = AB_E_EXCEPTION
     70        hr = ActiveBasic.AB_E_EXCEPTION
    6871    End Sub
    6972    /*!
     
    7477    Sub Exception(message As String, innerException As Exception)
    7578        init(message, innerException)
    76         hr = AB_E_EXCEPTION
     79        hr = ActiveBasic.AB_E_EXCEPTION
    7780    End Sub
    7881
     
    190193    Sub SystemException()
    191194        Exception(GetType().FullName, Nothing)
    192         HResult = AB_E_SYSTEM
     195        HResult = ActiveBasic.AB_E_SYSTEM
    193196    End Sub
    194197    /*!
     
    198201    Sub SystemException(message As String)
    199202        Exception(message, Nothing)
    200         HResult = AB_E_SYSTEM
     203        HResult = ActiveBasic.AB_E_SYSTEM
    201204    End Sub
    202205    /*!
     
    207210    Sub SystemException(message As String, innerException As Exception)
    208211        Exception(message, innerException)
    209         HResult = AB_E_SYSTEM
     212        HResult = ActiveBasic.AB_E_SYSTEM
    210213    End Sub
    211214End Class
     
    224227    Sub ArgumentException()
    225228        SystemException("One or more arguments have invalid value.", Nothing)
    226         HResult = AB_E_ARGUMENT
     229        HResult = ActiveBasic.AB_E_ARGUMENT
    227230    End Sub
    228231    /*!
     
    232235    Sub ArgumentException(message As String)
    233236        SystemException(message, Nothing)
    234         HResult = AB_E_ARGUMENT
     237        HResult = ActiveBasic.AB_E_ARGUMENT
    235238    End Sub
    236239    /*!
     
    241244    Sub ArgumentException(message As String, innerException As Exception)
    242245        SystemException(message, innerException)
    243         HResult = AB_E_ARGUMENT
     246        HResult = ActiveBasic.AB_E_ARGUMENT
    244247    End Sub
    245248    /*!
     
    251254        SystemException(message, Nothing)
    252255        param = paramName
    253         HResult = AB_E_ARGUMENT
     256        HResult = ActiveBasic.AB_E_ARGUMENT
    254257    End Sub
    255258    /*!
     
    262265        SystemException(message, innerException)
    263266        param = paramName
    264         HResult = AB_E_ARGUMENT
     267        HResult = ActiveBasic.AB_E_ARGUMENT
    265268    End Sub
    266269
     
    337340    Sub ArgumentOutOfRangeException()
    338341        ArgumentException("One or more arguments ware out of range value.", "", Nothing)
    339         HResult = AB_E_ARGUMENTOUTOFRANGE
     342        HResult = ActiveBasic.AB_E_ARGUMENTOUTOFRANGE
    340343    End Sub
    341344    /*!
     
    345348    Sub ArgumentOutOfRangeException(message As String)
    346349        ArgumentException(message, "", Nothing)
    347         HResult = AB_E_ARGUMENTOUTOFRANGE
     350        HResult = ActiveBasic.AB_E_ARGUMENTOUTOFRANGE
    348351    End Sub
    349352    /*!
     
    354357    Sub ArgumentOutOfRangeException(message As String, innerException As Exception)
    355358        ArgumentException(message, "", innerException)
    356         HResult = AB_E_ARGUMENTOUTOFRANGE
     359        HResult = ActiveBasic.AB_E_ARGUMENTOUTOFRANGE
    357360    End Sub
    358361    /*!
     
    363366    Sub ArgumentOutOfRangeException(message As String, paramName As String)
    364367        ArgumentException(message, paramName, Nothing)
    365         HResult = AB_E_ARGUMENTOUTOFRANGE
     368        HResult = ActiveBasic.AB_E_ARGUMENTOUTOFRANGE
    366369    End Sub
    367370    /*!
     
    374377        ArgumentException(message, paramName, Nothing)
    375378        actualValueObject = actualValue
    376         HResult = AB_E_ARGUMENTOUTOFRANGE
     379        HResult = ActiveBasic.AB_E_ARGUMENTOUTOFRANGE
    377380    End Sub
    378381
     
    411414    Sub IndexOutOfRangeException()
    412415        SystemException("The index was out of range value.", Nothing)
    413         HResult = AB_E_INDEXOUTOFRANGE
     416        HResult = ActiveBasic.AB_E_INDEXOUTOFRANGE
    414417    End Sub
    415418    /*!
     
    419422    Sub IndexOutOfRangeException(message As String)
    420423        SystemException(message, Nothing)
    421         HResult = AB_E_INDEXOUTOFRANGE
     424        HResult = ActiveBasic.AB_E_INDEXOUTOFRANGE
    422425    End Sub
    423426    /*!
     
    428431    Sub IndexOutOfRangeException(message As String, innerException As Exception)
    429432        SystemException(message, innerException)
    430         HResult = AB_E_INDEXOUTOFRANGE
     433        HResult = ActiveBasic.AB_E_INDEXOUTOFRANGE
    431434    End Sub
    432435End Class
     
    445448    Sub InvalidOperationException()
    446449        SystemException("The operation is invalid.", Nothing)
    447         HResult = AB_E_INVALIDOPERATION
     450        HResult = ActiveBasic.AB_E_INVALIDOPERATION
    448451    End Sub
    449452    /*!
     
    453456    Sub InvalidOperationException(message As String)
    454457        SystemException(message, Nothing)
    455         HResult = AB_E_INVALIDOPERATION
     458        HResult = ActiveBasic.AB_E_INVALIDOPERATION
    456459    End Sub
    457460    /*!
     
    462465    Sub InvalidOperationException(message As String, innerException As Exception)
    463466        SystemException(message, innerException)
    464         HResult = AB_E_INVALIDOPERATION
    465     End Sub
     467        HResult = ActiveBasic.AB_E_INVALIDOPERATION
     468    End Sub
     469End Class
     470
     471/*!
     472@brief  博されたオブジェクトを操作しようとしたことを表す例外
     473@author Egtra
     474@date   2007/12/06
     475*/
     476Class ObjectDisposedException
     477    Inherits InvalidOperationException
     478Public
     479    /*!
     480    @biref  コンストラクタ
     481    */
     482    Sub ObjectDisposedException()
     483        InvalidOperationException("The object has been disposed.", Nothing)
     484        HResult = ActiveBasic.AB_E_INVALIDOPERATION
     485    End Sub
     486    /*!
     487    @biref  コンストラクタ
     488    @param[in] message  エラーメッセージ
     489    */
     490    Sub ObjectDisposedException(message As String)
     491        InvalidOperationException(message, Nothing)
     492        HResult = ActiveBasic.AB_E_INVALIDOPERATION
     493    End Sub
     494    /*!
     495    @biref  コンストラクタ
     496    @param[in] message  エラーメッセージ
     497    @param[in] innerException   内部例外
     498    */
     499    Sub ObjectDisposedException(message As String, innerException As Exception)
     500        InvalidOperationException(message, innerException)
     501        HResult = ActiveBasic.AB_E_INVALIDOPERATION
     502    End Sub
     503    /*!
     504    @biref  コンストラクタ
     505    @param[in] objectName   操作しようとしたオブジェクトの名前
     506    @param[in] message  エラーメッセージ
     507    */
     508    Sub ObjectDisposedException(objectName As String, message As String)
     509        InvalidOperationException(message, Nothing)
     510        HResult = ActiveBasic.AB_E_INVALIDOPERATION
     511        objName = " object: " + objectName
     512    End Sub
     513    /*!
     514    @brief  この例外が発生したとき、操作しようとしていたオブジェクトの名前を返す。
     515    */
     516    Function ObjectName() As String
     517        Return objName
     518    End Function
     519
     520    Override Function ToString() As String
     521        ToString = Super.ToString()
     522        If Not ActiveBasic.IsNothing(objName) Then
     523            ToString += objName
     524        End If
     525    End Function
     526Private
     527    objName As String
    466528End Class
    467529
     
    513575    Sub NotSupportedException()
    514576        SystemException("This operation is not supported,", Nothing)
    515         HResult = AB_E_NOTSUPPORTED
     577        HResult = ActiveBasic.AB_E_NOTSUPPORTED
    516578    End Sub
    517579    /*!
     
    521583    Sub NotSupportedException(message As String)
    522584        SystemException(message, Nothing)
    523         HResult = AB_E_NOTSUPPORTED
     585        HResult = ActiveBasic.AB_E_NOTSUPPORTED
    524586    End Sub
    525587    /*!
     
    530592    Sub NotSupportedException(message As String, innerException As Exception)
    531593        SystemException(message, innerException)
    532         HResult = AB_E_NOTSUPPORTED
     594        HResult = ActiveBasic.AB_E_NOTSUPPORTED
    533595    End Sub
    534596End Class
     
    547609    Sub PlatformNotSupportedException()
    548610        NotSupportedException("This operation is not supported in this platform.", Nothing)
    549         HResult = AB_E_PLATFORMNOTSUPPORTED
     611        HResult = ActiveBasic.AB_E_PLATFORMNOTSUPPORTED
    550612    End Sub
    551613    /*!
     
    555617    Sub PlatformNotSupportedException(message As String)
    556618        NotSupportedException(message, Nothing)
    557         HResult = AB_E_PLATFORMNOTSUPPORTED
     619        HResult = ActiveBasic.AB_E_PLATFORMNOTSUPPORTED
    558620    End Sub
    559621    /*!
     
    564626    Sub PlatformNotSupportedException(message As String, innerException As Exception)
    565627        NotSupportedException(message, innerException)
    566         HResult = AB_E_PLATFORMNOTSUPPORTED
     628        HResult = ActiveBasic.AB_E_PLATFORMNOTSUPPORTED
    567629    End Sub
    568630End Class
  • trunk/Include/Classes/System/IO/FileStream.ab

    r388 r391  
    44/* ほんとはmiscに入れるかかファイルを分けたほうがいいかもしれないが一先ず実装 */
    55Enum FileOptions
    6     Asynchronous
    7     DeleteOnClose
    8     Encrypted
    9     None
    10     RandomAccess
    11     SequentialScan
    12     WriteThrough
     6    None = 0
     7    Asynchronous = FILE_FLAG_OVERLAPPED
     8    DeleteOnClose = FILE_FLAG_DELETE_ON_CLOSE
     9    Encrypted = FILE_ATTRIBUTE_ENCRYPTED
     10    RandomAccess = FILE_FLAG_RANDOM_ACCESS
     11    SequentialScan = FILE_FLAG_SEQUENTIAL_SCAN
     12    WriteThrough = FILE_FLAG_WRITE_THROUGH
    1313End Enum
    1414
     
    7575        End Select
    7676
    77         Select Case options
    78             Case FileOptions.Asynchronous
    79                 op=FILE_FLAG_OVERLAPPED
    80             Case FileOptions.DeleteOnClose
    81                 op=FILE_FLAG_DELETE_ON_CLOSE
    82             Case FileOptions.Encrypted
    83             Case FileOptions.None
    84                 op=0
    85             Case FileOptions.RandomAccess
    86                 op=FILE_FLAG_RANDOM_ACCESS
    87             Case FileOptions.SequentialScan
    88                 op=FILE_FLAG_SEQUENTIAL_SCAN
    89             Case FileOptions.WriteThrough
    90                 op=FILE_FLAG_WRITE_THROUGH
    91         End Select
    92 
    93         This.handle=CreateFile(path As PSTR,ac,sh,ByVal NULL,mo,op,0)
     77        op = options As DWord
     78        If Not Environment.OSVersion.Platform = PlatformID.Win32NT Then
     79            op And= Not FILE_FLAG_OVERLAPPED
     80        End If
     81
     82        This.handle=CreateFile(ToTCStr(path),ac,sh,ByVal NULL,mo,op,0)
    9483        If This.handle=INVALID_HANDLE_VALUE Then
    9584        'エラー処理
     
    134123    End Sub
    135124Public
     125    /*!
     126    @brief  ファイルが読み込みに対応しているかを返す
     127    */
    136128    Override Function CanRead() As Boolean
    137         /* ファイルが読み込みに対応しているかを返す */
    138129        If This.fileAccess And GENERIC_READ Then
    139130            Return True
     
    143134    End Function
    144135
     136    /*!
     137    @brief  ファイルがシークに対応しているかを返す
     138    */
    145139    Override Function CanSeek() As Boolean
    146         /* ファイルがシークに対応しているかを返す */
    147140        If GetFileType(This.handle)=FILE_TYPE_DISK Then
    148141            Return True
     
    157150'   End Function*/
    158151
     152    /*!
     153    @brief  ファイルが書き込みに対応しているかを返す
     154    */
    159155    Override Function CanWrite() As Boolean
    160         /* ファイルが書き込みに対応しているかを返す */
    161156        If This.fileAccess And GENERIC_WRITE Then
    162157            Return True
     
    168163    /*Handle*/
    169164
     165    /*!
     166    @brief  ファイルが非同期操作に対応しているかを返す
     167    */
    170168    Function IsAsync() As Boolean
    171         /* ファイルが非同期操作に対応しているかを返す */
    172169        If This.fileOptions And FILE_FLAG_OVERLAPPED /*FileOptions.Asynchronous*/ Then
    173170            Return True
     
    178175
    179176    Override Function Length() As Int64
     177        disposedCheck()
    180178        If This.CanSeek() Then
    181             Dim length As LARGE_INTEGER
    182             length.LowPart=GetFileSize(This.handle,VarPtr(length.HighPart) As *DWord)
    183             Return MAKEQWORD(length.LowPart,length.HighPart) As Int64
     179            Dim length = VarPtr(Length) As *ULARGE_INTEGER
     180            length->LowPart = GetFileSize(This.handle, VarPtr(length->HighPart))
     181            If LODWORD(Length) = INVALID_FILE_SIZE Then
     182                Dim error = GetLastError()
     183                If error <> NO_ERROR Then
     184'                   Detail.ThrowWinIOException("FileStream.Read: Failed to read.", error)
     185                End If
     186            End If
     187           
     188            If Length < 0 Then
     189                Debug 'Throw OverflowException
     190            End If
    184191        End If
    185192    End Function
     
    190197   
    191198    Override Sub Position(value As Int64)
     199        disposedCheck()
    192200        If This.CanSeek() Then
    193201            If This.IsAsync() Then
     
    202210    End Sub
    203211    Override Function Position() As Int64
     212        disposedCheck()
    204213        If This.CanSeek() Then
    205214            If This.IsAsync() Then
     
    266275
    267276    Override Sub Flush()
    268         FlushFileBuffers(This.handle)
     277        disposedCheck()
     278        Dim ret = FlushFileBuffers(This.handle)
     279        If ret = FALSE Then
     280'           Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
     281        End If
    269282    End Sub
    270283
     
    273286    End Function*/
    274287
    275     Override Function GetHashCode() As Long
    276         Return ObjPtr(This) As Long
    277     End Function
    278 
    279288/*  GetLifetimeService*/
    280289
     
    286295
    287296    Sub Lock(position As Int64, length As Int64)
     297        disposedCheck()
    288298        If position < 0 Then
    289299            Throw New ArgumentOutOfRangeException("FileStream.Lock: An argument is negative value.", New System.Int64(position), "position")
     
    296306
    297307    Override Function Read( buffer As *Byte, offset As Long, count As Long) As Long
    298         If This.CanRead() Then
    299             Dim readBytes As DWord
    300             If This.IsAsync() Then
    301                 Dim overlapped As OVERLAPPED
    302                 SetQWord(VarPtr(overlapped.Offset), offset)
    303                 Dim ret = ReadFile(This.handle, VarPtr(buffer[offset]), count, 0, overlapped)
     308        disposedCheck()
     309        If buffer = 0 Then
     310'           Throw ArgumentNullException("FileStream.Read: An argument is null value.", "buffer")
     311        ElseIf Not This.CanRead() Then
     312'           Throw NotSupportedException("FileStream.Read: This stream is not readable.")
     313        End If
     314
     315        Dim ret As BOOL
     316        Dim readBytes As DWord
     317        If This.IsAsync() Then
     318            Dim overlapped As OVERLAPPED
     319            SetQWord(VarPtr(overlapped.Offset), offset)
     320            overlapped.hEvent = CreateEvent(0, TRUE, FALSE, 0)
     321            If overlapped.hEvent = 0 Then
     322'               Throw OutOfMemoryException("FileStream.Read: Failed to create an event object.")
     323            End If
     324            Try
     325                ret = ReadFile(This.handle, VarPtr(buffer[offset]), count, 0, overlapped)
    304326                If ret = FALSE Then
    305                     If GetLastError() = ERROR_IO_PENDING Then
    306                         GetOverlappedResult(This.handle, overlapped, readBytes, TRUE)
     327                    Dim error = GetLastError()
     328                    If error <> ERROR_IO_PENDING Then
     329'                       Detail.ThrowWinIOException("FileStream.Read: Failed to read.", error)
    307330                    End If
    308331                End If
     332                ret = GetOverlappedResult(This.handle, overlapped, readBytes, TRUE)
     333                If ret = FALSE Then
     334'                   Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
     335                End If
    309336                offset += Read
    310             Else
    311                 ReadFile(This.handle,VarPtr(buffer[offset]),count,VarPtr(readBytes),ByVal NULL)
    312             End If
    313             Read = readBytes As Long
    314         End If
    315     End Function
    316 
    317 /*  ReferenceEquals*/
    318 
    319     Override Function Seek(offset As Int64, origin As SeekOrigin) As Long
     337            Finally
     338                CloseHandle(overlapped.hEvent)
     339            End Try
     340        Else
     341            ret = ReadFile(This.handle,VarPtr(buffer[offset]),count,VarPtr(readBytes),ByVal NULL)
     342            If ret = FALSE Then
     343'               Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
     344            End If
     345        End If
     346        Read = readBytes As Long
     347    End Function
     348
     349    /*!
     350    @brief  ストリームの現在位置を移動させる。
     351    @param[in] offset   originからの移動量
     352    @param[in] origin   移動の基準位置
     353    @return 移動後の新しい現在位置
     354    @exception DisposedException    既にストリームが閉じられている場合
     355    @exception ArgumentException    移動後の位置が負の位置(ファイル先頭より手前)になる場合
     356    @exception IOException  その他エラーが発生した場合
     357    */
     358    Override Function Seek(offset As Int64, origin As SeekOrigin) As Int64
     359        disposedCheck()
    320360        If This.CanSeek() Then
    321361            If This.IsAsync() Then
     
    328368                        This.offset = This.Length + offset
    329369                End Select
     370                Seek = This.offset As Int64
     371                If Seek < 0 Then
     372'                   Throw ArgumentException("FileStream.Seek: Cannot seek to negative offset.")
     373                End If
    330374            Else
    331                 Dim seek As LARGE_INTEGER
    332                 seek.LowPart=LODWORD(offset)
    333                 seek.HighPart=HIDWORD(offset)
    334                 Select Case origin
    335                     Case SeekOrigin.Begin
    336                         Return SetFilePointer(This.handle,seek.LowPart,VarPtr(seek.HighPart) As *DWord,FILE_BEGIN)
    337                     Case SeekOrigin.Current
    338                         Return SetFilePointer(This.handle,seek.LowPart,VarPtr(seek.HighPart) As *DWord,FILE_CURRENT)
    339                     Case SeekOrigin.End
    340                         Return SetFilePointer(This.handle,seek.LowPart,VarPtr(seek.HighPart) As *DWord,FILE_CURRENT)
    341                 End Select
     375                Dim seek = VarPtr(offset) As *ULARGE_INTEGER
     376                Dim ret = SetFilePointer(This.handle, seek->LowPart, VarPtr(seek->HighPart), origin As DWord)
     377                If ret = INVALID_SET_FILE_POINTER Then
     378                    Dim error = GetLastError()
     379                    If error = ERROR_NEGATIVE_SEEK Then
     380'                       Throw ArgumentException("FileStream.Seek: Cannot seek to negative offset.")
     381                    ElseIf error <> NO_ERROR Then
     382'                       Throw Detail.ThrowWinIOException("FileStream.Seek: Failed to seek.", error)
     383                    End If
     384                End If
     385                seek->LowPart = ret
     386                Seek = offset
    342387            End If
    343388        End If
     
    349394
    350395    Override Sub SetLength(value As Int64)
     396        disposedCheck()
    351397        If This.CanWrite() and This.CanSeek() Then
    352398            If This.IsAsync() Then
     
    354400                Dim current = This.Position()
    355401                This.Position(value)
    356                 SetEndOfFile(This.handle)
     402                Dim ret = SetEndOfFile(This.handle)
     403                If ret = FALSE Then
     404                    Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
     405                End If
     406                Position = current
    357407            End If
    358408        End If
     
    366416
    367417    Sub Unlock(position As Int64, length As Int64)
     418        disposedCheck()
    368419        If position < 0 Then
    369420            Throw New ArgumentOutOfRangeException("FileStream.Lock: An argument is negative value.", New System.Int64(position), "position")
     
    371422            Throw New ArgumentOutOfRangeException("FileStream.Lock: An argument is negative value.", New System.Int64(length), "length")
    372423        End If
    373         UnlockFile(handle, LODWORD(position As QWord), HIDWORD(position As QWord),
     424        Dim ret = UnlockFile(handle, LODWORD(position As QWord), HIDWORD(position As QWord),
    374425            LODWORD(length As QWord), HIDWORD(length As QWord))
    375     End Sub
    376 
     426        If ret = FALSE Then
     427            Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
     428        End If
     429    End Sub
    377430
    378431    Override Sub Write(buffer As *Byte, offset As Long, count As Long)
     432        disposedCheck()
    379433        If This.CanWrite() Then
    380434            Dim writeBytes As DWord
     
    382436                Dim overlapped As OVERLAPPED
    383437                SetQWord(VarPtr(overlapped.Offset), offset)
     438                overlapped.hEvent = CreateEvent(0, TRUE, FALSE, 0)
    384439                Dim ret = WriteFile(This.handle, VarPtr(buffer[offset]), count, 0, overlapped)
    385                 If ret = FALSE Then
    386                     If GetLastError() = ERROR_IO_PENDING Then
    387                         GetOverlappedResult(This.handle, overlapped, writeBytes, TRUE)
    388                     End If
     440                If ret <> FALSE Or GetLastError() = ERROR_IO_PENDING Then
     441                    GetOverlappedResult(This.handle, overlapped, writeBytes, TRUE)
    389442                End If
    390443                offset += writeBytes
     444                CloseHandle(overlapped.hEvent)
    391445            Else
    392446                WriteFile(This.handle, VarPtr(buffer[offset]), count, VarPtr(writeBytes), ByVal NULL)
     
    394448        End If
    395449    End Sub
    396 
    397450
    398451Protected
     
    405458    End Function
    406459
    407 /*  Dispose
    408     Finalize
    409     MemberwiseClone*/
    410460Private
     461    Sub disposedCheck()
     462        If handle = 0 Then
     463'           Throw ObjectDisposedException("FileStream: This stream has closed.")
     464        End If
     465    End Sub
     466
    411467End Class
    412468
  • trunk/Include/Classes/System/IO/Stream.ab

    r388 r391  
    7070    End Function
    7171
    72     Abstract Function Seek(offset As Int64, origin As SeekOrigin) As Long
     72    Abstract Function Seek(offset As Int64, origin As SeekOrigin) As Int64
    7373    Abstract Sub SetLength(value As Int64)
    7474    Abstract Sub Write(buffer As *Byte, offset As Long, count As Long)
  • trunk/Include/Classes/System/IO/misc.ab

    r318 r391  
    11
    2 TypeDef /* [Delegate] */ AsyncCallback = *Sub(ByRef ar As System.IAsyncResult)
     2Namespace System
     3Namespace IO
    34
    45Enum SeekOrigin
    5     Begin
    6     Current
    7     End
     6    Begin = FILE_BEGIN
     7    Current = FILE_CURRENT
     8    End = FILE_END
    89End Enum
    910
     
    1213    TopDirectoryOnly
    1314End Enum
     15
     16End Namespace 'IO
     17End Namespace 'System
  • trunk/Include/Classes/System/String.ab

    r388 r391  
    347347        Const Function Contains(s As String) As Boolean
    348348            If Object.ReferenceEquals(s, Nothing) Then
    349                 Throw New ArgumentNullException("String.Contains: An argument is out of range value.", "s")
     349                Throw New ArgumentNullException("String.Contains: An argument is null value.", "s")
    350350            ElseIf s = "" Then
    351351                Return True
  • trunk/Include/Classes/System/misc.ab

    r261 r391  
    1111    ' Properties
    1212    Function AsyncState() As Object
    13     Function AsyncWaitHandle() As System.Threading.WaitHandle
     13    Function AsyncWaitHandle() As Threading.WaitHandle
    1414    Function CompletedSynchronously() As Boolean
    1515    Function IsCompleted() As Boolean
     
    3636End Class
    3737
     38'Delegate Sub AsyncCallback(ar As IAsyncResult)
     39Delegate Sub AsyncCallback(ar As VoidPtr)
     40
     41
    3842End Namespace 'System
    3943#require <Classes/System/Threading/WaitHandle.ab>
  • trunk/Include/Classes/index.ab

    r388 r391  
    5858#require "./System/IO/DirectorySecurity.ab"
    5959#require "./System/IO/DriveInfo.ab"
     60#require "./System/IO/Exception.ab"
    6061#require "./System/IO/File.ab"
    6162#require "./System/IO/FileInfo.ab"
Note: See TracChangeset for help on using the changeset viewer.