Commit 5f3f67b16b3f5e568b7a911e8beaf181a87649b9

Ozkan Sezer 2020-10-14T23:01:03

os2/SDL_sysfilesystem.c: use OS/2 api DosCreateDir() instead of mkdir(). mkdir() from watcom and emx differ - the latter being unix-ish, so this change avoids ifdefs.

diff --git a/src/filesystem/os2/SDL_sysfilesystem.c b/src/filesystem/os2/SDL_sysfilesystem.c
index 7fd09c0..dce3f28 100644
--- a/src/filesystem/os2/SDL_sysfilesystem.c
+++ b/src/filesystem/os2/SDL_sysfilesystem.c
@@ -29,8 +29,7 @@
 #include "SDL_filesystem.h"
 #include "../../core/os2/SDL_os2.h"
 
-#include <sys/types.h>
-#include <direct.h>
+#define INCL_DOSFILEMGR
 #define INCL_DOSPROCESS
 #define INCL_DOSERRORS
 #include <os2.h>
@@ -75,7 +74,7 @@ SDL_GetPrefPath(const char *org, const char *app)
 {
   PSZ        pszPath = SDL_getenv( "HOME" );
   CHAR       acBuf[_MAX_PATH];
-  LONG       lPosApp, lPosOrg;
+  int        lPosApp, lPosOrg;
   PSZ        pszApp, pszOrg = OS2_UTF8ToSys( org );
 
   if ( pszOrg == NULL )
@@ -93,10 +92,10 @@ SDL_GetPrefPath(const char *org, const char *app)
 
   lPosApp = SDL_snprintf( acBuf, sizeof(acBuf) - 1, "%s\\%s", pszPath, pszOrg );
   SDL_free( pszOrg );
-  if ( lPosApp == -1 )
+  if ( lPosApp < 0 )
     return NULL;
 
-  mkdir( acBuf );
+  DosCreateDir( acBuf, NULL );
 
   pszApp = OS2_UTF8ToSys( app );
   if ( pszApp == NULL )
@@ -108,10 +107,10 @@ SDL_GetPrefPath(const char *org, const char *app)
   lPosOrg = SDL_snprintf( &acBuf[lPosApp], sizeof(acBuf) - lPosApp - 1, "\\%s",
                           pszApp );
   SDL_free( pszApp );
-  if ( lPosOrg == -1 )
+  if ( lPosOrg < 0 )
     return NULL;
 
-  mkdir( acBuf );
+  DosCreateDir( acBuf, NULL );
   *((PUSHORT)&acBuf[lPosApp + lPosOrg]) = (USHORT)'\0\\';
 
   return OS2_SysToUTF8( acBuf );