From bd5fd2685a1ca05b81e41c2e73781bd7652933ec Mon Sep 17 00:00:00 2001 From: tqfx Date: Sat, 26 Aug 2023 00:11:48 +0800 Subject: [PATCH] fix: look for a .lua-format in the directory without permissions --- src/main.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e7d711a..ead3047 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -406,11 +406,15 @@ int main(int argc, const char* argv[]) { if (configFileName.empty()) { fs::path current = fs::current_path(); while (configFileName.empty()) { - for (const auto& entry : fs::directory_iterator(current)) { - const fs::path& candidate = entry.path(); - if (candidate.filename() == ".lua-format") { - configFileName = candidate.string(); + try { + for (const auto& entry : fs::directory_iterator(current)) { + const fs::path& candidate = entry.path(); + if (candidate.filename() == ".lua-format") { + configFileName = candidate.string(); + } } + } catch(const fs::filesystem_error&) { + break; } fs::path parent = current.parent_path();