[win32] fix mingw32 gcc 2.8.0 build (DLLs generated seem to be broken
[p5sagit/p5-mst-13.2.git] / win32 / win32.c
index 83ba873..9d819b5 100644 (file)
@@ -36,7 +36,7 @@
 #include <stdarg.h>
 #include <float.h>
 #include <time.h>
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__MINGW32__)
 #include <sys/utime.h>
 #else
 #include <utime.h>
@@ -476,7 +476,10 @@ opendir(char *filename)
 
     /* check to see if filename is a directory */
     if (win32_stat(filename, &sbuf) < 0 || (sbuf.st_mode & S_IFDIR) == 0) {
-       return NULL;
+       /* CRT is buggy on sharenames, so make sure it really isn't */
+       DWORD r = GetFileAttributes(filename);
+       if (r == 0xffffffff || !(r & FILE_ATTRIBUTE_DIRECTORY))
+           return NULL;
     }
 
     /* get the file system characteristics */
@@ -831,7 +834,7 @@ filetime_from_time(PFILETIME pFileTime, time_t Time)
 }
 
 DllExport int
-win32_utime(const char *filename, const struct utimbuf *times)
+win32_utime(const char *filename, struct utimbuf *times)
 {
     HANDLE handle;
     FILETIME ftCreate;
@@ -1190,7 +1193,7 @@ win32_strerror(int e)
 }
 
 DllExport void
-win32_str_os_error(SV *sv, unsigned long dwErr)
+win32_str_os_error(void *sv, DWORD dwErr)
 {
     DWORD dwLen;
     char *sMsg;
@@ -1211,7 +1214,7 @@ win32_str_os_error(SV *sv, unsigned long dwErr)
                        "Unknown error #0x%lX (lookup 0x%lX)",
                        dwErr, GetLastError());
     }
-    sv_setpvn(sv, sMsg, dwLen);
+    sv_setpvn((SV*)sv, sMsg, dwLen);
     LocalFree(sMsg);
 }