Changeset 605 for trunk


Ignore:
Timestamp:
Aug 21, 2008, 7:21:48 PM (16 years ago)
Author:
イグトランス (egtra)
Message:

非同期入出力(Begin/End-Read/Writeメソッド)を実装。

Location:
trunk/ab5.0/ablib/src/Classes
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/src/Classes/System/IO/Exception.ab

    r584 r605  
    6161    @brief  Windowsエラー値を基にIOExceptionを投げる。
    6262    @param[in] message  エラーメッセージ
     63    @param[in] error    エラーコード
    6364    @author Egtra
    6465    @date   2007/12/06
    6566    */
    6667    Sub ThrowWinIOException(msg As String, error As DWord)
    67         Throw New IOException(msg, HRESULT_FROM_WIN32(error))
     68        Throw GetWinIOException(msg, error)
    6869    End Sub
     70
     71    /*!
     72    @brief  Windowsエラー値を基にIOExceptionインスタンスを作成する。
     73    @param[in] message  エラーメッセージ
     74    @param[in] error    エラーコード
     75    @return 作成されたIOExceptionインスタンス
     76    @author Egtra
     77    @date   2008/08/21
     78    */
     79    Function GetWinIOException(msg As String, error As DWord) As IOException
     80        Return New IOException(msg, HRESULT_FROM_WIN32(error))
     81    End Function
    6982
    7083    /*!
     
    7487    @date   2007/12/06
    7588    */
    76     Sub ThrowWinLastErrorIOException(msg As String)
    77         Throw New IOException(msg, HRESULT_FROM_WIN32(GetLastError()))
     89    Sub ThrowWinLastErrorIOException(msg = Nothing As String)
     90        Throw GetWinLastErrorIOException(msg)
    7891    End Sub
     92
     93
     94    /*!
     95    @brief  GetLastError()の値を基にIOExceptionインスタンスを作成する。
     96    @param[in] message  エラーメッセージ
     97    @return 作成されたIOExceptionインスタンス
     98    @author Egtra
     99    @date   2008/08/21
     100    */
     101    Function GetWinLastErrorIOException(msg As String) As IOException
     102        Return New IOException(msg, HRESULT_FROM_WIN32(GetLastError()))
     103    End Function
    79104End Namespace
    80105
  • trunk/ab5.0/ablib/src/Classes/System/IO/File.ab

    r476 r605  
    11Namespace System
    22Namespace IO
    3 
    4 /*
    5 @brief ファイルのアクセス方法を表す
    6 */
    7 Enum FileAccess
    8     Read      = GENERIC_READ
    9     ReadWrite = GENERIC_READ Or GENERIC_WRITE
    10     Write     = GENERIC_WRITE
    11 End Enum
    12 
    13 /*
    14 @brief ファイルの属性を表す
    15 */
    16 Enum FileAttributes
    17     Archive           = FILE_ATTRIBUTE_ARCHIVE
    18     Compressed        = FILE_ATTRIBUTE_COMPRESSED
    19     Device            = FILE_ATTRIBUTE_DEVICE
    20     Directory         = FILE_ATTRIBUTE_DIRECTORY
    21     Encrypted         = FILE_ATTRIBUTE_ENCRYPTED
    22     Hidden            = FILE_ATTRIBUTE_HIDDEN
    23     Normal            = FILE_ATTRIBUTE_NORMAL
    24     NotContentIndexed = FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
    25     Offline           = FILE_ATTRIBUTE_OFFLINE
    26     ReadOnly          = FILE_ATTRIBUTE_READONLY
    27     ReparsePoint      = FILE_ATTRIBUTE_REPARSE_POINT
    28     SparseFile        = FILE_ATTRIBUTE_SPARSE_FILE
    29     System            = FILE_ATTRIBUTE_SYSTEM
    30     Temporary         = FILE_ATTRIBUTE_TEMPORARY
    31 End Enum
    32 
    33 /*
    34 @brief ファイルの作成モードを表す
    35 */
    36 Enum FileMode
    37     Append       = OPEN_ALWAYS
    38     Create       = CREATE_ALWAYS
    39     CreateNew    = CREATE_NEW
    40     Open         = OPEN_EXISTING
    41     OpenOrCreate = OPEN_ALWAYS
    42     Truncate     = TRUNCATE_EXISTING
    43 End Enum
    44 
    45 /*
    46 @brief ファイルの共有を表す
    47 */
    48 Enum FileShare
    49     None       = 0
    50     Read       = FILE_SHARE_READ
    51     Write      = FILE_SHARE_WRITE
    52     ReadWrite  = FILE_SHARE_READ Or FILE_SHARE_WRITE
    53     DeleteFile = FILE_SHARE_DELETE
    54 End Enum
    553
    564/*
  • trunk/ab5.0/ablib/src/Classes/System/IO/FileStream.ab

    r560 r605  
     1'Classes/System/IO/FileStream.ab
     2
    13Namespace System
    24Namespace IO
    35
    4 /* ほんとはmiscに入れるかかファイルを分けたほうがいいかもしれないが一先ず実装 */
    5 Enum FileOptions
    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
    13 End Enum
     6/*
     7(handle As IntPtr, access As FileAccess)
     8(handle As IntPtr, access As FileAccess, ownsHandle As Boolean)
     9(handle As IntPtr, access As FileAccess, ownsHandle As Boolean)
     10(handle As IntPtr, access As FileAccess, ownsHandle As Boolean, isAsync As Boolean)
     11(path As String, mode As FileMode)
     12(path As String, mode As FileMode, access As FileAccess)
     13(path As String, mode As FileMode, access As FileAccess, share As FileShare, useAsync As Boolean)
     14(path As String, mode As FileMode, access As FileAccess, share As FileShare, options As FileOptions)
     15(path As String, mode As FileMode, rights As FileSystemRights, share As FileShare, options As FileOptions)
     16*/
    1417
    1518Class FileStream
    1619    Inherits Stream
    17 
    18     handle As HANDLE
    19 
    20     /*
    21     ファイルハンドルからこれらを取得できれば、これらは入らないが
    22     今のところは不明なので自前で実装するしかない
    23     */
    24     filePath As String
    25     fileMode As DWord
    26     fileAccess As DWord
    27     fileShare As DWord
    28     fileOptions As DWord
    29     ownsHandle As Boolean
    30    
    31     offset As QWord 'オーバーラップドIO用
    32 
    33     Sub _Initialize(path As String, mode As FileMode, access As FileAccess, share As FileShare, options As FileOptions)
    34         If ActiveBasic.IsNothing(path) Then
     20Protected
     21    Sub initialize(ac As DWord, owns As Boolean, isAsync As Boolean)
     22        Imports ActiveBasic
     23        ownsHandle = owns
     24        If (ac And GENERIC_READ) = 0 Then
     25            readFn = New Detail.Unreadable
     26        End If
     27        If (ac And GENERIC_WRITE) = 0 Then
     28            writeFn = New Detail.Unwritable
     29        End If
     30        If GetFileType(handle) <> FILE_TYPE_DISK Then
     31            seekFn = New Detail.Unseekable
     32        End If
     33        If isAsync Then
     34            If IsNothing(seekFn) Then
     35                seekFn = New Detail.OverlappedSeekable
     36            End If
     37            If IsNothing(readFn) Then
     38                readFn = New Detail.OverlappedReadable
     39            End If
     40            If IsNothing(writeFn) Then
     41                writeFn = New Detail.OverlappedWritable
     42            End If
     43        Else
     44            If IsNothing(seekFn) Then
     45                seekFn = New Detail.Seekable
     46            End If
     47            If IsNothing(readFn) Then
     48                readFn = New Detail.Readable
     49            End If
     50            If IsNothing(writeFn) Then
     51                writeFn = New Detail.Writable
     52            End If
     53        End If
     54    End Sub
     55
     56    Sub openFile(path As String, mode As FileMode, rights As DWord, share As FileShare, ByRef options As FileOptions)
     57        Imports ActiveBasic
     58        If IsNothing(path) Then
    3559            Throw New ArgumentNullException("path")
    3660        ElseIf path.Length = 0 Then
    37             Throw New ArgumentException
    38         End If
    39 
    40 
    41         Dim ac = access As DWord
     61            Throw New ArgumentException("path.Length = 0")
     62        End If
    4263        Dim sh = share As DWord
    4364        Dim mo = mode As DWord
    4465        Dim op = options As DWord
    45 '       If (Environment.OSVersion.Platform As DWord) <> (PlatformID.Win32NT As DWord) Then 'ToDo: なぜかアクセス違反になる
    46             op And= Not FILE_FLAG_OVERLAPPED
    47 '       End If
    48 
    49         This.handle=CreateFile(ToTCStr(path),ac,sh,ByVal NULL,mo,op,0)
    50         If This.handle=INVALID_HANDLE_VALUE Then
     66
     67        If mode = FileMode.Append Then
     68            mo = OPEN_ALWAYS
     69            seekFn = New Detail.Unseekable
     70        End If
     71
     72        Dim os = Environment.OSVersion
     73        Dim platform = os.Platform As DWord
     74        If platform = PlatformID.Win32Windows As DWord Or platform = PlatformID.Win32S As DWord Then
     75            options = (op As DWord And Not FILE_FLAG_OVERLAPPED) As FileOptions
     76        End If
     77
     78        handle = CreateFile(ToTCStr(path), rights, sh, ByVal NULL, mo, op, 0)
     79        If handle = INVALID_HANDLE_VALUE Then
    5180        'エラー処理
    5281        'Throw ArgumentException
    5382        'Throw IOException
    54         'Throw System.IO.FileNotFoundException 
    55             This.handle=0
     83        'Throw System.IO.FileNotFoundException
     84            handle = 0
    5685            Detail.ThrowWinLastErrorIOException("Failed to open/create file.")
    57             Exit Sub
    58         End If
    59 
    60         This.filePath = path
    61         This.fileMode = mo
    62         This.fileAccess = ac
    63         This.fileShare = sh
    64         This.fileOptions = op
    65         This.offset = 0
    66         This.ownsHandle = True
    67 
    68         If FileMode.Append = This.fileMode Then
     86        End If
     87   
     88        filePath = path
     89
     90        If mode = FileMode.Append Then
    6991            Seek(0, SeekOrigin.End)
    7092        End If
    7193    End Sub
    7294
     95    Sub initWithOpen(path As String, mode As FileMode, access As FileAccess, share As FileShare, options As FileOptions)
     96        openFile(path, mode, access As DWord, share, options)
     97        initialize(access, True, UseOverlappled(options))
     98    End Sub
     99
     100    Sub initWithOpen2(path As String, mode As FileMode, rights As DWord, share As FileShare, options As FileOptions)
     101        openFile(path, mode, rights, share, options)
     102        Dim ac = 0 As DWord
     103        If (rights And GENERIC_READ) Or (rights And FILE_READ_DATA) Then
     104            ac = (ac As DWord Or GENERIC_READ) As FileAccess
     105        End If
     106        If (rights And GENERIC_WRITE) Or (rights And FILE_WRITE_DATA) Then
     107            ac = (ac As DWord Or GENERIC_WRITE) As FileAccess
     108        End If
     109        initialize(ac, True, UseOverlappled(options))
     110    End Sub
     111
     112    Static Function UseOverlappled(options As FileOptions) As Boolean
     113        Dim op = options As DWord
     114        If op And FILE_FLAG_OVERLAPPED Then
     115            UseOverlappled = True
     116        Else
     117            UseOverlappled = False
     118        End If
     119    End Function
     120
     121    Sub FileStream()
     122    End Sub
    73123Public
    74     /* コンストラクタ.NETと同じように実装は難しい、一先ず動くものを実装したが変更が必要だと思う */
     124    /*!
     125    @brief ファイルを開く。
     126    @param[in] path ファイルパス
     127    @param[in] mode 開き方
     128    @param[in] rights 使用するアクセス権の指定
     129    @param[in] share 共有方法
     130    @param[in] option オプション
     131    @date 2008/08/21
     132    @auther Egtra
     133    */
     134    Sub FileStream(path As String, mode As FileMode, rights As Security.AccessControl.FileSystemRights, share As FileShare, options As FileOptions)
     135        initWithOpen2(path, mode, rights As DWord, share, options)
     136    End Sub
     137    /*!
     138    @brief ファイルを開く。
     139    @param[in] path ファイルパス
     140    @param[in] mode 開き方
     141    @param[in] access ファイルアクセスの指定
     142    @param[in] share 共有方法
     143    @param[in] option オプション
     144    */
    75145    Sub FileStream(path As String, mode As FileMode, access As FileAccess, share As FileShare, options As FileOptions)
    76         _Initialize( path, mode, access, share, options )
    77     End Sub
     146        initWithOpen(path, mode, access, share, options)
     147    End Sub
     148    /*!
     149    @brief ファイルを開く。
     150    @param[in] path ファイルパス
     151    @param[in] mode 開き方
     152    @param[in] access ファイルアクセスの指定
     153    @param[in] share 共有方法
     154    @param[in] useAsync 非同期にするならTrue
     155    @date 2008/08/21
     156    @auther Egtra
     157    */
     158    Sub FileStream(path As String, mode As FileMode, access As FileAccess, share As FileShare, useAsync As Boolean)
     159        Dim options = FileOptions.None
     160        If useAsync Then
     161            options = FileOptions.Asynchronous
     162        End If
     163        initWithOpen(path, mode, access, share, options)
     164    End Sub
     165    /*!
     166    @brief ファイルを開く。
     167    @param[in] path ファイルパス
     168    @param[in] mode 開き方
     169    @param[in] access ファイルアクセスの指定
     170    @param[in] share 共有方法
     171    */
    78172    Sub FileStream(path As String, mode As FileMode, access As FileAccess, share As FileShare)
    79         _Initialize(path,mode,access,share,FileOptions.None)
    80     End Sub
     173        initWithOpen(path,mode,access,share,FileOptions.None)
     174    End Sub
     175    /*!
     176    @brief ファイルを開く。
     177    @param[in] path ファイルパス
     178    @param[in] mode 開き方
     179    @param[in] access ファイルアクセスの指定
     180    */
    81181    Sub FileStream(path As String, mode As FileMode, access As FileAccess)
    82         _Initialize(path,mode,access,FileShare.None,FileOptions.None)
    83     End Sub
     182        initWithOpen(path,mode,access,FileShare.None,FileOptions.None)
     183    End Sub
     184    /*!
     185    @brief ファイルを開く。
     186    @param[in] path ファイルパス
     187    @param[in] mode 開き方
     188    */
    84189    Sub FileStream(path As String, mode As FileMode)
    85190        Dim access As FileAccess
     
    98203                access=FileAccess.Write
    99204        End Select
    100         _Initialize(path,mode,access,FileShare.None,FileOptions.None)
    101     End Sub
    102     /*
     205        initWithOpen(path,mode,access,FileShare.None,FileOptions.None)
     206    End Sub
     207    /*!
     208    @brief 既存ハンドルを基にストリームを作る。
     209    @param[in] h ハンドル
     210    @param[in] access ファイルアクセスの指定
     211    @param[in] owns 所有権を保持するかどうか(TrueならDispose時に基のハンドルも閉じる)
     212    @param[in] isAsync 重複IOを使用するかどうか
    103213    @date 2008/02/26
    104214    @auther Egtra
    105     '不要になったら削除すること
    106     */
    107     Sub FileStream(h As HANDLE, access As FileAccess, owns As Boolean)
     215    @todo SafeFileHandle版に置き換えること
     216    */
     217    Sub FileStream(h As HANDLE, access As FileAccess, owns = True As Boolean, isAsync = False As Boolean)
    108218        handle = h
    109         fileAccess = access As DWord
    110         ownsHandle = owns
    111     End Sub
    112 
     219        initialize(access, owns, isAsync)
     220    End Sub
    113221Public
    114222    /*!
     
    116224    */
    117225    Override Function CanRead() As Boolean
    118         If This.fileAccess And GENERIC_READ Then
    119             Return True
    120         Else
    121             Return False
    122         End If
     226        Return readFn.CanRead
    123227    End Function
    124228
     
    127231    */
    128232    Override Function CanSeek() As Boolean
    129         If GetFileType(This.handle)=FILE_TYPE_DISK Then
    130             Return True
    131         Else
    132             Return False
    133         End If
    134     End Function
    135 
    136 '   Override Function CanTimeout() As Boolean
    137 '       /* ファイルがタイムアウトに対応しているかを返す */
    138 '       Return False /*今のところ対応していないのでFalse*/
    139 '   End Function*/
     233        Return seekFn.CanSeek
     234    End Function
    140235
    141236    /*!
     
    143238    */
    144239    Override Function CanWrite() As Boolean
    145         If This.fileAccess And GENERIC_WRITE Then
    146             Return True
    147         Else
    148             Return False
    149         End If
    150     End Function
    151 
     240        Return writeFn.CanWrite
     241    End Function
     242
     243    /*!
     244    @brief  保持しているハンドルを返す
     245    */
    152246    Function Handle() As HANDLE
    153247        Return handle
    154248    End Function
    155249
    156     /*!
    157     @brief  ファイルが非同期操作に対応しているかを返す
    158     */
    159     Function IsAsync() As Boolean
    160         If This.fileOptions And FILE_FLAG_OVERLAPPED /*FileOptions.Asynchronous*/ Then
    161             Return True
    162         Else
    163             Return False
    164         End If
    165     End Function
    166 
    167     Override Function Length() As Int64
    168         disposedCheck()
    169         If This.CanSeek() Then
    170             Dim length = VarPtr(Length) As *ULARGE_INTEGER
    171             length->LowPart = GetFileSize(This.handle, VarPtr(length->HighPart))
    172             If LODWORD(Length) = INVALID_FILE_SIZE Then
    173                 Dim error = GetLastError()
    174                 If error <> NO_ERROR Then
    175 '                   Detail.ThrowWinIOException("FileStream.Read: Failed to read.", error)
    176                 End If
    177             End If
    178            
    179             If Length < 0 Then
    180                 Debug 'Throw OverflowException
    181             End If
    182         End If
     250    Override Function Length() As QWord
     251        disposedCheck()
     252        Length = seekFn.Length(This)
    183253    End Function
    184254
     
    186256        Return This.filePath
    187257    End Function
    188    
    189     Override Sub Position(value As Int64)
    190         disposedCheck()
    191         If This.CanSeek() Then
    192             If This.IsAsync() Then
    193                 offset = value As QWord
    194             Else
    195                 Dim position As LARGE_INTEGER
    196                 position.LowPart=LODWORD(value)
    197                 position.HighPart=HIDWORD(value)
    198                 SetFilePointer(This.handle,position.LowPart,VarPtr(position.HighPart) As *DWord,FILE_BEGIN)
    199             End If
    200         End If
    201     End Sub
    202     Override Function Position() As Int64
    203         disposedCheck()
    204         If This.CanSeek() Then
    205             If This.IsAsync() Then
    206                 Return offset As Int64
    207             Else
    208                 Dim position As LARGE_INTEGER
    209                 ZeroMemory(VarPtr(position),SizeOf(LARGE_INTEGER))
    210                 position.LowPart=SetFilePointer(This.handle,position.LowPart,VarPtr(position.HighPart) As *DWord,FILE_CURRENT)
    211                 Return MAKEQWORD(position.LowPart,position.HighPart) As Int64
    212             End If
    213         End If
    214     End Function
    215 
    216 /*  Override Sub ReadTimeout(value As Long)
    217         'TODO
    218     End Sub
    219     Override Function ReadTimeout() As Long
    220         'TODO
    221     End Function*/
    222 
     258
     259    Override Sub Position(value As QWord)
     260        disposedCheck()
     261        seekFn.Position(This, value)
     262    End Sub
     263    Override Function Position() As QWord
     264        disposedCheck()
     265        Position = seekFn.Position(This)
     266    End Function
     267
     268Public
    223269    /* Safe~Handle系の実装は要相談!! */
    224270/*  Function SafeFileHandle() As SafeFileHandle
    225271    End Function*/
    226272
    227     Override Sub WriteTimeout(value As Long)
    228         'TODO
    229     End Sub
    230     Override Function WriteTimeout() As Long
    231         'TODO
    232     End Function
    233    
    234 
    235273Public
    236274    Override Function BeginRead(buffer As *Byte, offset As Long, count As Long, callback As AsyncCallback, state As Object) As System.IAsyncResult
    237         If This.IsAsync() Then
    238         Else
    239             Read(buffer,offset,count)
    240         End If
     275        disposedCheck()
     276        If buffer = 0 Then
     277            Throw New ArgumentNullException("FileStream.BeginRead", "buffer")
     278        End If
     279        BeginRead = readFn.BeginRead(This, buffer, offset, count, callback, state)
    241280    End Function
    242281
    243282    Override Function BeginWrite(buffer As *Byte, offset As Long, count As Long, callback As AsyncCallback, state As Object) As System.IAsyncResult
    244         If This.IsAsync() Then
    245         Else
    246             Write(buffer,offset,count)
    247         End If
    248     End Function
    249 
    250 /*  CreateObjRef*/
    251    
     283        disposedCheck()
     284        If buffer = 0 Then
     285            Throw New ArgumentNullException("FileStream.BeginWrite", "buffer")
     286        End If
     287        BeginWrite = writeFn.BeginWrite(This, buffer, offset, count, callback, state)
     288    End Function
     289
    252290    Override Function EndRead(asyncResult As System.IAsyncResult) As Long
    253         'TODO
     291        disposedCheck()
     292        EndRead = readFn.EndRead(This, asyncResult)
    254293    End Function
    255294
    256295    Override Sub EndWrite(asyncResult As System.IAsyncResult)
    257         'TODO
    258     End Sub
    259 
    260 /*  Equals*/
     296        disposedCheck()
     297        writeFn.EndWrite(This, asyncResult)
     298    End Sub
    261299
    262300    Override Sub Flush()
     
    264302        Dim ret = FlushFileBuffers(This.handle)
    265303        If ret = FALSE Then
    266 '           Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
     304            Detail.ThrowWinLastErrorIOException("FileStream.Flush: Failed to flush.")
    267305        End If
    268306    End Sub
     
    272310    End Function*/
    273311
    274 /*  GetLifetimeService*/
    275 
    276 /*  Override Function GetType() As TypeInfo
    277         Return Super.GetType()
    278     End Function*/
    279 
    280 /*  InitializeLifetimeService*/
    281 
    282     Sub Lock(position As Int64, length As Int64)
     312    Sub Lock(position As QWord, length As QWord)
    283313        disposedCheck()
    284314        If position < 0 Then
    285             Throw New ArgumentOutOfRangeException("FileStream.Lock: An argument is negative value.", New System.Int64(position), "position")
     315            Throw New ArgumentOutOfRangeException("FileStream.Lock: An argument is negative value.", New System.UInt64(position), "position")
    286316        ElseIf length < 0 Then
    287             Throw New ArgumentOutOfRangeException("FileStream.Lock: An argument is negative value.", New System.Int64(length), "length")
    288         End If
    289         LockFile(handle, LODWORD(position As QWord), HIDWORD(position As QWord),
    290             LODWORD(length As QWord), HIDWORD(length As QWord))
     317            Throw New ArgumentOutOfRangeException("FileStream.Lock: An argument is negative value.", New System.UInt64(length), "length")
     318        End If
     319        If LockFile(handle, LODWORD(position), HIDWORD(position), LODWORD(length), HIDWORD(length)) = FALSE Then
     320            Detail.ThrowWinLastErrorIOException("FileStream.Lock: Failed to lock.")
     321        End If
    291322    End Sub
    292323
     
    294325        disposedCheck()
    295326        If buffer = 0 Then
    296             Throw New ArgumentNullException("FileStream.Read: An argument is null value.", "buffer")
    297         ElseIf Not This.CanRead() Then
    298             Throw New NotSupportedException("FileStream.Read: This stream is not readable.")
    299         End If
    300 
    301         Dim ret As BOOL
    302         Dim readBytes As DWord
    303         If This.IsAsync() Then
    304             Dim overlapped As OVERLAPPED
    305             SetQWord(VarPtr(overlapped.Offset), offset)
    306             overlapped.hEvent = CreateEvent(0, TRUE, FALSE, 0)
    307             If overlapped.hEvent = 0 Then
    308                 Throw New OutOfMemoryException("FileStream.Read: Failed to create an event object.")
    309             End If
    310             Try
    311                 ret = ReadFile(This.handle, VarPtr(buffer[offset]), count, 0, overlapped)
    312                 If ret = FALSE Then
    313                     Dim error = GetLastError()
    314                     If error <> ERROR_IO_PENDING Then
    315                         Detail.ThrowWinIOException("FileStream.Read: Failed to read.", error)
    316                     End If
    317                 End If
    318                 ret = GetOverlappedResult(This.handle, overlapped, readBytes, TRUE)
    319                 If ret = FALSE Then
    320                     Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
    321                 End If
    322                 offset += Read
    323             Finally
    324                 CloseHandle(overlapped.hEvent)
    325             End Try
    326         Else
    327             ret = ReadFile(This.handle,VarPtr(buffer[offset]),count,VarPtr(readBytes),ByVal NULL)
    328             If ret = FALSE Then
    329                 Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
    330             End If
    331         End If
    332         Read = readBytes As Long
     327            Throw New ArgumentNullException("FileStream.Read", "buffer")
     328        End If
     329        Read = readFn.Read(This, buffer, offset, count)
    333330    End Function
    334331
     
    344341    Override Function Seek(offset As Int64, origin As SeekOrigin) As Int64
    345342        disposedCheck()
    346         If This.CanSeek() Then
    347             If This.IsAsync() Then
    348                 Select Case origin
    349                     Case SeekOrigin.Begin
    350                         This.offset = offset
    351                     Case SeekOrigin.Current
    352                         This.offset += offset
    353                     Case SeekOrigin.End
    354                         This.offset = This.Length + offset
    355                 End Select
    356                 Seek = This.offset As Int64
    357                 If Seek < 0 Then
    358 '                   Throw ArgumentException("FileStream.Seek: Cannot seek to negative offset.")
    359                 End If
    360             Else
    361                 Dim seek = VarPtr(offset) As *ULARGE_INTEGER
    362                 Dim ret = SetFilePointer(This.handle, seek->LowPart, VarPtr(seek->HighPart), origin As DWord)
    363                 If ret = INVALID_SET_FILE_POINTER Then
    364                     Dim error = GetLastError()
    365                     If error = ERROR_NEGATIVE_SEEK Then
    366 '                       Throw ArgumentException("FileStream.Seek: Cannot seek to negative offset.")
    367                     ElseIf error <> NO_ERROR Then
    368 '                       Throw Detail.ThrowWinIOException("FileStream.Seek: Failed to seek.", error)
    369                     End If
    370                 End If
    371                 seek->LowPart = ret
    372                 Seek = offset
    373             End If
    374         End If
     343        Seek = seekFn.Seek(This, offset, origin)
    375344    End Function
    376345
     
    379348    End Sub*/
    380349
    381     Override Sub SetLength(value As Int64)
    382         disposedCheck()
    383         If This.CanWrite() and This.CanSeek() Then
    384             If This.IsAsync() Then
    385             Else
    386                 Dim current = This.Position()
    387                 This.Position(value)
    388                 Dim ret = SetEndOfFile(This.handle)
    389                 If ret = FALSE Then
    390                     Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
    391                 End If
    392                 Position = current
    393             End If
    394         End If
    395     End Sub
    396 
    397 /*  Synchronized*/
     350    Override Sub SetLength(value As QWord)
     351        disposedCheck()
     352        seekFn.SetLength(This, value)
     353    End Sub
    398354
    399355    Override Function ToString() As String
     
    401357    End Function
    402358
    403     Sub Unlock(position As Int64, length As Int64)
    404         disposedCheck()
    405         If position < 0 Then
    406             Throw New ArgumentOutOfRangeException("FileStream.Lock: An argument is negative value.", New System.Int64(position), "position")
    407         ElseIf length < 0 Then
    408             Throw New ArgumentOutOfRangeException("FileStream.Lock: An argument is negative value.", New System.Int64(length), "length")
    409         End If
    410         Dim ret = UnlockFile(handle, LODWORD(position As QWord), HIDWORD(position As QWord),
    411             LODWORD(length As QWord), HIDWORD(length As QWord))
     359    Sub Unlock(position As QWord, length As QWord)
     360        disposedCheck()
     361        Dim ret = UnlockFile(handle, LODWORD(position), HIDWORD(position), LODWORD(length), HIDWORD(length))
    412362        If ret = FALSE Then
    413             Detail.ThrowWinLastErrorIOException("FileStream.Read: Failed to read.")
     363            Detail.ThrowWinLastErrorIOException("FileStream.Unlock failed")
    414364        End If
    415365    End Sub
     
    417367    Override Sub Write(buffer As *Byte, offset As Long, count As Long)
    418368        disposedCheck()
    419         If This.CanWrite() Then
    420             Dim writeBytes As DWord
    421             If This.IsAsync() Then
    422                 Dim overlapped As OVERLAPPED
    423                 SetQWord(VarPtr(overlapped.Offset), offset)
    424                 overlapped.hEvent = CreateEvent(0, TRUE, FALSE, 0)
    425                 Dim ret = WriteFile(This.handle, VarPtr(buffer[offset]), count, 0, overlapped)
    426                 If ret <> FALSE Or GetLastError() = ERROR_IO_PENDING Then
    427                     GetOverlappedResult(This.handle, overlapped, writeBytes, TRUE)
    428                 End If
    429                 offset += writeBytes
    430                 CloseHandle(overlapped.hEvent)
    431             Else
    432                 WriteFile(This.handle, VarPtr(buffer[offset]), count, VarPtr(writeBytes), ByVal NULL)
    433             End If
    434         End If
     369        If buffer = 0 Then
     370            Throw New ArgumentNullException("FileStream.Write", "buffer")
     371        End If
     372        writeFn.Write(This, buffer, offset, count)
    435373    End Sub
    436374
     
    438376    Override Sub Dispose(disposing As Boolean)
    439377        If handle <> 0 Then
    440             Flush()
    441378            CloseHandle(InterlockedExchangePointer(ByVal VarPtr(handle), NULL))
    442379        End If
    443380    End Sub
    444381
    445     Override Function CreateWaitHandle() As System.Threading.WaitHandle
    446         Return New System.Threading.AutoResetEvent(False)
    447     End Function
    448 
    449 Private
    450382    Sub disposedCheck()
    451383        If handle = 0 Then
    452 '           Throw ObjectDisposedException("FileStream: This stream has closed.")
    453         End If
    454     End Sub
    455 
     384            Throw New ObjectDisposedException("FileStream: This stream has already closed.")
     385        End If
     386    End Sub
     387
     388Private
     389    handle As HANDLE
     390    seekFn As Detail.SeekFunctions
     391    readFn As Detail.ReadFunctions
     392    writeFn As Detail.WriteFunctions
     393    filePath As String
     394    ownsHandle As Boolean
    456395End Class
    457 
    458396
    459397End Namespace
  • trunk/ab5.0/ablib/src/Classes/System/IO/MemoryStream.ab

    r472 r605  
    173173    Virtual Sub Capacity(value As Long)
    174174        If This.pointer = 0 Then Throw New ObjectDisposedException("MemoryStream: This stream has closed.")
    175         If value < 0 Then Throw New ArgumentOutOfRangeException("MemoryStream.Capacity: A capacity is set to negative value.", New System.Int64(value),"Capacity")
    176         If value < This.streamLength Then Throw New ArgumentOutOfRangeException("MemoryStream.Capacity: A capacity is less than the current length of the stream.",New System.Int64(value),"Capacity")
     175        If value < 0 Then Throw New ArgumentOutOfRangeException("MemoryStream.Capacity: A capacity is set to negative value.", New System.UInt64(value),"Capacity")
     176        If value < This.streamLength Then Throw New ArgumentOutOfRangeException("MemoryStream.Capacity: A capacity is less than the current length of the stream.",New System.UInt64(value),"Capacity")
    177177        This.pointer = This.reallocate(This.pointer,value)
    178178    End Sub
     
    193193    @date   2008/3/12
    194194    */
    195     Override Function Length() As Int64
     195    Override Function Length() As QWord
    196196        If This.pointer = 0 Then Throw New ObjectDisposedException("MemoryStream: This stream has closed.")
    197197        Return This.streamLength
     
    203203    @date   2008/3/12
    204204    */
    205     Override Sub Position(value As Int64)
    206         If This.pointer = 0 Then Throw New ObjectDisposedException("MemoryStream: This stream has closed.")
    207         If value < 0 Then Throw New ArgumentOutOfRangeException("MemoryStream.Position: The position is set to a negative value.", New System.Int64(value), "Position")
    208         If value > Int32.MaxValue() Then Throw New ArgumentOutOfRangeException("MemoryStream.Position: The position is a value greater than MaxValue.", New System.Int64(value), "Position")
     205    Override Sub Position(value As QWord)
     206        If This.pointer = 0 Then Throw New ObjectDisposedException("MemoryStream: This stream has closed.")
     207        If value < 0 Then Throw New ArgumentOutOfRangeException("MemoryStream.Position: The position is set to a negative value.", New System.UInt64(value), "Position")
     208        If value > Int32.MaxValue() Then Throw New ArgumentOutOfRangeException("MemoryStream.Position: The position is a value greater than MaxValue.", New System.UInt64(value), "Position")
    209209        This.currentPosition = value As Long
    210210    End Sub
     
    215215    @date   2008/3/12
    216216    */
    217     Override Function Position() As Int64
    218         If This.pointer = 0 Then Throw New ObjectDisposedException("MemoryStream: This stream has closed.")
    219         Return This.currentPosition As Int64
     217    Override Function Position() As QWord
     218        If This.pointer = 0 Then Throw New ObjectDisposedException("MemoryStream: This stream has closed.")
     219        Return This.currentPosition As QWord
    220220    End Function
    221221
     
    236236        If This.pointer = 0 Then Throw New ObjectDisposedException("MemoryStream: This stream has closed.")
    237237        If buffer = 0 Then Throw New ArgumentNullException("FileStream.Read: An argument is a null value.", "buffer")
    238         If offset < 0 Then Throw New ArgumentOutOfRangeException("MemoryStream.Read: An argument is a negative value.", New System.Int64(offset), "offset")
    239         If count < 0 Then Throw New ArgumentOutOfRangeException("MemoryStream.Read: An argument is a negative value.", New System.Int64(count), "count")
     238        If offset < 0 Then Throw New ArgumentOutOfRangeException("MemoryStream.Read: An argument is a negative value.", New System.UInt64(offset), "offset")
     239        If count < 0 Then Throw New ArgumentOutOfRangeException("MemoryStream.Read: An argument is a negative value.", New System.UInt64(count), "count")
    240240        If (This.streamLength - (This.currentPosition + count)) < 0 Then
    241241            count + = (This.streamLength - (This.currentPosition + count))
     
    270270    Override Function Seek(offset As Int64, origin As SeekOrigin) As Int64
    271271        If This.pointer = 0 Then Throw New ObjectDisposedException("MemoryStream: This stream has closed.")
    272         If offset > Int32.MaxValue() Then Throw New ArgumentOutOfRangeException("MemoryStream.Seek: The offset is a value greater than MaxValue.", New System.Int64(offset), "offset")
     272        If offset > Int32.MaxValue() Then Throw New ArgumentOutOfRangeException("MemoryStream.Seek: The offset is a value greater than MaxValue.", New System.UInt64(offset), "offset")
    273273        Select Case origin
    274274            Case SeekOrigin.Begin
     
    285285                Throw New ArgumentException("MemoryStream.Seek: An argument is an invalid SeekOrigin","origin")
    286286        End Select
    287         Return This.currentPosition As Int64
     287        Return This.currentPosition As QWord
    288288    End Function
    289289
     
    293293    @date   2008/3/12
    294294    */
    295     Override Sub SetLength(value As Int64)
     295    Override Sub SetLength(value As QWord)
    296296        If This.pointer = 0 Then Throw New ObjectDisposedException("MemoryStream: This stream has closed.")
    297297        If This.writable = False Then Throw New NotSupportedException("MemoryStream: The current stream is not writable")
    298298        If This.resizable = False Then Throw New NotSupportedException("MemoryStream: The current stream is not resizable")
    299299        If value > This.Capacity() Then Throw New NotSupportedException("MemoryStream.SetLength: This stream length is larger than the current capacity.")
    300         If value < 0 Then Throw New ArgumentOutOfRangeException("MemoryStream.Read: An argument is a negative value.", New System.Int64(value), "value")
    301         If value > Int32.MaxValue() Then Throw New ArgumentOutOfRangeException("MemoryStream.SetLength: The length is a value greater than MaxValue.", New System.Int64(value), "value")
     300        If value < 0 Then Throw New ArgumentOutOfRangeException("MemoryStream.Read: An argument is a negative value.", New System.UInt64(value), "value")
     301        If value > Int32.MaxValue() Then Throw New ArgumentOutOfRangeException("MemoryStream.SetLength: The length is a value greater than MaxValue.", New System.UInt64(value), "value")
    302302        This.pointer = This.reallocate(This.pointer,value As Long)
    303303        This.streamLength = value As Long
     
    313313        If This.writable = False Then Throw New NotSupportedException("MemoryStream: The current stream is not writable")
    314314        If buffer = 0 Then Throw New ArgumentNullException("MemoryStream.Write: An argument is a null value.", "buffer")
    315         If offset < 0 Then Throw New ArgumentOutOfRangeException("MemoryStream.Write: An argument is a negative value.", New System.Int64(offset), "offset")
    316         If count < 0 Then Throw New ArgumentOutOfRangeException("MemoryStream.Write: An argument is a negative value.", New System.Int64(count), "count")
    317         If count > (This.streamLength - This.currentPosition) Then 
     315        If offset < 0 Then Throw New ArgumentOutOfRangeException("MemoryStream.Write: An argument is a negative value.", New System.UInt64(offset), "offset")
     316        If count < 0 Then Throw New ArgumentOutOfRangeException("MemoryStream.Write: An argument is a negative value.", New System.UInt64(count), "count")
     317        If count > (This.streamLength - This.currentPosition) Then
    318318            If This.resizable = False Then Throw New NotSupportedException("MemoryStream: The current stream is not resizable")
    319             If (This.Capacity() - This.currentPosition) < count Then 
     319            If (This.Capacity() - This.currentPosition) < count Then
    320320                This.pointer = This.reallocate(This.pointer,This.currentPosition+count)
    321321            End If
  • trunk/ab5.0/ablib/src/Classes/System/IO/Stream.ab

    r568 r605  
    44
    55Class Stream
    6     Implements System.IDisposable
     6    Implements IDisposable
    77
    8 Public 'Protected
     8Protected
    99    Sub Stream()
    1010    End Sub
    1111Public
    12     Virtual Sub ~Stream()
     12    Sub ~Stream()
    1313        This.Dispose(False)
    1414    End Sub
     
    1818
    1919    Virtual Function CanTimeout() As Boolean
    20         Return True
     20        Return False
    2121    End Function
    2222
    2323    Abstract Function CanWrite() As Boolean
    24     Abstract Function Length() As Int64
    25     Abstract Sub Position(value As Int64)
    26     Abstract Function Position() As Int64
     24    Abstract Function Length() As QWord
     25    Abstract Sub Position(value As QWord)
     26    Abstract Function Position() As QWord
    2727
    2828    Virtual Sub ReadTimeout(value As Long)
    29         ' Throw InvalidOperationException
     29        Throw New InvalidOperationException("Stream does not support Timeout.")
    3030    End Sub
    3131
    3232    Virtual Function ReadTimeout() As Long
    33         ' Throw InvalidOperationException
     33        Throw New InvalidOperationException("Stream does not support Timeout.")
    3434    End Function
    3535
    3636    Virtual Sub WriteTimeout(value As Long)
    37         ' Throw InvalidOperationException
     37        Throw New InvalidOperationException("Stream does not support Timeout.")
    3838    End Sub
    3939
    4040    Virtual Function WriteTimeout() As Long
    41         ' Throw InvalidOperationException
     41        Throw New InvalidOperationException("Stream does not support Timeout.")
    4242    End Function
    4343
    4444Public
    4545    Virtual Function BeginRead(buffer As *Byte, offset As Long, count As Long, callback As AsyncCallback, state As Object) As System.IAsyncResult
    46         Read(buffer,offset,count)
     46        Dim r = Read(buffer,offset,count)
     47        Return New Detail.SyncStreamResultImpl(r, state)
    4748    End Function
    4849    Virtual Function BeginWrite(buffer As *Byte, offset As Long, count As Long, callback As AsyncCallback, state As Object) As System.IAsyncResult
    4950        Write(buffer,offset,count)
     51        Return New Detail.SyncStreamResultImpl(0, state)
    5052    End Function
    5153    Sub Close()
     
    5658    End Sub
    5759    Virtual Function EndRead(asyncResult As System.IAsyncResult) As Long
     60        Dim ar = asyncResult As Detail.IAsyncStreamResult
     61        EndRead = ar.WaitAndGetResult
    5862    End Function
    5963    Virtual Sub EndWrite(asyncResult As System.IAsyncResult)
     
    7377
    7478    Abstract Function Seek(offset As Int64, origin As SeekOrigin) As Int64
    75     Abstract Sub SetLength(value As Int64)
     79    Abstract Sub SetLength(value As QWord)
    7680    Abstract Sub Write(buffer As *Byte, offset As Long, count As Long)
    7781    Virtual Sub WriteByte(b As Byte)
     
    8185    Virtual Sub Dispose(disposing As Boolean)
    8286    End Sub
    83     Virtual Function CreateWaitHandle() As System.Threading.WaitHandle
    84     End Function
    8587End Class
    8688
  • trunk/ab5.0/ablib/src/Classes/System/IO/StreamReader.ab

    r497 r605  
    3434    Override Function Peek() As Long
    3535        If cur = last Then
    36             last = s.Read(buf, 0, size)
     36            last = s.Read(buf As *Byte, 0, size)
    3737            cur = 0
    3838            If last = 0 Then
     
    108108        If count > size Then
    109109            n = (count \ size) * size 'sizeの倍数分だけは直接bufferへ読み込ませる
    110             Dim read = s.Read(p, 0, n)
     110            Dim read = s.Read(p As *Byte, 0, n)
    111111            If read = 0 Then 'EOF
    112112                Exit Function
     
    116116            count -= n
    117117        End If
    118         last = s.Read(buffer, 0, size)
     118        last = s.Read(buffer As *Byte, 0, size)
    119119        cur = 0
    120120        If last = 0 Then 'EOF
  • trunk/ab5.0/ablib/src/Classes/System/IO/misc.ab

    r391 r605  
    1414End Enum
    1515
     16/*
     17@brief ファイルのアクセス方法を表す
     18*/
     19Enum FileAccess
     20    Read      = GENERIC_READ
     21    ReadWrite = GENERIC_READ Or GENERIC_WRITE
     22    Write     = GENERIC_WRITE
     23End Enum
     24
     25/*
     26@brief ファイルの属性を表す
     27*/
     28Enum FileAttributes
     29    Archive           = FILE_ATTRIBUTE_ARCHIVE
     30    Compressed        = FILE_ATTRIBUTE_COMPRESSED
     31    Device            = FILE_ATTRIBUTE_DEVICE
     32    Directory         = FILE_ATTRIBUTE_DIRECTORY
     33    Encrypted         = FILE_ATTRIBUTE_ENCRYPTED
     34    Hidden            = FILE_ATTRIBUTE_HIDDEN
     35    Normal            = FILE_ATTRIBUTE_NORMAL
     36    NotContentIndexed = FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
     37    Offline           = FILE_ATTRIBUTE_OFFLINE
     38    ReadOnly          = FILE_ATTRIBUTE_READONLY
     39    ReparsePoint      = FILE_ATTRIBUTE_REPARSE_POINT
     40    SparseFile        = FILE_ATTRIBUTE_SPARSE_FILE
     41    System            = FILE_ATTRIBUTE_SYSTEM
     42    Temporary         = FILE_ATTRIBUTE_TEMPORARY
     43End Enum
     44
     45/*
     46@brief ファイルの作成モードを表す
     47*/
     48Enum FileMode
     49    Append       = -1
     50    Create       = CREATE_ALWAYS
     51    CreateNew    = CREATE_NEW
     52    Open         = OPEN_EXISTING
     53    OpenOrCreate = OPEN_ALWAYS
     54    Truncate     = TRUNCATE_EXISTING
     55End Enum
     56
     57/*
     58@brief ファイルの共有を表す
     59*/
     60Enum FileShare
     61    None       = 0
     62    Read       = FILE_SHARE_READ
     63    Write      = FILE_SHARE_WRITE
     64    ReadWrite  = FILE_SHARE_READ Or FILE_SHARE_WRITE
     65    DeleteFile = FILE_SHARE_DELETE
     66    Inheritable = &h10
     67End Enum
     68
     69Enum FileOptions
     70    None = 0
     71    Asynchronous = FILE_FLAG_OVERLAPPED
     72    DeleteOnClose = FILE_FLAG_DELETE_ON_CLOSE
     73    Encrypted = FILE_ATTRIBUTE_ENCRYPTED
     74    RandomAccess = FILE_FLAG_RANDOM_ACCESS
     75    SequentialScan = FILE_FLAG_SEQUENTIAL_SCAN
     76    WriteThrough = FILE_FLAG_WRITE_THROUGH
     77End Enum
     78
    1679End Namespace 'IO
    1780End Namespace 'System
  • trunk/ab5.0/ablib/src/Classes/System/Security/AccessControl/misc.ab

    r577 r605  
    9292
    9393Enum FileSystemRights
    94     ' ファイルの末尾にデータを追加する権限を指定します。 
    95     AppendData
    96     ' ファイルまたはフォルダに関連付けられたセキュリティ規則と監査規則を変更する権限を指定します。 
    97     ChangePermissions
    98 
    99     ' フォルダを作成する権限を指定します。 
    100     'この権限には Synchronize 値が必要です。ファイルまたはフォルダの作成時に Synchronize 値を明示的に設定しない場合、Synchronize 値は自動的に設定されます。
    101     CreateDirectories
    102  
    103     ' ファイルを作成する権限を指定します。 
    104     'この権限には Synchronize 値が必要です。ファイルまたはフォルダの作成時に Synchronize 値を明示的に設定しない場合、Synchronize 値は自動的に設定されます。
    105     CreateFiles
    106  
    107     ' フォルダまたはファイルを削除する権限を指定します。   
    108     Delete
    109     ' フォルダおよびそのフォルダ内に格納されているファイルを削除する権限を指定します。 
    110     DeleteSubdirectoriesAndFiles
    111     ' アプリケーション ファイルを実行する権限を指定します。 
    112     ExecuteFile
    113     ' フォルダまたはファイルに対してフル コントロールを行い、アクセス制御と監査規則を変更する権限を指定します。この値は、ファイルに対してどのような操作でも行うことができる権限を表します。この値は、この列挙体のすべての権限を組み合わせたものです。 
    114     FullControl
    115     ' ディレクトリの内容を読み取る権限を指定します。 
    116     ListDirectory
    117     ' 読み取り、書き込み、フォルダの内容の一覧表示、フォルダとファイルの削除、およびアプリケーション ファイルの実行を行う権限を指定します。この権限には、ReadAndExecute 権限、Write 権限、および Delete 権限が含まれます。 
    118     Modify
    119     ' フォルダまたはファイルを読み取り専用として開いたり、コピーしたりする権限を指定します。この権限には、ReadData 権限、ReadExtendedAttributes 権限、ReadAttributes 権限、および ReadPermissions 権限が含まれます。 
    120     Read
    121     ' フォルダまたはファイルを読み取り専用として開いたりコピーしたりする権限、およびアプリケーション ファイルを実行する権限を指定します。この権限には、Read 権限および ExecuteFile 権限が含まれます。 
    122     ReadAndExecute
    123     ' フォルダまたはファイルのファイル システム属性を開いたり、コピーしたりする権限を指定します。たとえば、この値は、ファイルの作成日や変更日を表示する権限を指定します。これには、データ、拡張ファイル システム属性、またはアクセス規則や監査規則を読み取る権限は含まれません。 
    124     ReadAttributes
    125     ' ファイルまたはフォルダを開いたり、コピーしたりする権限を指定します。これには、ファイル システム属性、拡張ファイル システム属性、またはアクセス規則や監査規則を読み取る権限は含まれません。 
    126     ReadData
    127     ' フォルダまたはファイルの拡張ファイル システム属性を開いたり、コピーしたりする権限を指定します。たとえば、この値は、作成者や内容に関する情報を表示する権限を指定します。これには、データ、ファイル システム属性、またはアクセス規則や監査規則を読み取る権限は含まれません。 
    128     ReadExtendedAttributes
    129     ' フォルダまたはファイルのアクセス規則や監査規則を開いたり、コピーしたりする権限を指定します。これには、データ、ファイル システム属性、および拡張ファイル システム属性を読み取る権限は含まれません。   
    130     ReadPermissions
    131 
    132     ' ファイル ハンドルが I/O 操作の完了に同期するまでアプリケーションが待機できるかどうかを指定します。
    133     'Synchronize 値は、アクセスを許可すると自動的に設定され、アクセスを拒否すると自動的に除外されます。
    134     'ファイルまたはフォルダを作成する権限には、この値が必要です。この値は、ファイルの作成時に明示的に設定しなくても、自動的に設定されます。
    135     Synchronize
    136  
    137     ' フォルダまたはファイルの所有者を変更する権限を指定します。リソースの所有者は、そのリソースに対してフル アクセス権限を持ちます。 
    138     TakeOwnership
    139     ' フォルダの内容を一覧表示し、そのフォルダに格納されているアプリケーションを実行する権限を指定します。 
    140     Traverse
    141     ' フォルダおよびファイルを作成し、ファイルに対してデータの追加または削除を行う権限を指定します。この権限には、WriteData 権限、AppendData 権限、WriteExtendedAttributes 権限、および WriteAttributes 権限が含まれます。   
    142     Write
    143     ' フォルダまたはファイルのファイル システム属性を開いたり、フォルダまたはファイルにファイル システム属性を書き込んだりする権限を指定します。これには、データ、拡張属性、またはアクセス規則や監査規則を書き込む権限は含まれません。 
    144     WriteAttributes
    145     ' ファイルまたはフォルダを開いたり、ファイルまたはフォルダに書き込んだりする権限を指定します。これには、ファイル システム属性、拡張ファイル システム属性、またはアクセス規則や監査規則を開いたり書き込んだりする権限は含まれません。 
    146     WriteData
    147     ' フォルダまたはファイルの拡張ファイル システム属性を開いたり、フォルダまたはファイルに拡張ファイル システム属性を書き込んだりする権限を指定します。これには、データ、属性、またはアクセス規則や監査規則を書き込む権限は含まれません。 
    148     WriteExtendedAttributes
     94    ReadData = FILE_READ_DATA
     95    ListDirectory = FILE_LIST_DIRECTORY
     96    WriteData = FILE_WRITE_DATA
     97    CreateFiles = FILE_ADD_FILE
     98    CreateDirectories = FILE_ADD_SUBDIRECTORY
     99    AppendData = FILE_APPEND_DATA
     100    ReadExtendedAttributes = FILE_READ_EA
     101    WriteExtendedAttributes = FILE_WRITE_EA
     102    Traverse = FILE_TRAVERSE
     103    ExecuteFile = FILE_EXECUTE
     104    DeleteSubdirectoriesAndFiles = FILE_DELETE_CHILD
     105    ReadAttributes = FILE_READ_ATTRIBUTES
     106    WriteAttributes = FILE_WRITE_ATTRIBUTES
     107    Write = FILE_WRITE_DATA Or FILE_WRITE_ATTRIBUTES Or FILE_WRITE_EA Or FILE_APPEND_DATA
     108    Delete = &h00010000 'DELETE
     109    ReadPermissions = READ_CONTROL
     110    Read = FILE_READ_DATA Or FILE_READ_ATTRIBUTES Or FILE_READ_EA Or STANDARD_RIGHTS_READ
     111    ReadAndExecute = Read As DWord Or FILE_EXECUTE
     112    Modify = ReadAndExecute As DWord Or Write As DWord Or &h00010000 'Delete
     113    ChangePermissions = WRITE_DAC
     114    TakeOwnership = WRITE_OWNER
     115    Synchronize = SYNCHRONIZE
     116    FullControl = &h001f01ff
    149117End Enum
    150118
  • trunk/ab5.0/ablib/src/Classes/index.ab

    r599 r605  
    7070#require "./System/IO/FileInfo.ab"
    7171#require "./System/IO/FileStream.ab"
     72#require "./System/IO/FileStreamImpl.ab"
    7273#require "./System/IO/FileSystemInfo.ab"
    7374#require "./System/IO/MemoryStream.ab"
Note: See TracChangeset for help on using the changeset viewer.