Ignore:
Timestamp:
Feb 26, 2008, 3:33:49 AM (17 years ago)
Author:
イグトランス (egtra)
Message:

StreamReaderの実装開始。
Stringの+演算子で右辺がNullのときに起こるアクセス違反を回避。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Include/Classes/System/IO/FileStream.ab

    r391 r426  
    7676
    7777        op = options As DWord
    78         If Not Environment.OSVersion.Platform = PlatformID.Win32NT Then
     78'       If (Environment.OSVersion.Platform As DWord) <> (PlatformID.Win32NT As DWord) Then 'ToDo: なぜかアクセス違反になる
    7979            op And= Not FILE_FLAG_OVERLAPPED
    80         End If
     80'       End If
    8181
    8282        This.handle=CreateFile(ToTCStr(path),ac,sh,ByVal NULL,mo,op,0)
     
    305305    End Sub
    306306
    307     Override Function Read( buffer As *Byte, offset As Long, count As Long) As Long
     307    Override Function Read(buffer As *Byte, offset As Long, count As Long) As Long
    308308        disposedCheck()
    309309        If buffer = 0 Then
    310 '           Throw ArgumentNullException("FileStream.Read: An argument is null value.", "buffer")
     310            Throw New ArgumentNullException("FileStream.Read: An argument is null value.", "buffer")
    311311        ElseIf Not This.CanRead() Then
    312 '           Throw NotSupportedException("FileStream.Read: This stream is not readable.")
     312            Throw New NotSupportedException("FileStream.Read: This stream is not readable.")
    313313        End If
    314314
     
    320320            overlapped.hEvent = CreateEvent(0, TRUE, FALSE, 0)
    321321            If overlapped.hEvent = 0 Then
    322 '               Throw OutOfMemoryException("FileStream.Read: Failed to create an event object.")
     322                Throw New OutOfMemoryException("FileStream.Read: Failed to create an event object.")
    323323            End If
    324324            Try
     
    327327                    Dim error = GetLastError()
    328328                    If error <> ERROR_IO_PENDING Then
    329 '                       Detail.ThrowWinIOException("FileStream.Read: Failed to read.", error)
     329                        Detail.ThrowWinIOException("FileStream.Read: Failed to read.", error)
    330330                    End If
    331331                End If
    332332                ret = GetOverlappedResult(This.handle, overlapped, readBytes, TRUE)
    333333                If ret = FALSE Then
    334 '                   Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
     334                    Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
    335335                End If
    336336                offset += Read
     
    341341            ret = ReadFile(This.handle,VarPtr(buffer[offset]),count,VarPtr(readBytes),ByVal NULL)
    342342            If ret = FALSE Then
    343 '               Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
     343                Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
    344344            End If
    345345        End If
Note: See TracChangeset for help on using the changeset viewer.