Correct File.size

Hello,

how do I get a correct size of file larger than 4GB?
File.size( "filename" ) alway return some negative number. It seems to be some integer overflow.
I use latest rubyinstaller.rubyforge.org instalation package on winxpsp2

Regards

Tom

···

__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail

Hi,

At Wed, 24 Nov 2004 20:15:16 +0900,
Tomas Brixi wrote in [ruby-talk:121251]:

how do I get a correct size of file larger than 4GB?
File.size( "filename" ) alway return some negative number. It seems to be some integer overflow.
I use latest rubyinstaller.rubyforge.org instalation package on winxpsp2

Large file support for Windows hasn't been imported yet.

···

--
Nobu Nakada

Tomas Brixi <tomas_brixi@yahoo.com> wrote in message news:<20041124111513.50696.qmail@web41502.mail.yahoo.com>...

Hello,

how do I get a correct size of file larger than 4GB?
File.size( "filename" ) alway return some negative number. It seems to be some integer overflow.
I use latest rubyinstaller.rubyforge.org instalation package on winxpsp2

Regards

Tom

I don't know why we can't get 64bit support for Windows. This bit of
C code works fine:

#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>

//_INTEGRAL_MAX_BITS

int main()
{
   char* filename = "C:\\delete_this\\big_file.txt";
   struct _stati64 buf;
   unsigned __int64 result;

   result = _stati64( filename, &buf );

   if( result != 0 )
   {
      perror( "Problem getting information" );
   }
   else
   {
      printf( "File size : %lu\n", buf.st_size );
   }

   return 0;
}

See Technical documentation | Microsoft Learn

I'll probably just implement File.size in the win32-file package,
using GetFileSizeEx() until this works as it should.

Regards,

Dan