@@ -1009,124 +1009,3 @@ interface Iterator(T) {
10091009 int opApply (int delegate (ref T) action);
10101010
10111011}
1012-
1013- deprecated
1014- class FileSystemIterator : Iterator !(string) {
1015-
1016- private string path_;
1017- private string searchPattern_;
1018- private bool includeFiles_;
1019- private bool includeDirs_;
1020-
1021- this (string path, string searchPattern, bool includeFiles, bool includeDirs) {
1022- path_ = path;
1023- searchPattern_ = searchPattern;
1024- includeFiles_ = includeFiles;
1025- includeDirs_ = includeDirs;
1026- }
1027-
1028- int opApply (int delegate (ref string ) action) {
1029-
1030- bool isDir (WIN32_FIND_DATA findData) {
1031- return ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) != 0 );
1032- }
1033-
1034- bool isFile (WIN32_FIND_DATA findData) {
1035- return ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) == 0 );
1036- }
1037-
1038- string getSearchResult (string path, WIN32_FIND_DATA findData) {
1039- return combine (path, toUtf8(findData.cFileName[0 .. wcslen(findData.cFileName.ptr)]));
1040- }
1041-
1042- int ret = 0 ;
1043-
1044- string fullPath = getFullPath(path_);
1045-
1046- string searchPattern = searchPattern_.stripRight();
1047- if (searchPattern == " ." )
1048- searchPattern = " *" ;
1049- if (searchPattern.length == 0 )
1050- return ret;
1051-
1052- string searchPath = combine(fullPath, searchPattern);
1053- if (std.path.isDirSeparator (searchPath[$ - 1 ])
1054- || searchPath[$ - 1 ] == ' :' )
1055- searchPath ~= ' *' ;
1056-
1057- string userPath = path_;
1058- string tempPath = getDirectoryName(searchPattern);
1059- if (tempPath.length != 0 )
1060- userPath = combine(userPath, tempPath);
1061-
1062- WIN32_FIND_DATA findData;
1063- uint lastError;
1064-
1065- Handle hFind = FindFirstFile(searchPath.toUTF16z(), findData);
1066- if (hFind != INVALID_HANDLE_VALUE ) {
1067- scope (exit) FindClose (hFind);
1068-
1069- do {
1070- if (wcscmp(findData.cFileName.ptr, " ." ) == 0
1071- || wcscmp(findData.cFileName.ptr, " .." ) == 0 )
1072- continue ;
1073-
1074- string result = getSearchResult(userPath, findData);
1075-
1076- if ((includeDirs_ && isDir(findData))
1077- || (includeFiles_ && isFile(findData))) {
1078- if ((ret = action(result)) != 0 )
1079- break ;
1080- }
1081- } while (FindNextFile(hFind, findData));
1082-
1083- lastError = GetLastError();
1084- }
1085-
1086- if (lastError != ERROR_SUCCESS
1087- && lastError != ERROR_NO_MORE_FILES
1088- && lastError != ERROR_FILE_NOT_FOUND )
1089- ioError(lastError, userPath);
1090-
1091- return ret;
1092- }
1093-
1094- }
1095-
1096- /**
1097- * $(RED Deprecated.
1098- * Please use std.file.dirEntries instead.)
1099- *
1100- * Returns an iterable collection of directory names in the specified _path.
1101- */
1102- deprecated
1103- Iterator! (string ) enumDirectories (string path, string searchPattern = " *" ) {
1104- return enumFileSystemNames (path, searchPattern, false , true );
1105- }
1106-
1107- /**
1108- * $(RED Deprecated.
1109- * Please use std.file.dirEntries instead.)
1110- *
1111- * Returns an iterable collection of file names in the specified _path.
1112- */
1113- deprecated
1114- Iterator! (string ) enumFiles (string path, string searchPattern = " *" ) {
1115- return enumFileSystemNames (path, searchPattern, true , false );
1116- }
1117-
1118- /**
1119- * $(RED Deprecated.
1120- * Please use std.file.dirEntries instead.)
1121-
1122- * Returns an iterable collection of file-system entries in the specified _path.
1123- */
1124- deprecated
1125- Iterator! (string ) enumFileSystemEntries (string path, string searchPattern = " *" ) {
1126- return enumFileSystemNames (path, searchPattern, true , true );
1127- }
1128-
1129- deprecated
1130- private Iterator! (string ) enumFileSystemNames (string path, string searchPattern, bool includeFiles, bool includeDirs) {
1131- return new FileSystemIterator(path, searchPattern, includeFiles, includeDirs);
1132- }
0 commit comments