[PATCH 6/8] Files: some win32 changes in uemis-downloader.c
Lubomir I. Ivanov
neolit123 at gmail.com
Wed Dec 18 14:47:04 UTC 2013
From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
number_of_file() now has more #ifdef WIN32 branches
to make this work.
Also instead of 'struct dirent', 'struct _wdirent' has to
be used and the set of _w... functions.
Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---
uemis-downloader.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/uemis-downloader.c b/uemis-downloader.c
index f69a352..2b25156 100644
--- a/uemis-downloader.c
+++ b/uemis-downloader.c
@@ -139,18 +139,33 @@ static long bytes_available(int file)
static int number_of_file(char *path)
{
int count = 0;
- DIR * dirp;
- struct dirent * entry;
+#ifdef WIN32
+ struct _wdirent *entry;
+ _WDIR *dirp = (_WDIR *)subsurface_opendir(path);
+#else
+ struct dirent *entry;
+ DIR *dirp = (DIR *)subsurface_opendir(path);
+#endif
- dirp = opendir(path);
- while (dirp && (entry = readdir(dirp)) != NULL) {
-#ifndef WIN32
+ while (dirp) {
+#ifdef WIN32
+ entry = _wreaddir(dirp);
+ if (!entry)
+ break;
+#else
+ entry = readdir(dirp);
+ if (!entry)
+ break;
if (entry->d_type == DT_REG) /* If the entry is a regular file */
#endif
count++;
}
+#ifdef WIN32
+ _wclosedir(dirp);
+#else
closedir(dirp);
+#endif
return count;
}
--
1.7.11.msysgit.0
More information about the subsurface
mailing list