Code

msvc: opendir: handle paths ending with a slash
authorErik Faye-Lund <kusmabite@gmail.com>
Tue, 23 Nov 2010 18:38:28 +0000 (19:38 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 Nov 2010 00:06:47 +0000 (16:06 -0800)
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/msvc.c

index 199eb220f42032c1b50dd226dbea084cc10ccd38..fdbfb70a627ccea462e683a56616f2613522daae 100644 (file)
@@ -23,6 +23,8 @@ DIR *opendir(const char *name)
 
        /* check that the pattern won't be too long for FindFirstFileA */
        len = strlen(name);
+       if (is_dir_sep(name[len - 1]))
+               len--;
        if (len + 2 >= MAX_PATH) {
                errno = ENAMETOOLONG;
                return NULL;