@@ -953,7 +953,21 @@ std::vector<uint8_t> query_code_signature(std::string file) {
953
953
}
954
954
955
955
template <typename F>
956
- void enumerateDirectory (std::string directory, F &&func) {
956
+ void listDirectoryContents (std::string directory, F &&func) {
957
+ DIR *dir = opendir (directory.c_str ());
958
+ if (dir == NULL ) {
959
+ return ;
960
+ }
961
+
962
+ struct dirent *entry;
963
+ while ((entry = readdir (dir))) {
964
+ func (directory + " /" + entry->d_name );
965
+ }
966
+ closedir (dir);
967
+ }
968
+
969
+ template <typename F>
970
+ void recursivelyListFiles (std::string directory, F &&func) {
957
971
DIR *dir = opendir (directory.c_str ());
958
972
if (dir == NULL ) {
959
973
return ;
@@ -975,7 +989,7 @@ void enumerateDirectory(std::string directory, F &&func) {
975
989
}
976
990
closedir (dir);
977
991
for (const auto &path : subpaths) {
978
- enumerateDirectory (path, func);
992
+ recursivelyListFiles (path, func);
979
993
}
980
994
}
981
995
@@ -1085,7 +1099,7 @@ int main(int argc, const char *argv[]) {
1085
1099
std::string root_path =
1086
1100
parentPath (parentPath (self_executable)) + " /" + " lib" ;
1087
1101
1088
- enumerateDirectory (root_path, [&](std::string entry) {
1102
+ listDirectoryContents (root_path, [&](std::string entry) {
1089
1103
if (filename (entry).compare (0 , strlen (" swift-" ), " swift-" ) == 0 ) {
1090
1104
src_dirs.push_back (entry + " /" + platform);
1091
1105
}
@@ -1119,7 +1133,7 @@ int main(int argc, const char *argv[]) {
1119
1133
1120
1134
// Collect executables from the --scan-folder locations.
1121
1135
for (const auto &embedDir : embedDirs) {
1122
- enumerateDirectory (embedDir, [&](std::string entry) {
1136
+ recursivelyListFiles (embedDir, [&](std::string entry) {
1123
1137
if (0 == access (entry.c_str (), X_OK)) {
1124
1138
executables.push_back (entry);
1125
1139
} else {
0 commit comments