summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 17194c1)
raw | patch | inline | side by side (parent: 17194c1)
author | Erik Faye-Lund <kusmabite@gmail.com> | |
Tue, 23 Nov 2010 18:38:26 +0000 (19:38 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 24 Nov 2010 00:06:46 +0000 (16:06 -0800) |
compat/mingw.c's readdir expects to be the one that starts the search,
and if it isn't, then the first entry will be missing or incorrect.
Fix this by removing the call to _findfirst, and initializing dd_handle
to INVALID_HANDLE_VALUE.
At the same time, make sure we use FindClose instead of _findclose,
which is symmetric to readdir's FindFirstFile. Take into account that
the find-handle might already be closed by readdir.
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
and if it isn't, then the first entry will be missing or incorrect.
Fix this by removing the call to _findfirst, and initializing dd_handle
to INVALID_HANDLE_VALUE.
At the same time, make sure we use FindClose instead of _findclose,
which is symmetric to readdir's FindFirstFile. Take into account that
the find-handle might already be closed by readdir.
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/msvc.c | patch | blob | history |
diff --git a/compat/msvc.c b/compat/msvc.c
index c195365d2cf77348b0646f210adb984ae75d07bc..88c6093258eaa117996668026734ea8e6eb2761a 100644 (file)
--- a/compat/msvc.c
+++ b/compat/msvc.c
p->dd_name[len] = '/';
p->dd_name[len+1] = '*';
- p->dd_handle = _findfirst(p->dd_name, &p->dd_dta);
-
- if (p->dd_handle == -1) {
- free(p);
- return NULL;
- }
+ p->dd_handle = (long)INVALID_HANDLE_VALUE;
return p;
}
int closedir(DIR *dir)
{
- _findclose(dir->dd_handle);
+ if (dir->dd_handle != (long)INVALID_HANDLE_VALUE)
+ FindClose((HANDLE)dir->dd_handle);
free(dir);
return 0;
}