more testsuite smarts (many of them courtesy Ilya)
[p5sagit/p5-mst-13.2.git] / win32 / win32.c
index 1e4e4c5..ec04823 100644 (file)
@@ -682,8 +682,15 @@ win32_opendir(char *filename)
 
     /* Create the search pattern */
     strcpy(scanname, filename);
-    if (scanname[len-1] != '/' && scanname[len-1] != '\\')
+
+    /* bare drive name means look in cwd for drive */
+    if (len == 2 && isALPHA(scanname[0]) && scanname[1] == ':') {
+       scanname[len++] = '.';
+       scanname[len++] = '/';
+    }
+    else if (scanname[len-1] != '/' && scanname[len-1] != '\\') {
        scanname[len++] = '/';
+    }
     scanname[len++] = '*';
     scanname[len] = '\0';
 
@@ -929,10 +936,10 @@ win32_stat(const char *path, struct stat *buffer)
            t[l] = '\0';
            path = t;
            break;
-       /* FindFirstFile() is buggy with "x:", so add a slash :-( */
+       /* FindFirstFile() is buggy with "x:", so add a dot :-( */
        case ':':
            if (l == 2 && isALPHA(path[0])) {
-               t[0] = path[0]; t[1] = ':'; t[2] = '/'; t[3] = '\0';
+               t[0] = path[0]; t[1] = ':'; t[2] = '.'; t[3] = '\0';
                l = 3;
                path = t;
            }
@@ -1307,7 +1314,12 @@ win32_uname(struct utsname *name)
        SYSTEM_INFO info;
        char *arch;
        GetSystemInfo(&info);
+
+#ifdef __BORLANDC__
+       switch (info.u.s.wProcessorArchitecture) {
+#else
        switch (info.wProcessorArchitecture) {
+#endif
        case PROCESSOR_ARCHITECTURE_INTEL:
            arch = "x86"; break;
        case PROCESSOR_ARCHITECTURE_MIPS:
@@ -2860,8 +2872,8 @@ static
 XS(w32_GetTickCount)
 {
     dXSARGS;
-    EXTEND(SP,1);
     DWORD msec = GetTickCount();
+    EXTEND(SP,1);
     if ((IV)msec > 0)
        XSRETURN_IV(msec);
     XSRETURN_NV(msec);
@@ -2961,6 +2973,17 @@ XS(w32_Sleep)
     XSRETURN_YES;
 }
 
+static
+XS(w32_CopyFile)
+{
+    dXSARGS;
+    if (items != 3)
+       croak("usage: Win32::CopyFile($from, $to, $overwrite)");
+    if (CopyFile(SvPV_nolen(ST(0)), SvPV_nolen(ST(1)), !SvTRUE(ST(2))))
+       XSRETURN_YES;
+    XSRETURN_NO;
+}
+
 void
 Perl_init_os_extras()
 {
@@ -2992,6 +3015,7 @@ Perl_init_os_extras()
     newXS("Win32::GetShortPathName", w32_GetShortPathName, file);
     newXS("Win32::GetFullPathName", w32_GetFullPathName, file);
     newXS("Win32::GetLongPathName", w32_GetLongPathName, file);
+    newXS("Win32::CopyFile", w32_CopyFile, file);
     newXS("Win32::Sleep", w32_Sleep, file);
 
     /* XXX Bloat Alert! The following Activeware preloads really