summaryrefslogtreecommitdiffstats
path: root/uemis-downloader.c
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2013-12-19 15:00:56 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-19 07:28:27 -0800
commita351bbde24d4a51a544f4d2056595475ff72e06a (patch)
tree44f8db24d1a87f1045a5cf8760463d9a04433b00 /uemis-downloader.c
parent86ed014339f5225c70f10bd569133787bb2ad7ef (diff)
downloadsubsurface-a351bbde24d4a51a544f4d2056595475ff72e06a.tar.gz
Files: use the new opendir() wrapper
This is a separate patch because it required more changes and branches due to how opendir() works on win32 with the separate struct type _WDIR and the according _w... methods for it. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'uemis-downloader.c')
-rw-r--r--uemis-downloader.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/uemis-downloader.c b/uemis-downloader.c
index f69a3527f..2b2515647 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;
}