From 52106ca6eef36265c2ff183daf50a2644aafd182 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 23 Aug 2022 19:09:14 +0200 Subject: [PATCH] fix win32 braindead `_access()` The Windows library call `_access()` styled after POSIX `access(2)` only allows combinations of `R_OK` and `W_OK` and returns `EINVAL` otherwise. cf. https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/access-waccess?view=msvc-170 v2: move to platform-specific header file v3: just strip X_OK (@skullernet) --- inc/shared/platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/shared/platform.h b/inc/shared/platform.h index a529bddd5..9288aa0c4 100644 --- a/inc/shared/platform.h +++ b/inc/shared/platform.h @@ -64,7 +64,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define os_stat(p, s) _stat64(p, s) #define os_fstat(f, s) _fstat64(f, s) #define os_fileno(f) _fileno(f) -#define os_access(p, m) _access(p, m) +#define os_access(p, m) _access(p, (m) & ~X_OK) #define Q_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) #define Q_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) #define Q_STATBUF struct _stat64