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.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller

In reply to Re: File::stat's size method returns negative values by BrowserUk
in thread File::stat's size method returns negative values by djw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.