@@ -953,7 +953,21 @@ std::vector<uint8_t> query_code_signature(std::string file) {
953953}
954954
955955template <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) {
957971 DIR *dir = opendir (directory.c_str ());
958972 if (dir == NULL ) {
959973 return ;
@@ -975,7 +989,7 @@ void enumerateDirectory(std::string directory, F &&func) {
975989 }
976990 closedir (dir);
977991 for (const auto &path : subpaths) {
978- enumerateDirectory (path, func);
992+ recursivelyListFiles (path, func);
979993 }
980994}
981995
@@ -1085,7 +1099,7 @@ int main(int argc, const char *argv[]) {
10851099 std::string root_path =
10861100 parentPath (parentPath (self_executable)) + " /" + " lib" ;
10871101
1088- enumerateDirectory (root_path, [&](std::string entry) {
1102+ listDirectoryContents (root_path, [&](std::string entry) {
10891103 if (filename (entry).compare (0 , strlen (" swift-" ), " swift-" ) == 0 ) {
10901104 src_dirs.push_back (entry + " /" + platform);
10911105 }
@@ -1119,7 +1133,7 @@ int main(int argc, const char *argv[]) {
11191133
11201134 // Collect executables from the --scan-folder locations.
11211135 for (const auto &embedDir : embedDirs) {
1122- enumerateDirectory (embedDir, [&](std::string entry) {
1136+ recursivelyListFiles (embedDir, [&](std::string entry) {
11231137 if (0 == access (entry.c_str (), X_OK)) {
11241138 executables.push_back (entry);
11251139 } else {
0 commit comments