From 249f68e3ceaaabdd40964f8ab85645da529ec469 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 30 Sep 2015 11:13:38 +0100 Subject: win32: append '/' to bare drive name in opendir Make 'ls c:' and 'ls c:/*' do the right thing. --- include/mingw.h | 6 ++++++ win32/mingw.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/mingw.h b/include/mingw.h index c15161483..6d494b7ef 100644 --- a/include/mingw.h +++ b/include/mingw.h @@ -434,6 +434,12 @@ int mingw_rmdir(const char *name); */ int utimes(const char *file_name, const struct timeval times[2]); +/* + * dirent.h + */ +DIR *mingw_opendir(const char *path); +#define opendir mingw_opendir + /* * MinGW specific */ diff --git a/win32/mingw.c b/win32/mingw.c index 14cfdd992..876b74221 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -986,3 +986,18 @@ char *file_is_win32_executable(const char *p) return NULL; } + +#undef opendir +DIR *mingw_opendir(const char *path) +{ + char name[4]; + + if (isalpha(path[0]) && path[1] == ':' && path[2] == '\0') { + strcpy(name, path); + name[2] = '/'; + name[3] = '\0'; + path = name; + } + + return opendir(path); +} -- cgit v1.2.3-55-g6feb