This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #125347] allow truncate to work on large files on Win32
authorTony Cook <tony@develop-help.com>
Tue, 9 Jun 2015 23:48:09 +0000 (09:48 +1000)
committerTony Cook <tony@develop-help.com>
Tue, 9 Jun 2015 23:51:22 +0000 (09:51 +1000)
commitd484df69ed26120321cdca989748cd4636b276bb
tree626d5c524ba36af0318fa79ef43d0c80a30721c3
parent4221d7c5eb104778a9335f0f89b12f122d99e425
[perl #125347] allow truncate to work on large files on Win32

truncate($filename, $size) was using a simple PerlIO_open() to open
the file, which on Win32 defaults to a text mode open.

Unfortunately, on a text mode open(), MSVCRT attempts to seek to the
end of file using only 32-bit offsets, which fails.

For good measure, add in O_LARGEFILE if it's available, which may
prevent similar issues on other platforms.

Also, remove the erroneous SETERRNO() added by 375ed12a to the open
failure branch, PerlLIO_open() should already set errno on failure, so
we get sane error messages when the open fails.
pp_sys.c