summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@engin.umich.edu>1997-08-01 01:26:12 +1200
committerTim Bunce <Tim.Bunce@ig.co.uk>1997-08-07 00:00:00 +1200
commit67fbe06e7fe7dfa95ec51821be9237cabdf281e2 (patch)
tree271a3678200e5f490bcfe7cf7fed9b8175ee5d1a /win32
parent2bc71ef813f5d9e1635af64220cf742859485b38 (diff)
downloadperl-67fbe06e7fe7dfa95ec51821be9237cabdf281e2.tar.gz
win32_stat() fixes (2nd try)
Here's a better version (the earlier one didn't clear the execute bit for some files). This one also enables a test. p5p-msgid: 199708040137.VAA16810@aatma.engin.umich.edu
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c26
-rw-r--r--win32/win32iop.h1
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)