From a7476af8f853f3081bf39d0e023ef7d4284433ec Mon Sep 17 00:00:00 2001 From: firewave Date: Mon, 17 Feb 2025 00:33:04 +0100 Subject: [PATCH] fixed #13641 - FileLister: do not report an error on Windows when the given path does not exist --- cli/filelister.cpp | 5 +++-- test/testfilelister.cpp | 5 ----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/cli/filelister.cpp b/cli/filelister.cpp index 676d0448a51..30392ef4b22 100644 --- a/cli/filelister.cpp +++ b/cli/filelister.cpp @@ -86,8 +86,9 @@ static std::string addFiles2(std::list&files, const std::string HANDLE hFind = FindFirstFileA(searchPattern.c_str(), &ffd); if (INVALID_HANDLE_VALUE == hFind) { const DWORD err = GetLastError(); - if (err == ERROR_FILE_NOT_FOUND) { - // no files matched + if (err == ERROR_FILE_NOT_FOUND || // the pattern did not match anything + err == ERROR_PATH_NOT_FOUND) // the given search path does not exist + { return ""; } return "finding files failed. Search pattern: '" + searchPattern + "'. (error: " + std::to_string(err) + ")"; diff --git a/test/testfilelister.cpp b/test/testfilelister.cpp index 80601d61050..fefafededd9 100644 --- a/test/testfilelister.cpp +++ b/test/testfilelister.cpp @@ -181,12 +181,7 @@ class TestFileLister : public TestFixture { { const std::string addfile = Path::join(Path::join(adddir, "lib2"), "token.cpp"); // does not exist const std::string err = FileLister::addFiles(files, addfile, {}, true,PathMatch({})); -#ifdef _WIN32 - // TODO: get rid of this error - caused by missing intermediate folder - ASSERT_EQUALS("finding files failed. Search pattern: '" + dirprefix_nat + "lib2\\token.cpp'. (error: 3)", err); -#else ASSERT_EQUALS("", err); -#endif } { const std::string addfile = Path::join(Path::join(adddir, "lib"), "matchcompiler.h");