Changeset 345


Ignore:
Timestamp:
Sep 29, 2007, 9:26:35 PM (17 years ago)
Author:
OverTaker
Message:

GetFileSystemInfos実装完了。他ちょっとした修整

Location:
trunk/Include/Classes/System/IO
Files:
3 edited

Legend:

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

    r333 r345  
    1010        OriginalPath = path
    1111        FullPath = Path.GetFullPath(path)
    12         Refresh()
    1312    End Sub
    1413
     
    160159        find = FindFirstFile(ToTCStr(Path.Combine(FullPath, searchPattern)), findData)
    161160        If find = INVALID_HANDLE_VALUE Then
    162             debug 'Exception
    163             Return Nothing
     161            Return New List<DirectoryInfo>
    164162        End If
    165163
    166164        Dim files As List<FileSystemInfo>
    167         Dim i = 0 As Long
    168165        Do
    169             If i > 1 Then
    170                 Dim s = New String(findData.cFileName As PCTSTR)
    171                 If (findData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY Then
    172                     files.Add(New DirectoryInfo(Path.Combine(FullPath, s)))
    173                 Else
    174                     files.Add(New FileInfo(Path.Combine(FullPath, s)))
    175                 End If
     166            Dim s = New String(findData.cFileName As PCTSTR)
     167            If (findData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY Then
     168                files.Add(New DirectoryInfo(Path.Combine(FullPath, s)))
     169            Else
     170                files.Add(New FileInfo(Path.Combine(FullPath, s)))
    176171            End If
    177             i++
    178172        Loop While FindNextFile(find, findData)
    179173        FindClose(find)
     174
     175        files.Remove(New DirectoryInfo(Path.Combine(FullPath, ".")))
     176        files.Remove(New DirectoryInfo(Path.Combine(FullPath, "..")))
    180177
    181178        If GetLastError() = ERROR_NO_MORE_FILES Then
  • trunk/Include/Classes/System/IO/FileInfo.ab

    r318 r345  
    99        OriginalPath = path
    1010        FullPath = Path.GetFullPath(path)
    11         Refresh()
    1211    End Sub
    1312
  • trunk/Include/Classes/System/IO/FileSystemInfo.ab

    r333 r345  
    88    m_LastWriteTime As FILETIME
    99    m_FileAttributes As DWord
     10
     11    m_IsFreshed As Boolean
    1012Protected
    1113    FullPath As String
    1214    OriginalPath As String
    1315Public
     16    Sub FileSystemInfo()
     17        m_IsFreshed = False
     18    End Sub
     19
     20    Sub ~FileSystemInfo()
     21    End Sub
    1422
    1523    Override Function Equals( object As Object ) As Boolean
     
    2735    'Public Properties
    2836    Function Attributes() As DWord'FileAttributes
     37        If Not m_IsFreshed Then Refresh()
    2938        Return m_FileAttributes
    3039    End Function
     
    3847
    3948    Function CreationTime() As DateTime
     49        If Not m_IsFreshed Then Refresh()
    4050        Return DateTime.FromFileTime(m_CreationTime)
    4151    End Function
     
    5565
    5666    Function LastAccessTime() As DateTime
     67        If Not m_IsFreshed Then Refresh()
    5768        Return DateTime.FromFileTime(m_LastAccessTime)
    5869    End Function
     
    7283
    7384    Function LastWriteTime() As DateTime
     85        If Not m_IsFreshed Then Refresh()
    7486        Return DateTime.FromFileTime(m_LastWriteTime)
    7587    End Function
     
    89101
    90102    Function Exists() As Boolean
     103        If Not m_IsFreshed Then Refresh()
    91104        If m_FileAttributes = 0 Then
    92105            Return False
     
    128141Private
    129142    Sub setFileTime()
     143        If Not m_IsFreshed Then Refresh()
    130144        Dim hFile = CreateFile(ToTCStr(FullPath), GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0)
    131145        If hFile = INVALID_HANDLE_VALUE Then
Note: See TracChangeset for help on using the changeset viewer.