summaryrefslogtreecommitdiff
path: root/content/fetchers/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'content/fetchers/file.c')
-rw-r--r--content/fetchers/file.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/content/fetchers/file.c b/content/fetchers/file.c
index f0c78ded2..7c87a905b 100644
--- a/content/fetchers/file.c
+++ b/content/fetchers/file.c
@@ -505,20 +505,18 @@ static void fetch_file_process_dir(struct fetch_file_context *ctx,
char urlpath[PATH_MAX]; /* buffer for leaf entry path */
struct dirent *ent; /* current directroy entry */
-#if defined(_WIN32)
- /* Mingw lacks scandir and alphasort functions, so use opendir */
- DIR *scandir; /* handle for enumerating the directory */
-
- scandir = opendir(ctx->path);
- if (scandir == NULL) {
-#else
- /* Use scandir everywhere else */
+#ifdef HAVE_SCANDIR
struct dirent **listing = NULL; /* directory entry listing */
int i; /* directory entry index */
int n; /* number of directory entries */
n = scandir(ctx->path, &listing, 0, alphasort);
if (n < 0) {
+#else
+ DIR *scandir; /* handle for enumerating the directory */
+
+ scandir = opendir(ctx->path);
+ if (scandir == NULL) {
#endif
fetch_file_process_error(ctx,
fetch_file_errno_to_http_code(errno));
@@ -577,11 +575,11 @@ static void fetch_file_process_dir(struct fetch_file_context *ctx,
if (fetch_file_send_callback(&msg, ctx))
goto fetch_file_process_dir_aborted;
-#if defined(_WIN32)
- while ((ent = readdir(scandir)) != NULL) {
-#else
+#ifdef HAVE_SCANDIR
for (i = 0; i < n; i++) {
ent = listing[i];
+#else
+ while ((ent = readdir(scandir)) != NULL) {
#endif
if (ent->d_name[0] == '.')
@@ -667,15 +665,15 @@ static void fetch_file_process_dir(struct fetch_file_context *ctx,
fetch_file_process_dir_aborted:
-#if defined(_WIN32)
- closedir(scandir);
-#else
+#ifdef HAVE_SCANDIR
if (listing != NULL) {
for (i = 0; i < n; i++) {
free(listing[i]);
}
free(listing);
}
+#else
+ closedir(scandir);
#endif
}