summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorVadim Konovalov <vkonovalov@lucent.com>2000-10-16 13:55:03 +0400
committerJarkko Hietaniemi <jhi@iki.fi>2000-10-18 20:52:01 +0000
commit2a07f407e1463660d7c00682ec168da23d057171 (patch)
tree7bb1f756b4b2021c0a9c97650706889b1829a55f /win32
parent37d4d706d45f77e3a247c477a430766026e4e1a1 (diff)
downloadperl-2a07f407e1463660d7c00682ec168da23d057171.tar.gz
Borland C fstat() never saw the fd as writable.
Subject: fix for Borland's weak "stat" (perl@7211) From: "Konovalov, Vadim" <vkonovalov@lucent.com> Message-ID: <402099F49BEED211999700805FC7359F7C0E40@ru0028exch01.spb.lucent.com> p4raw-id: //depot/perl@7362
Diffstat (limited to 'win32')
-rw-r--r--win32/win32.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 0e4c2e0aef..2b31878a52 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -2312,7 +2312,25 @@ win32_abort(void)
DllExport int
win32_fstat(int fd,struct stat *sbufptr)
{
+#ifdef __BORLANDC__
+ /* A file designated by filehandle is not shown as accessible
+ * for write operations, probably because it is opened for reading.
+ * --Vadim Konovalov
+ */
+ int rc = fstat(fd,sbufptr);
+ BY_HANDLE_FILE_INFORMATION bhfi;
+ if (GetFileInformationByHandle((HANDLE)_get_osfhandle(fd), &bhfi)) {
+ sbufptr->st_mode &= 0xFE00;
+ if (bhfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
+ sbufptr->st_mode |= (S_IREAD + (S_IREAD >> 3) + (S_IREAD >> 6));
+ else
+ sbufptr->st_mode |= ((S_IREAD|S_IWRITE) + ((S_IREAD|S_IWRITE) >> 3)
+ + ((S_IREAD|S_IWRITE) >> 6));
+ }
+ return rc;
+#else
return fstat(fd,sbufptr);
+#endif
}
DllExport int