Changeset 432 for trunk/Include/Classes/System/IO/FileStream.ab
- Timestamp:
- Feb 27, 2008, 1:04:59 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/Classes/System/IO/FileStream.ab
r430 r432 27 27 fileShare As DWord 28 28 fileOptions As DWord 29 ownsHandle As Boolean 29 30 30 31 offset As QWord 'オーバーラップドIO用 … … 33 34 /* コンストラクタ.NETと同じように実装は難しい、一先ず動くものを実装したが変更が必要だと思う */ 34 35 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 78 40 ' If (Environment.OSVersion.Platform As DWord) <> (PlatformID.Win32NT As DWord) Then 'ToDo: なぜかアクセス違反になる 79 41 op And= Not FILE_FLAG_OVERLAPPED … … 97 59 This.fileOptions = op 98 60 This.offset = 0 61 This.ownsHandle = True 99 62 End Sub 100 63 Sub FileStream(path As String, mode As FileMode, access As FileAccess, share As FileShare) … … 122 85 This.FileStream(path,mode,access,FileShare.None,FileOptions.None) 123 86 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 124 98 Public 125 99 /*! … … 259 233 /* CreateObjRef*/ 260 234 261 Override Sub Dispose(disposing As Boolean)262 Flush()263 CloseHandle(InterlockedExchangePointer(VarPtr(This.handle),NULL))264 End Sub265 266 235 Override Function EndRead(asyncResult As System.IAsyncResult) As Long 267 236 'TODO … … 450 419 451 420 Protected 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 452 428 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 454 434 End Function 455 435
Note:
See TracChangeset
for help on using the changeset viewer.