php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20446 negative filesize() returned on large files > 2Gb
Submitted: 2002-11-15 09:23 UTC Modified: 2002-11-15 10:09 UTC
From: andrew dot robinson at gni dot co dot uk Assigned:
Status: Not a bug Package: *Directory/Filesystem functions
PHP Version: 4.2.3 OS: NT4 - SP 6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: andrew dot robinson at gni dot co dot uk
New email:
PHP Version: OS:

 

 [2002-11-15 09:23 UTC] andrew dot robinson at gni dot co dot uk
the following works fine on small files (<2Gb) but returns negative numbers for files larger.

while ( $file = readdir($dp) ){
	clearstatcache();
	if (! ereg("^[.]+$|^$",$file) ){
		$stats = stat("$DIRNAME$file");
		echo "$DIRNAME$file\t" . $stats[7] . "\t" filesize("$DIRNAME$file") . "\n";
	}
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-15 09:26 UTC] derick@php.net
This is not really a bug, PHP simply doesn't support unsigned integers, and a signed integer on Windows/i386 only goes to 2^31 - 1 (about 2GB).

Ddderick
 [2002-11-15 09:30 UTC] andrew dot robinson at gni dot co dot uk
disk_total_space() appears to cope very well with large volumes (100Gb+).  Are there any work arounds for filesize() ?
 [2002-11-15 09:33 UTC] iliaa@php.net
You could try doing:
printf("%u", filesize("your_file"));
 [2002-11-15 10:09 UTC] andrew dot robinson at gni dot co dot uk
Although the number is no longer negative the size is unfortunately inaccurate by quite a bit.  It's a shame as php was in the running as our cli for scripting on NT.  I doubt it will pass acceptance testing now.

Thanks for all your help it was appreciated.
Regards
Andy
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 17:01:29 2024 UTC