summaryrefslogtreecommitdiff
path: root/src/clone.c
diff options
context:
space:
mode:
authorBen Straub <bstraub@github.com>2012-06-21 20:07:32 -0700
committerBen Straub <bstraub@github.com>2012-06-21 20:07:32 -0700
commit830388a728a73c63bb85a59e603333bd210af6ca (patch)
tree1b8b683b1fa2bb30c5c0157fdb2534643382935c /src/clone.c
parentacdd3d959ba95670928bb8a4cfcec42edfafd46e (diff)
downloadlibgit2-830388a728a73c63bb85a59e603333bd210af6ca.tar.gz
Clone: non-empty-dir test, now for Win32.
Diffstat (limited to 'src/clone.c')
-rw-r--r--src/clone.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/clone.c b/src/clone.c
index 7790049cb..9e6f58da8 100644
--- a/src/clone.c
+++ b/src/clone.c
@@ -6,7 +6,10 @@
*/
#include <assert.h>
+
+#ifndef GIT_WIN32
#include <dirent.h>
+#endif
#include "git2/clone.h"
#include "git2/remote.h"
@@ -184,8 +187,15 @@ static bool is_dot_or_dotdot(const char *name)
/* TODO: p_opendir, p_closedir */
static bool path_is_okay(const char *path)
{
- DIR *dir;
+#ifdef GIT_WIN32
+ HANDLE hFind = INVALID_HANDLE_VALUE;
+ wchar_t *wbuf;
+ WIN32_FIND_DATAW ffd;
+#else
+ DIR *dir = NULL;
struct dirent *e;
+#endif
+
bool retval = true;
/* The path must either not exist, or be an empty directory */
@@ -197,6 +207,16 @@ static bool path_is_okay(const char *path)
return false;
}
+#ifdef GIT_WIN32
+ wbuf = gitwin_to_utf16(path);
+ gitwin_append_utf16(wbuf, "\\*", 2);
+ hFind = FindFirstFileW(wbuf, &ffd);
+ if (INVALID_HANDLE_VALUE != hFind) {
+ retval = false;
+ FindClose(hFind);
+ }
+ git__free(wbuf);
+#else
dir = opendir(path);
if (!dir) {
giterr_set(GITERR_OS, "Couldn't open '%s'", path);
@@ -211,8 +231,9 @@ static bool path_is_okay(const char *path)
break;
}
}
-
closedir(dir);
+#endif
+
return retval;
}