Ignore:
Timestamp:
Feb 27, 2008, 1:04:59 AM (17 years ago)
Author:
イグトランス (egtra)
Message:

StreamReaderの完成。StringReaderの追加。
Consoleの追加(現在入力関係の一部のみ)。

File:
1 edited

Legend:

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

    r430 r432  
    2727    fileShare As DWord
    2828    fileOptions As DWord
     29    ownsHandle As Boolean
    2930   
    3031    offset As QWord 'オーバーラップドIO用
     
    3334    /* コンストラクタ.NETと同じように実装は難しい、一先ず動くものを実装したが変更が必要だと思う */
    3435    Sub FileStream(path As String, mode As FileMode, access As FileAccess, share As FileShare, options As FileOptions)
    35         Dim ac As DWord
    36         Dim mo As DWord
    37         Dim sh As DWord
    38         Dim op As DWord
    39 
    40         Select Case access
    41             Case FileAccess.Read
    42                 ac=GENERIC_READ
    43             Case FileAccess.ReadWrite
    44                 ac=GENERIC_READ or GENERIC_WRITE
    45             Case FileAccess.Write
    46                 ac=GENERIC_WRITE
    47         End Select
    48 
    49         Select Case share
    50             Case FileShare.DeleteFile
    51                 sh=FILE_SHARE_DELETE
    52             Case FileShare.None
    53                 sh=0
    54             Case FileShare.Read
    55                 sh=FILE_SHARE_READ
    56             Case FileShare.ReadWrite
    57                 sh=FILE_SHARE_READ or FILE_SHARE_WRITE
    58             Case FileShare.Write
    59                 sh=FILE_SHARE_WRITE
    60         End Select
    61 
    62         Select Case mode
    63             Case FileMode.Append
    64                 mo=OPEN_ALWAYS
    65             Case FileMode.Create
    66                 mo=CREATE_ALWAYS
    67             Case FileMode.CreateNew
    68                 mo=CREATE_NEW
    69             Case FileMode.Open
    70                 mo=OPEN_EXISTING
    71             Case FileMode.OpenOrCreate
    72                 mo=OPEN_ALWAYS
    73             Case FileMode.Truncate
    74                 mo=TRUNCATE_EXISTING
    75         End Select
    76 
    77         op = options As DWord
     36        Dim ac = access As DWord
     37        Dim sh = share As DWord
     38        Dim mo = mode As DWord
     39        Dim op = options As DWord
    7840'       If (Environment.OSVersion.Platform As DWord) <> (PlatformID.Win32NT As DWord) Then 'ToDo: なぜかアクセス違反になる
    7941            op And= Not FILE_FLAG_OVERLAPPED
     
    9759        This.fileOptions = op
    9860        This.offset = 0
     61        This.ownsHandle = True
    9962    End Sub
    10063    Sub FileStream(path As String, mode As FileMode, access As FileAccess, share As FileShare)
     
    12285        This.FileStream(path,mode,access,FileShare.None,FileOptions.None)
    12386    End Sub
     87    /*
     88    @date 2008/02/26
     89    @auther Egtra
     90    '不要になったら削除すること
     91    */
     92    Sub FileStream(h As HANDLE, access As FileAccess, owns As Boolean)
     93        handle = h
     94        fileAccess = access As DWord
     95        ownsHandle = owns
     96    End Sub
     97
    12498Public
    12599    /*!
     
    259233/*  CreateObjRef*/
    260234   
    261     Override Sub Dispose(disposing As Boolean)
    262         Flush()
    263         CloseHandle(InterlockedExchangePointer(VarPtr(This.handle),NULL))
    264     End Sub
    265 
    266235    Override Function EndRead(asyncResult As System.IAsyncResult) As Long
    267236        'TODO
     
    450419
    451420Protected
     421    Override Sub Dispose(disposing As Boolean)
     422        If handle <> 0 Then
     423            Flush()
     424            CloseHandle(InterlockedExchangePointer(VarPtr(handle), NULL))
     425        End If
     426    End Sub
     427
    452428    Override Function CreateWaitHandle() As System.Threading.WaitHandle
    453         Return New System.Threading.AutoResetEvent(False)
     429        '調査した限りでは、System.Threading.EventWaitHandleクラスをNewする模様。
     430        '現状ではSystem.Threading.WaitHandleクラスをNewしてからHandleにて設定
     431        Dim wh As System.Threading.WaitHandle
     432        wh.Handle=CreateEvent(NULL,TRUE,FALSE,NULL)
     433        Return wh
    454434    End Function
    455435
Note: See TracChangeset for help on using the changeset viewer.