From e3a4b7294c08cb31d2ec1222ae6971478913eb74 Mon Sep 17 00:00:00 2001 From: fyodor Date: Tue, 12 Sep 2006 03:33:24 +0000 Subject: [PATCH] portability fix from diman --- nmap.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nmap.cc b/nmap.cc index 94503c67c..9e67734de 100644 --- a/nmap.cc +++ b/nmap.cc @@ -2276,6 +2276,12 @@ void sigdie(int signo) { exit(1); } +#ifdef WIN32 +#define STAT_READABLE(st) st.st_mode & S_IREAD +#else +#define STAT_READABLE(st) st.st_mode & S_IRUSR +#endif + /* Returns true (nonzero) if the file pathname given exists, is not * a directory and is readable by the executing process. Returns * zero if it is not @@ -2286,7 +2292,7 @@ static int fileexistsandisreadable(char *pathname) { if (stat(pathname, &st) == -1) return 0; - if (!S_ISDIR(st.st_mode) && (access(pathname, R_OK) != -1)) + if (!S_ISDIR(st.st_mode) && STAT_READABLE(st)) return 1; return 0;