Edit report at http://bugs.php.net/bug.php?id=54758&edit=1
ID: 54758 User updated by: noodleyman at gmail dot com Reported by: noodleyman at gmail dot com Summary: GetSize() returns negative values for large file sizes Status: Open Type: Bug Package: Directory function related Operating System: Windows Server 2008 PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: the filesize() function also returns the same results as GetSize() for large files. Previous Comments: ------------------------------------------------------------------------ [2011-05-17 10:11:35] noodleyman at gmail dot com Just confirming that I have also tested this using the code in the example page as linked to below and here are the results <?php $iterator = new DirectoryIterator(dirname(__FILE__)); foreach ($iterator as $fileinfo) { if ($fileinfo->isFile()) { echo $fileinfo->getFilename() . " " . $fileinfo->getSize() . "\n"; } } ?> on the same file, this returns a result of "-79538816" ------------------------------------------------------------------------ [2011-05-16 22:02:11] noodleyman at gmail dot com just realised I typed the wrong function name in the description by mistake. it should read "When using GetSize()" not "When using GetFile()" ------------------------------------------------------------------------ [2011-05-16 21:46:57] noodleyman at gmail dot com Description: ------------ When using GetFile() as documented http://php.net/manual/en/directoryiterator.getsize.php if you run the function on a large file you get negative values which are wrong. I haven't got the exact file size that this happens at, but I have tested with files of 7GB and over, and always get the same result. tested using the function in the test script. Test script: --------------- function dirSize($directory) { $size = 0; foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file){ $size+=$file->getSize(); } return $size; } Then ran function using input value of a directory with a single file of 8,510,398,464 bytes in size. Expected result: ---------------- 8310936 KB Actual result: -------------- -77674.63 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54758&edit=1