diff options
-rwxr-xr-x | t/op/stat.t | 4 | ||||
-rw-r--r-- | win32/win32.c | 26 | ||||
-rw-r--r-- | win32/win32iop.h | 1 |
3 files changed, 27 insertions, 4 deletions
diff --git a/t/op/stat.t b/t/op/stat.t index aea5cc147c..97f8192885 100755 --- a/t/op/stat.t +++ b/t/op/stat.t @@ -75,8 +75,8 @@ if (!$> || ! -w 'Op.stat.tmp') {print "ok 10\n";} else {print "not ok 10\n";} eval '$> = $olduid;'; # switch uid back (may not be implemented) print "# olduid=$olduid, newuid=$>\n" unless ($> == $olduid); -if ($Is_MSWin32 or ! -x 'Op.stat.tmp') {print "ok 11\n";} -else {print "not ok 11\n";} +if (! -x 'Op.stat.tmp') {print "ok 11\n";} +else {print "not ok 11\n";} foreach ((12,13,14,15,16,17)) { print "ok $_\n"; #deleted tests diff --git a/win32/win32.c b/win32/win32.c index 8ec1f9e1b9..ceaca7ed19 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -514,7 +514,7 @@ opendir(char *filename) /* char *dummy;*/ /* check to see if filename is a directory */ - if(stat(filename, &sbuf) < 0 || sbuf.st_mode & S_IFDIR == 0) { + if (win32_stat(filename, &sbuf) < 0 || sbuf.st_mode & S_IFDIR == 0) { return NULL; } @@ -764,6 +764,7 @@ win32_stat(const char *path, struct stat *buffer) char t[MAX_PATH]; const char *p = path; int l = strlen(path); + int res; if (l > 1) { switch(path[l - 1]) { @@ -776,7 +777,28 @@ win32_stat(const char *path, struct stat *buffer) }; } } - return stat(p, buffer); + res = pIOSubSystem->pfnstat(p,buffer); +#ifdef __BORLANDC__ + if (res == 0) { + if (S_ISDIR(buffer->st_mode)) + buffer->st_mode |= S_IWRITE | S_IEXEC; + else if (S_ISREG(buffer->st_mode)) { + if (l >= 4 && path[l-4] == '.') { + const char *e = path + l - 3; + if (strnicmp(e,"exe",3) + && strnicmp(e,"bat",3) + && strnicmp(e,"com",3) + && (IsWin95() || strnicmp(e,"cmd",3))) + buffer->st_mode &= ~S_IEXEC; + else + buffer->st_mode |= S_IEXEC; + } + else + buffer->st_mode &= ~S_IEXEC; + } + } +#endif + return res; } #ifndef USE_WIN32_RTL_ENV diff --git a/win32/win32iop.h b/win32/win32iop.h index 6ec25b0c3a..56ed40282a 100644 --- a/win32/win32iop.h +++ b/win32/win32iop.h @@ -138,6 +138,7 @@ void * SetIOSubSystem(void *piosubsystem); #define tmpfile() win32_tmpfile() #define abort() win32_abort() #define fstat(fd,bufptr) win32_fstat(fd,bufptr) +#define stat(pth,bufptr) win32_stat(pth,bufptr) #define setmode(fd,mode) win32_setmode(fd,mode) #define lseek(fd,offset,orig) win32_lseek(fd,offset,orig) #define tell(fd) win32_tell(fd) |