in reply to File::stat's size method returns negative values
I couldnt reproduce the error but I don't have any file much over a couple of hundred megs.
It might help you to track down whether the problem is located in the values being reported by the OS, the build of perl, or the File::Stat module if you tried querying the filesize of the affected files directly from the OS. You can use Win32::API to get at the GetFileSize OS API which may eliminate one part of the equation.
#! perl -slw use strict; use Win32API::File 0.08 ':ALL'; use Win32::API; my $GetFileSize = Win32::API->new( 'Kernel32.dll', 'GetFileSize', 'NN' +, 'N' ) or die "Win32::API->new: $!, $^E"; open my $FH, '<', $ARGV[0] or die "Couldn't open $ARGV[0]: $!"; my $nativeFH = GetOsFHandle( $FH ) or die "GetOsFHandle: $^E"; my $OSSize = $GetFileSize->Call( $nativeFH, 0 ); die "GetFileSize error:$^E" if $OSSize == 0xFFFFFFFF; # See msdn docs. print "$ARGV[0]: $OSSize";
The call as shown will only correctly report filesizes upto 4 Gb -2. To get at sizes larger there is some extra (twisted!) logic required using the second parm to the call. See the doc link above for details.
|
---|