summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Marquess <paul.marquess@btinternet.com>2005-11-01 17:05:38 +0000
committerSteve Hay <SteveHay@planit.com>2005-11-02 09:41:25 +0000
commitbda6ed216cf53718fff278193bffd2c4078fb377 (patch)
tree2f58df7e22ea06050a69bf7ff6f6bfe066578269
parentfc8d54b0ec8f51a3b3106f2c54bd0f1ada739e0e (diff)
downloadperl-bda6ed216cf53718fff278193bffd2c4078fb377.tar.gz
RE: [perl #37571] -z FH broken with Borland build
From: "Paul Marquess" <paul.marquess@ntlworld.com> Message-ID: <003501c5df06$7d63fdb0$0505140a@myopwv.com> p4raw-id: //depot/perl@25952
-rwxr-xr-xt/op/stat.t9
-rw-r--r--win32/win32.c24
2 files changed, 31 insertions, 2 deletions
diff --git a/t/op/stat.t b/t/op/stat.t
index 6eb5c9a0c4..b1f7a150ef 100755
--- a/t/op/stat.t
+++ b/t/op/stat.t
@@ -9,7 +9,7 @@ BEGIN {
use Config;
use File::Spec;
-plan tests => 82;
+plan tests => 86;
my $Perl = which_perl();
@@ -128,6 +128,8 @@ DIAG
# truncate and touch $tmpfile.
open(F, ">$tmpfile") || DIE("Can't open temp test file: $!");
+ok(-z \*F, '-z on empty filehandle');
+ok(! -s \*F, ' and -s');
close F;
ok(-z $tmpfile, '-z on empty file');
@@ -137,6 +139,11 @@ open(F, ">$tmpfile") || DIE("Can't open temp test file: $!");
print F "hi\n";
close F;
+open(F, "<$tmpfile") || DIE("Can't open temp test file: $!");
+ok(!-z *F, '-z on empty filehandle');
+ok( -s *F, ' and -s');
+close F;
+
ok(! -z $tmpfile, '-z on non-empty file');
ok(-s $tmpfile, ' and -s');
diff --git a/win32/win32.c b/win32/win32.c
index 3740e7054d..f6401415a7 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -2734,9 +2734,31 @@ win32_fstat(int fd, Stat_t *sbufptr)
* for write operations, probably because it is opened for reading.
* --Vadim Konovalov
*/
- int rc = fstat(fd,sbufptr);
BY_HANDLE_FILE_INFORMATION bhfi;
+#if defined(WIN64) || defined(USE_LARGE_FILES)
+ /* Borland 5.5.1 has a 64-bit stat, but only a 32-bit fstat */
+ struct stat tmp;
+ int rc = fstat(fd,&tmp);
+
+ sbufptr->st_dev = tmp.st_dev;
+ sbufptr->st_ino = tmp.st_ino;
+ sbufptr->st_mode = tmp.st_mode;
+ sbufptr->st_nlink = tmp.st_nlink;
+ sbufptr->st_uid = tmp.st_uid;
+ sbufptr->st_gid = tmp.st_gid;
+ sbufptr->st_rdev = tmp.st_rdev;
+ sbufptr->st_size = tmp.st_size;
+ sbufptr->st_atime = tmp.st_atime;
+ sbufptr->st_mtime = tmp.st_mtime;
+ sbufptr->st_ctime = tmp.st_ctime;
+#else
+ int rc = fstat(fd,sbufptr);
+#endif
+
if (GetFileInformationByHandle((HANDLE)_get_osfhandle(fd), &bhfi)) {
+#if defined(WIN64) || defined(USE_LARGE_FILES)
+ sbufptr->st_size = (bhfi.nFileSizeHigh << 32) + bhfi.nFileSizeLow ;
+#endif
sbufptr->st_mode &= 0xFE00;
if (bhfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
sbufptr->st_mode |= (S_IREAD + (S_IREAD >> 3) + (S_IREAD >> 6));