windows: Workaround for WinXP systems.
authorRyan C. Gordon <icculus@icculus.org>
Mon, 18 Mar 2019 13:36:16 -0400
changeset 1663 7564353d225f
parent 1660 89e1b79e10c6
child 1664 b76a47b006f6
windows: Workaround for WinXP systems. (transplanted from c8f3bbd689d6b71b84c11db74275ea3d56fef961)
src/physfs_platform_windows.c
--- a/src/physfs_platform_windows.c	Mon Mar 18 11:27:26 2019 -0400
+++ b/src/physfs_platform_windows.c	Mon Mar 18 13:36:16 2019 -0400
@@ -572,11 +572,20 @@
         /*
          * Should fail. Will write the size of the profile path in
          *  psize. Also note that the second parameter can't be
-         *  NULL or the function fails.
+         *  NULL or the function fails on Windows XP, but has to be NULL on
+         *  Windows 10 or it will fail.  :(
          */
         rc = pGetDir(accessToken, NULL, &psize);
         GOTO_IF(rc, PHYSFS_ERR_OS_ERROR, done);  /* should have failed! */
 
+        if (psize == 0)  /* probably on Windows XP, try a different way. */
+        {
+            char x = 0;
+            rc = pGetDir(accessToken, &x, &psize);
+            GOTO_IF(rc, PHYSFS_ERR_OS_ERROR, done);  /* should have failed! */
+            GOTO_IF(!psize, PHYSFS_ERR_OS_ERROR, done);  /* Uhoh... */
+        } /* if */
+
         /* Allocate memory for the profile directory */
         wstr = (LPWSTR) __PHYSFS_smallAlloc((psize + 1) * sizeof (WCHAR));
         if (wstr != NULL)