php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47025 DirectoryIterator::getSize always returns a value under 4GB
Submitted: 2009-01-07 11:35 UTC Modified: 2009-01-08 00:42 UTC
From: bfanger at gmail dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.8 OS: Mac OS X 10.5.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: bfanger at gmail dot com
New email:
PHP Version: OS:

 

 [2009-01-07 11:35 UTC] bfanger at gmail dot com
Description:
------------
I tried to create a directory listing including the filesize.
But the directory containing a 4.4GB file shows an incorrect filesize of 400MB

DirectoryIterator::getSize and filesize() have the same (32bit signed int) problem.

Possible solutions:
1. Use a string (or other datatype) that can contain the filesize. (Bug #44215)

2. An extra optional parameter: filesize(string $filename, [bool human_readable = false])



Reproduce code:
---------------
Using (not-existing) solution 2

$file = "/path/to/4.4GiB.file";
echo filesize($file, true);


Expected result:
----------------
4.4G

Actual result:
--------------
401524051

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-08 00:42 UTC] felipe@php.net
It's expected, PHP doesnt works with large files yet. This is an item in our TODO, thanks.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 17:01:33 2025 UTC