Ignore:
Timestamp:
Mar 8, 2008, 7:33:08 PM (17 years ago)
Author:
OverTaker
Message:

File.ab,FileInfo.abをそれなりに実装

File:
1 edited

Legend:

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

    r406 r466  
    1515
    1616    '----------------------------------------------------------------
    17     ' Public properties
     17    ' パブリック プロパティ
    1818    '----------------------------------------------------------------
    1919
     
    3333        End If
    3434    End Function
     35
     36    Function Length() As QWord
     37        Dim hFile = CreateFile(ToTCStr(FullPath), GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
     38        If hFile = INVALID_HANDLE_VALUE Then
     39            Throw New IOException("FileInfo.Length: Failed to CreateFile.")
     40            Exit Function
     41        End If
     42
     43        Dim length As QWord
     44        If GetFileSizeEx(hFile, VarPtr(length)) Then
     45            CloseHandle(hFile)
     46            Return length
     47        Else
     48            CloseHandle(hFile)
     49            Throw New IOException("FileInfo.Length: Failed to GetFileSize")
     50        End If
     51    End Function
     52
     53    '----------------------------------------------------------------
     54    ' パブリック メソッド
     55    '----------------------------------------------------------------
     56
     57/*  Function AppendText() As StreamWriter
     58    End Function*/
     59
     60    Function CopyTo(destFileName As String) As FileInfo
     61        Return CopyTo(destFileName, False)
     62    End Function
     63
     64    Function CopyTo(destFileName As String, overwrite As Boolean) As FileInfo
     65        File.Copy(FullPath, destFileName, overwrite)
     66        Return New FileInfo(destFileName)
     67    End Function
     68
     69    Function Create() As FileStream
     70        Return File.Create(FullPath)
     71    End Function
     72
     73/*  Function CreateText() As StreamWriter
     74    End Function*/
     75
     76/*  Sub Decrypt()
     77    End Sub*/
     78
     79    Override Sub Delete()
     80        File.Delete(FullPath)
     81    End Sub
     82
     83/*  Sub Encrypt()
     84    End Sub*/
     85
     86/*  Function GetAccessControl() As FileSecurity
     87    End Function*/
     88
     89/*  Function GetAccessControl(includeSections As AccessControlSections) As FileScurity
     90    End Function*/
     91
     92    Sub MoveTo(destFileName As String)
     93        File.Move(FullPath, destFileName)
     94    End Sub
     95
     96    Function Open(mode As FileMode) As FileStream
     97        Return New FileStream(FullPath, mode)
     98    End Function
     99
     100    Function Open(mode As FileMode, access As FileAccess) As FileStream
     101        Return New FileStream(FullPath, mode, access)
     102    End Function
     103
     104    Function Open(mode As FileMode, access As FileAccess, share As FileShare ) As FileStream
     105        Return New FileStream(FullPath, mode, access, share)
     106    End Function
     107
     108    Function OpenRead() As FileStream
     109        Return Open(FileMode.Open, FileAccess.Read, FileShare.Read)
     110    End Function
     111
     112    Function OpenText() As StreamReader
     113        Return New StreamReader(FullPath)
     114    End Function
     115
     116    Function OpenWrite() As FileStream
     117        Return Open(FileMode.Open, FileAccess.Write)
     118    End Function
     119
     120/*  Function Replace(destinationFileName As String, destinationBackupFileName As String) As FileInfo
     121    End Function*/
     122
     123/*  Function Replace(destinationFileName As String, destinationBackupFileName As String, ignoreMetadataErrors As Boolean) As FileInfo
     124    End Function*/
     125
     126/*  Sub SetAccessControl(fileSecurity As FileSecurity)
     127    End Sub*/
     128
     129    Override Function ToString() As String
     130        Return FullPath
     131    End Function
     132
    35133End Class
    36 
    37134
    38135
Note: See TracChangeset for help on using the changeset viewer.