Bug #54758 [Opn->Dup]: GetSize() returns negative values for large file sizes
| From: | cmb@php.net | Date: | Wed, 22 Jul 2015 20:23:26 +0000 |
| Subject: | Bug #54758 [Opn->Dup]: GetSize() returns negative values for large file sizes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-194640@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=54758&edit=1
ID: 54758
Updated by: cmb@php.net
Reported by: noodleyman at gmail dot com
Summary: GetSize() returns negative values for large file
sizes
-Status: Open
+Status: Duplicate
Type: Bug
Package: Directory function related
Operating System: Windows Server 2008
PHP Version: 5.3.6
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Indeed, clicky!
Previous Comments:
------------------------------------------------------------------------
[2011-10-14 15:36:34] clicky at erebot dot net
This is a duplicate of bug #27792.
Short answer is: PHP does not support large files (>= 2GB) as of yet.
------------------------------------------------------------------------
[2011-05-17 11:21:38] noodleyman at gmail dot com
now using these functions to get a work around.
function dos_filesize($fn) {
if (is_file($fn))
return exec('FOR %A IN ("'.$fn.'") DO @ECHO %~zA');
else
return '0';
}
function dirSize($directory) {
$size = 0;
foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file){
$size+=dos_filesize($file);
}
return $size;
}
------------------------------------------------------------------------
[2011-05-17 10:14:14] noodleyman at gmail dot com
the filesize() function also returns the same results as GetSize() for large files.
------------------------------------------------------------------------
[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()"
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=54758
--
Edit this bug report at https://bugs.php.net/bug.php?id=54758&edit=1