aboutsummaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorErik Faye-Lund <kusmabite@gmail.com>2010-11-23 19:38:26 +0100
committerJunio C Hamano <gitster@pobox.com>2010-11-23 16:06:46 -0800
commit20c6788aced1237489824db3b25285afed0ad169 (patch)
treed7822042223a5355f16a6efb3f581dc662a03b48 /compat
parent17194c1e96eddb43d2608fe7bd121256d17118ee (diff)
downloadgit-20c6788aced1237489824db3b25285afed0ad169.tar.gz
git-20c6788aced1237489824db3b25285afed0ad169.tar.xz
msvc: opendir: do not start the search
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>
Diffstat (limited to 'compat')
-rw-r--r--compat/msvc.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/compat/msvc.c b/compat/msvc.c
index c195365d2..88c609325 100644
--- a/compat/msvc.c
+++ b/compat/msvc.c
@@ -16,17 +16,13 @@ DIR *opendir(const char *name)
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;
}