Changeset 327 for trunk/Include
- Timestamp:
- Sep 8, 2007, 10:59:51 AM (17 years ago)
- Location:
- trunk/Include/Classes/System/IO
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Include/Classes/System/IO/DirectoryInfo.ab
r326 r327 93 93 94 94 Function GetDirectories(searchPattern As String, searchOption As SearchOption) As List<DirectoryInfo> 95 If searchOption = SearchOption.TopDirectoryOnly Then 96 Return GetDirectories(searchPattern) 97 ElseIf searchOption = SearchOption.AllDirectories Then 98 Dim dirs As List<DirectoryInfo> 99 dirs = GetDirectories(searchPattern) 100 101 Dim subdirs As List<DirectoryInfo> 102 Dim i As Long, j As Long 103 For i = 0 To ELM(dirs.Count) 104 subdirs = dirs[i].GetDirectories(searchPattern) 105 For j = 0 To ELM(subdirs.Count) 106 dirs.Add(subdirs[i]) 95 Select Case searchOption 96 Case SearchOption.TopDirectoryOnly 97 Return GetDirectories(searchPattern) 98 Case SearchOption.AllDirectories 99 Dim dirs As List<DirectoryInfo> 100 dirs = GetDirectories(searchPattern) 101 102 Dim subdirs As List<DirectoryInfo> 103 Dim i As Long, j As Long 104 For i = 0 To ELM(dirs.Count) 105 subdirs = dirs[i].GetDirectories(searchPattern) 106 For j = 0 To ELM(subdirs.Count) 107 dirs.Add(subdirs[i]) 108 Next 107 109 Next 108 Next 109 Return dirs 110 End If 110 Return dirs 111 End Select 111 112 End Function 112 113 … … 129 130 End Function 130 131 131 /* Function GetFiles(searchPattern As String, searchOption As SearchOption) As List<FileInfo> 132 End Function*/ 132 Function GetFiles(searchPattern As String, searchOption As SearchOption) As List<FileInfo> 133 Select Case searchOption 134 Case SearchOption.TopDirectoryOnly 135 Return GetFiles(searchPattern) 136 Case SearchOption.AllDirectories 137 Dim dirs As List<DirectoryInfo> 138 dirs = GetDirectories(searchPattern, SearchOption.AllDirectories) 139 140 Dim files As List<FileInfo> 141 Dim subfiles As List<FileInfo> 142 Dim i As Long, j As Long 143 For i = 0 To ELM(dirs.Count) 144 subfiles = dirs[i].GetFiles(searchPattern) 145 For j = 0 To ELM(subfiles.Count) 146 files.Add(subfiles[j]) 147 Next 148 Next 149 Return files 150 End Select 151 End Function 133 152 134 153 Function GetFileSystemInfos() As List<FileSystemInfo> … … 139 158 Dim find As HANDLE 140 159 Dim findData As WIN32_FIND_DATA 141 find = FindFirstFile( Path.Combine(FullPath, searchPattern), findData)160 find = FindFirstFile(ToTCStr(Path.Combine(FullPath, searchPattern)), findData) 142 161 If find = INVALID_HANDLE_VALUE Then 143 162 debug 'Exception … … 146 165 147 166 Dim files As List<FileSystemInfo> 148 Dim lastError As DWord149 167 Dim i As Long 150 While lastError <> ERROR_NO_MORE_FILES168 Do 151 169 If i > 1 Then 152 170 Dim s = New String(findData.cFileName As PCTSTR) … … 157 175 End If 158 176 End If 159 160 If FindNextFile(find, findData) = False Then161 lastError = GetLastError()162 If lastError <> ERROR_NO_MORE_FILES Then163 FindClose(find)164 debug 'Exception165 Return Nothing166 End If167 End If168 177 i++ 169 Wend178 Loop While FindNextFile(find, findData) 170 179 FindClose(find) 171 Return files 180 181 If GetLastError() = ERROR_NO_MORE_FILES Then 182 Return files 183 Else 184 debug 'Exception 185 Return Nothing 186 End If 172 187 End Function 173 188
Note:
See TracChangeset
for help on using the changeset viewer.