Hello,

PA builds fine on MinGW except for the use of the scandir function in 
pulsecore/conf-parser.c, so I provided a Win32 implementation. With this patch 
the latest code builds on Win32 without problems.

-- 
Vadim Troshchinskiy
>From 0b0bd5fe0f0483a7113e83a0f0bdf386ead2d1dd Mon Sep 17 00:00:00 2001
From: Vadim Troshchinskiy <[email protected]>
Date: Mon, 24 Jul 2017 16:24:31 +0200
Subject: [PATCH] Provide a replacement for scandir on Win32

---
 src/pulsecore/conf-parser.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/pulsecore/conf-parser.c b/src/pulsecore/conf-parser.c
index 60345adf..a08ff9e8 100644
--- a/src/pulsecore/conf-parser.c
+++ b/src/pulsecore/conf-parser.c
@@ -218,6 +218,35 @@ finish:
         fclose(f);
 
     if (use_dot_d) {
+#ifdef OS_IS_WIN32
+        char *dir_name = pa_sprintf_malloc("%s.d", filename);
+        char *pattern = pa_sprintf_malloc("%s\\*.*", dir_name);
+        HANDLE fh;
+        WIN32_FIND_DATA wfd;
+
+        fh = FindFirstFile(pattern, &wfd);
+        if ( fh != INVALID_HANDLE_VALUE ) {
+            do {
+                if( ! (wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ) {
+                    char *filename2 = pa_sprintf_malloc("%s\\%s", dir_name, wfd.cFileName);
+                    pa_config_parse(filename2, NULL, t, proplist, false, userdata);
+                    pa_xfree(filename2);
+                }
+            } while(FindNextFile(fh, &wfd));
+            FindClose(fh);
+        } else {
+            DWORD err = GetLastError();
+
+            if ( err == ERROR_PATH_NOT_FOUND ) {
+                pa_log_debug("%s does not exist, ignoring.", dir_name);
+            } else {
+                pa_log_warn("FindFirstFile failed %s with error %d, ignoring", err, pattern);
+            }
+        }
+
+        pa_xfree(pattern);
+        pa_xfree(dir_name);
+#else
         char *dir_name;
         int n;
         struct dirent **entries = NULL;
@@ -247,6 +276,7 @@ finish:
         }
 
         pa_xfree(dir_name);
+#endif
     }
 
     return r;
-- 
2.13.3

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
pulseaudio-discuss mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss

Reply via email to