summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorSteve Hay <SteveHay@planit.com>2008-03-17 14:36:54 +0000
committerNicholas Clark <nick@ccl4.org>2008-03-25 16:23:46 +0000
commit038ae9a45711aea142f721498a4a61353b40c4e4 (patch)
tree9422e7deed8c530efa3204c14d48bc43bb13b38b /win32
parentc05290799fe650da776e2abcfd6f8da9ec7b5d50 (diff)
downloadperl-038ae9a45711aea142f721498a4a61353b40c4e4.tar.gz
RE: [PATCH revised] Fix ExtUtils::Install under Cygwin
From: "Steve Hay" <SteveHay@planit.com> Message-ID: <1B32FF956ABF414C9BCE5E487A1497E70176BD61@ukmail02.planit.group> "OK, so how about the attached. This fixes up -w for all compilers so that it is symmetrical with chmod(), and adds a note to perltodo on fixing POSIX::access() and chdir()." The whole long thread started here: http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2008-03/msg00056.html p4raw-id: //depot/perl@33566
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/win32/win32.c b/win32/win32.c
index a5723d608b..5a0dde37c7 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -1510,9 +1510,22 @@ win32_stat(const char *path, Stat_t *sbuf)
errno = ENOTDIR;
return -1;
}
+ if (S_ISDIR(sbuf->st_mode)) {
+ /* Ensure the "write" bit is switched off in the mode for
+ * directories with the read-only attribute set. Borland (at least)
+ * switches it on for directories, which is technically correct
+ * (directories are indeed always writable unless denied by DACLs),
+ * but we want stat() and -w to reflect the state of the read-only
+ * attribute for symmetry with chmod(). */
+ DWORD r = GetFileAttributesA(path);
+ if (r != 0xffffffff && (r & FILE_ATTRIBUTE_READONLY)) {
+ sbuf->st_mode &= ~S_IWRITE;
+ }
+ }
#ifdef __BORLANDC__
- if (S_ISDIR(sbuf->st_mode))
- sbuf->st_mode |= S_IWRITE | S_IEXEC;
+ if (S_ISDIR(sbuf->st_mode)) {
+ sbuf->st_mode |= S_IEXEC;
+ }
else if (S_ISREG(sbuf->st_mode)) {
int perms;
if (l >= 4 && path[l-4] == '.') {