diff options
Diffstat (limited to 'win32')
-rw-r--r-- | win32/win32.c | 26 | ||||
-rw-r--r-- | win32/win32iop.h | 1 |
2 files changed, 25 insertions, 2 deletions
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) |