From 784223c67fb09c7245340f034f178b9d5e957489 Mon Sep 17 00:00:00 2001 From: James Turner Date: Mon, 21 Oct 2013 23:51:19 +0100 Subject: [PATCH] Fix Dir warnings on Windows. Test result of GetLastError so we don't log a warning in the 'nothing matched' case. Makes early startup logging much more pleasant, especially when scanning aircraft dirs. --- simgear/misc/sg_dir.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/simgear/misc/sg_dir.cxx b/simgear/misc/sg_dir.cxx index 9a084a6d..5ffc10d6 100644 --- a/simgear/misc/sg_dir.cxx +++ b/simgear/misc/sg_dir.cxx @@ -149,7 +149,11 @@ PathList Dir::children(int types, const std::string& nameFilter) const WIN32_FIND_DATA fData; HANDLE find = FindFirstFile(search.c_str(), &fData); if (find == INVALID_HANDLE_VALUE) { - SG_LOG(SG_GENERAL, SG_WARN, "Dir::children: FindFirstFile failed:" << _path.str()); + int err = GetLastError(); + if (err != ERROR_FILE_NOT_FOUND) { + SG_LOG(SG_GENERAL, SG_WARN, "Dir::children: FindFirstFile failed:" << + _path.str() << " with error:" << err); + } return result; } -- 2.39.5