Skip to content

Commit 17e8d5c

Browse files
authored
Merge pull request #41877 from keith/ks/swift-stdlib-tool-add-error-for-missing-directories
[swift-stdlib-tool] Add error for missing directories
2 parents 3b661bc + a61899f commit 17e8d5c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tools/swift-stdlib-tool/swift-stdlib-tool.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,11 @@ std::string filename(std::string path) {
723723
return basename_r(pathCstr, filename) ? filename : pathCstr;
724724
}
725725

726+
bool directory_exists(const std::string &path) {
727+
struct stat st;
728+
return stat(path.c_str(), &st) == 0 && S_ISDIR(st.st_mode);
729+
}
730+
726731
// This executable's own path.
727732
std::string self_executable = []() -> std::string {
728733
char path[MAXPATHLEN] = {0};
@@ -1110,6 +1115,11 @@ int main(int argc, const char *argv[]) {
11101115
platform = filename(src_dirs.front());
11111116
}
11121117

1118+
for (const auto &src_dir : src_dirs) {
1119+
if (!directory_exists(src_dir))
1120+
fail("Source directory does not exist: %s", src_dir.c_str());
1121+
}
1122+
11131123
// Add the platform to unsigned_dst_dir if it is not already present.
11141124
if (!unsigned_dst_dir.empty()) {
11151125
const auto unsigned_platform = unsigned_dst_dir;

0 commit comments

Comments
 (0)