From d562642e269cb2f16b717c81851cbf6c1bca72b4 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 30 Jun 2022 18:32:40 +0300 Subject: [PATCH] utils: mdldec: fix build on Windows, use GetFileAttributes instead of stat here --- utils/mdldec/utils.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/utils/mdldec/utils.c b/utils/mdldec/utils.c index 3e1014cc..d43fe266 100644 --- a/utils/mdldec/utils.c +++ b/utils/mdldec/utils.c @@ -17,6 +17,7 @@ GNU General Public License for more details. #include #include #include +#include #include "xash3d_types.h" #include "port.h" #include "crtlib.h" @@ -29,12 +30,26 @@ MakeDirectory */ qboolean MakeDirectory( const char *path ) { - struct stat st; + if( -1 == _mkdir( path )) + { + if( errno == EEXIST ) + { + // TODO: when filesystem library will be ready + // use FS_SysFolderExists here or replace this whole function + // with FS_CreatePath +#if XASH_WIN32 + DWORD dwFlags = GetFileAttributes( path ); - if( -1 == _mkdir( path ) - && ( -1 == stat( path, &st ) - || !S_ISDIR(st.st_mode ) ) ) + return ( dwFlags != -1 ) && ( dwFlags & FILE_ATTRIBUTE_DIRECTORY ); +#else + struct stat buf; + + if( !stat( path, &buf )) + return S_ISDIR( buf.st_mode ); +#endif + } return false; + } return true; }