From: James Turner Date: Mon, 21 Oct 2013 22:51:19 +0000 (+0100) Subject: Fix Dir warnings on Windows. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=784223c67fb09c7245340f034f178b9d5e957489;p=simgear.git 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. --- 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; }