if (!S_ISDIR(stat_buf.st_mode))
goto err;
-#if defined(HAVE_EACCESS)
- if (eaccess(path, R_OK | X_OK) != 0)
+ if (!check_eaccess(path, R_OK | X_OK))
goto err;
-#elif defined(HAVE_EUIDACCESS)
- if (euidaccess(path, R_OK | X_OK) != 0)
- goto err;
-#endif
darray_append(ctx->includes, tmp);
return 1;
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
+#if defined(HAVE_EACCESS) || defined(HAVE_EUIDACCESS)
+#include <unistd.h>
+#else
+/* Required on Windows where unistd.h doesn't exist */
+#define R_OK 4 /* Test for read permission. */
+#define W_OK 2 /* Test for write permission. */
+#define X_OK 1 /* Test for execute permission. */
+#define F_OK 0 /* Test for existence. */
+#endif
#include "darray.h"
void
unmap_file(char *string, size_t size);
+static inline bool
+check_eaccess(const char *path, int mode)
+{
+#if defined(HAVE_EACCESS)
+ if (eaccess(path, mode) != 0)
+ return false;
+#elif defined(HAVE_EUIDACCESS)
+ if (euidaccess(path, mode) != 0)
+ return false;
+#endif
+
+ return true;
+}
+
#if defined(HAVE_SECURE_GETENV)
# define secure_getenv secure_getenv
#elif defined(HAVE___SECURE_GETENV)