Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 228b68c

Browse files
committed
Updated toolchain verify for edge error cases
1 parent fc24c7a commit 228b68c

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

buildcc/lib/toolchain/src/api/toolchain_verify.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <unordered_set>
2121
#include <vector>
2222

23+
#include <iostream>
24+
2325
#include "toolchain/toolchain.h"
2426

2527
#include "env/assert_fatal.h"
@@ -207,18 +209,20 @@ ToolchainVerify<T>::Verify(const VerifyToolchainConfig &config) {
207209
continue;
208210
}
209211

212+
std::error_code ec;
213+
auto directory_iterator = fs::directory_iterator(p, ec);
214+
if (ec) {
215+
continue;
216+
}
217+
210218
// For each directory, Check if ALL toolchain filenames are found
211-
for (const auto &dir_iter : fs::directory_iterator(p)) {
212-
try {
213-
if (!dir_iter.is_regular_file()) {
214-
continue;
215-
}
216-
const auto &filename = dir_iter.path().filename().string();
217-
matcher.Check(filename);
218-
} catch (const std::exception &e) {
219-
// NOTE, Certain paths might not be accessible i.e restricted
220-
env::log_critical(__FUNCTION__, e.what());
219+
for (const auto &dir_iter : directory_iterator) {
220+
bool is_regular_file = dir_iter.is_regular_file(ec);
221+
if (!is_regular_file || ec) {
222+
continue;
221223
}
224+
const auto &filename = dir_iter.path().filename().string();
225+
matcher.Check(filename);
222226
}
223227

224228
// Store verified toolchain path if found

0 commit comments

Comments
 (0)