Re: [PHP] Problems with filesize() and large files

2002-09-09 Thread Evan Nemerson

Just figure out what the limits of 32-bit integers are. It might be enough to 
do something like $num = INT_MAX + abs( INT_MIN - filesize(bigFile) );

I'm not sure if that's the right math, but I hope you get the idea.

If memory serves, what's happening is that the 32nd bit (which represents the 
sign- 0='+', 1='-') is getting flipped because you're trying to store 8 bits 
of data in 7 bits of space.



On Monday 09 September 2002 15:07, Kurt Glazemakers wrote:
 Hi,

 I need the filesize in PHP for very large files, over 2 Gigabyte. The
 problem is that the integer returns the size in byte as an integer. If
 the integer is too big, it returns an negative value.

 Is it possible to extend the integer to 64 bit ? Or any other solution,
 to solve this problem ?

 Example:

 C:\php423\phpphp -q c:\devel\filesize.php
 int(-834864026)

 Which checks the size of a 3 Gigabyte file.

 Many thanks,

 Kurt


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Problems with filesize() and large files

2002-09-09 Thread Kurt Glazemakers

Yep,

I was thinking about a similar solution, but if the file exceeds the 4
Gigabyte limit, the solution won't help anymore. And it wil be a matter
of time to exceed this limit.

But I'm afraid there is no other solution for this.

Kurt

-Original Message-
From: Evan Nemerson [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, September 10, 2002 12:27 AM
To: Kurt Glazemakers; [EMAIL PROTECTED]
Subject: Re: [PHP] Problems with filesize() and large files

Just figure out what the limits of 32-bit integers are. It might be
enough to 
do something like $num = INT_MAX + abs( INT_MIN - filesize(bigFile) );

I'm not sure if that's the right math, but I hope you get the idea.

If memory serves, what's happening is that the 32nd bit (which
represents the 
sign- 0='+', 1='-') is getting flipped because you're trying to store 8
bits 
of data in 7 bits of space.



On Monday 09 September 2002 15:07, Kurt Glazemakers wrote:
 Hi,

 I need the filesize in PHP for very large files, over 2 Gigabyte. The
 problem is that the integer returns the size in byte as an integer. If
 the integer is too big, it returns an negative value.

 Is it possible to extend the integer to 64 bit ? Or any other
solution,
 to solve this problem ?

 Example:

 C:\php423\phpphp -q c:\devel\filesize.php
 int(-834864026)

 Which checks the size of a 3 Gigabyte file.

 Many thanks,

 Kurt


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Problems with filesize() and large files

2002-09-09 Thread timo stamm

Hi Kurt,


not pretty, but what about using the CLI tool ls with an exec() call?


Timo


Am Dienstag den, 10. September 2002, um 00:07, schrieb Kurt Glazemakers:


 Hi,

 I need the filesize in PHP for very large files, over 2 Gigabyte. The
 problem is that the integer returns the size in byte as an integer. If
 the integer is too big, it returns an negative value.

 Is it possible to extend the integer to 64 bit ? Or any other solution,
 to solve this problem ?

 Example:

 C:\php423\phpphp -q c:\devel\filesize.php
 int(-834864026)

 Which checks the size of a 3 Gigabyte file.

 Many thanks,

 Kurt

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php