[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Correct File.size

Tomas Brixi

11/24/2004 11:15:00 AM

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


2 Answers

nobu.nokada

11/24/2004 2:24:00 PM

0

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


djberg96

11/24/2004 4:07:00 PM

0

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

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

Regards,

Dan