Correct File.size

T

Tomas Brixi

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
 
N

nobu.nokada

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.
 
D

Daniel Berger

Tomas Brixi said:
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 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/pgalpha98/html/int64.asp

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

Regards,

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,799
Messages
2,569,654
Members
45,386
Latest member
Daniel_Dan
Top