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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 01:01:28 2024 UTC