Changeset 318 for trunk/Include/Classes/System/IO/DirectoryInfo.ab
- Timestamp:
- Aug 28, 2007, 9:16:10 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/Classes/System/IO/DirectoryInfo.ab
r285 r318 1 Imports System.Collections.Generic 1 2 2 3 Namespace System … … 17 18 'Public Property 18 19 Function Parent() As DirectoryInfo 19 Dim dirInfo As DirectoryInfo(Path.GetDirectoryName(FullPath)) 20 Return dirInfo 20 Return New DirectoryInfo(Path.GetDirectoryName(FullPath)) 21 21 End Function 22 22 23 23 Function Root() As DirectoryInfo 24 Dim dirInfo As DirectoryInfo(Path.GetPathRoot(FullPath)) 25 Return dirInfo 24 Return New DirectoryInfo(Path.GetPathRoot(FullPath)) 26 25 End Function 27 26 … … 75 74 End Function*/ 76 75 77 /* Function GetDirectories() As Array 76 Function GetDirectories() As List<DirectoryInfo> 77 Return GetDirectories("?*") 78 End Function 79 80 Function GetDirectories(searchPattern As String) As List<DirectoryInfo> 81 Dim infos As List<FileSystemInfo> 82 infos = GetFileSystemInfos(searchPattern) 83 84 Dim dirs As List<DirectoryInfo> 85 Dim i As Long 86 For i = 0 To ELM(infos.Count) 87 If infos[i].GetType.ToString() = "DirectoryInfo" Then 88 dirs.Add(infos[i] As DirectoryInfo) 89 End If 90 Next 91 Return dirs 92 End Function 93 94 /* Function GetDirectories(searchPattern As String, searchOption As SearchOption) As List<DirectoryInfo> 95 If searchOption = SearchOption.TopDirectoryOnly Then 96 Return GetDirectories(searchPattern) 97 Else 98 Dim dirs As List<DirectoryInfo> 99 dirs = GetDirectories(searchPattern) 100 Dim i As Long 101 102 End If 78 103 End Function*/ 79 104 80 /* Function GetDirectories(searchPattern As String) As Array 105 Function GetFiles() As List<FileInfo> 106 Return GetFiles("?*") 107 End Function 108 109 Function GetFiles(searchPattern As String) As List<FileInfo> 110 Dim infos As List<FileSystemInfo> 111 infos = GetFileSystemInfos(searchPattern) 112 113 Dim files As List<FileInfo> 114 Dim i As Long 115 For i = 0 To ELM(infos.Count) 116 If infos[i].GetType.ToString() = "FileInfo" Then 117 files.Add(infos[i] As FileInfo) 118 End If 119 Next 120 Return files 121 End Function 122 123 /* Function GetFiles(searchPattern As String, searchOption As SearchOption) As List<FileInfo> 81 124 End Function*/ 82 125 83 /* Function GetDirectories(searchPattern As String, searchOption As SearchOption) As Array 84 End Function*/ 126 Function GetFileSystemInfos() As List<FileSystemInfo> 127 Return GetFileSystemInfos("?*") 128 End Function 85 129 86 /* Function GetFiles() As Array 87 End Function*/ 130 Function GetFileSystemInfos(searchPattern As String) As List<FileSystemInfo> 131 Dim find As HANDLE 132 Dim findData As WIN32_FIND_DATA 133 find = FindFirstFile(ToTCStr(Path.Combine(FullPath, searchPattern)), findData) 134 If find = INVALID_HANDLE_VALUE Then 135 debug 'Exception 136 Return Nothing 137 End If 88 138 89 /* Function GetFiles(searchPattern As String) As Array 90 End Function*/ 139 Dim files As List<FileSystemInfo> 140 Dim lastError = GetLastError() As DWord 141 Dim i As Long 142 While lastError <> ERROR_NO_MORE_FILES 143 If i > 1 Then 144 Dim s = New String(findData.cFileName As PCTSTR) 145 If (findData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY) = FILE_ATTRIBUTE_DIRECTORY Then 146 files.Add(New DirectoryInfo(Path.Combine(FullPath, s))) 147 Else 148 files.Add(New FileInfo(Path.Combine(FullPath, s))) 149 End If 150 End If 91 151 92 /* Function GetFiles(searchPattern As String, searchOption As SearchOption) As Array 93 End Function*/ 94 95 /* Function GetFileSystemInfos() As Array 96 End Function*/ 97 98 /* Function GetFileSystemInfos(searchPattern As String) As Array 99 End Function*/ 152 If FindNextFile(find, findData) = False Then 153 lastError = GetLastError() 154 If lastError <> ERROR_NO_MORE_FILES Then 155 debug 'Exception 156 Return Nothing 157 End If 158 End If 159 i++ 160 Wend 161 Return files 162 End Function 100 163 101 164 Sub MoveTo(destDirName As String) … … 110 173 End Class 111 174 112 Enum SearchOption113 AllDirectories114 TopDirectoryOnly115 End Enum116 117 175 End Namespace 118 176 End Namespace
Note:
See TracChangeset
for help on using the changeset viewer.