Fix for traditional glob(3) behaviour

fixes #4778
This commit is contained in:
Edgar Fuß 2017-02-09 09:08:48 +01:00 committed by Michael Friedrich
parent 582f700a1a
commit 1fc6d8c899
1 changed files with 12 additions and 1 deletions

View File

@ -48,6 +48,7 @@
# include <sys/types.h>
# include <pwd.h>
# include <grp.h>
# include <errno.h>
#endif /* _WIN32 */
#ifdef _WIN32
@ -502,6 +503,16 @@ static bool GlobHelper(const String& pathSpec, int type, std::vector<String>& fi
}
#endif /* _WIN32 */
#ifndef _WIN32
static int GlobErrorHandler(const char *epath, int eerrno)
{
if (eerrno == ENOTDIR)
return 0;
return eerrno;
}
#endif /* _WIN32 */
/**
* Calls the specified callback for each file matching the path specification.
*
@ -556,7 +567,7 @@ bool Utility::Glob(const String& pathSpec, const boost::function<void (const Str
#else /* _WIN32 */
glob_t gr;
int rc = glob(pathSpec.CStr(), GLOB_ERR | GLOB_NOSORT, NULL, &gr);
int rc = glob(pathSpec.CStr(), GLOB_NOSORT, GlobErrorHandler, &gr);
if (rc < 0) {
if (rc == GLOB_NOMATCH)