From a85b1084c5e802c192c5309093d939c48db91aaf Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Tue, 29 Sep 2020 13:50:31 +0100 Subject: [PATCH] pathut: windows error message --- src/utils/pathut.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/utils/pathut.cpp b/src/utils/pathut.cpp index 164eaa1c..82cf7afd 100644 --- a/src/utils/pathut.cpp +++ b/src/utils/pathut.cpp @@ -1303,16 +1303,18 @@ bool PathDirContents::opendir() SYSPATH(dp, sysdir); m->dirhdl = OPENDIR(sysdir); #ifdef _WIN32 - int rc = GetLastError(); - LOGERR("opendir failed: LastError " << rc << endl); - if (rc == ERROR_NETNAME_DELETED) { - // 64: share disconnected. - // Not too sure of the errno in this case. - // Make sure it's not one of the permissible ones - errno = ENODEV; + if (nullptr == m->dirhdl) { + int rc = GetLastError(); + LOGERR("opendir failed: LastError " << rc << endl); + if (rc == ERROR_NETNAME_DELETED) { + // 64: share disconnected. + // Not too sure of the errno in this case. + // Make sure it's not one of the permissible ones + errno = ENODEV; + } } #endif - return ! (nullptr == m->dirhdl); + return nullptr != m->dirhdl; } void PathDirContents::rewinddir()