Req #34750 [Com]: filesize()/stat() fails on too big files

From: Date: Sun, 11 Mar 2012 12:16:38 +0000
Subject: Req #34750 [Com]: filesize()/stat() fails on too big files
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-168354@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=34750&edit=1 ID: 34750 Comment by: sam_account3 at hotmail dot co dot uk Reported by: aulbach at mayflower dot de Summary: filesize()/stat() fails on too big files Status: Open Type: Feature/Change Request Package: *General Issues Operating System: * PHP Version: 5CVS,6CVS,4CVS (2008-02-22) Block user comment: N Private report: N New Comment: Please avoid writing '*' in the OS field. This is particularly important here, as your request is platform-dependant. PHP uses 4 bytes to store an integer on 32-bit systems, and 8 bytes on 64-bit systems. Previous Comments: ------------------------------------------------------------------------ [2010-08-24 10:54:00] aulbach at mayflower dot de Nice. Perhaps I mix something up, but don't forget to fix stat() too. :) ------------------------------------------------------------------------ [2010-08-23 22:11:59] dominic dot benson at thirdlight dot com The patch takes advantage of floats being doubles in PHP (with 53 bits of precision under linux 32) - in the patch LLONG_MAX is hardcoded as its actual value, this should really be derived from limits.h. It depends on PHP being built with the largefile compile flags to actually work (it fixes the integer wrapping that then occurs). It should be harmless on 64 bit, but ideally configure would check long vs. double on the system and include the additional section or not based on that. ------------------------------------------------------------------------ [2005-10-06 10:38:36] aulbach at mayflower dot de - it's not a feature request, it's a workarround over a problem, that otherwise cannot be solved within PHP! (without calling external programs) - For longer term, there is no question, that PHP needs 64 bit integer. ------------------------------------------------------------------------ [2005-10-06 10:22:20] derick@php.net This is not a bug, but a feature request. ------------------------------------------------------------------------ [2005-10-06 10:08:18] aulbach at mayflower dot de Description: ------------ Writing a php command-line script, which scans all my files on my big raid, I mentioned, that PHP is not able to handle the case, when the files are bigger than 4 GB. But this is more and more used, cause for example complete DVD-images are just put in one file. PHP itself cannot handle bigger numbers, cause it uses 32 bit integer. Currently I help me with ls but that's no real solution. Everyone is using 64 bit integer now. There are many cases, timestamps for example. For now I suggest, that the number is stored as a string, if it gets too big. I use that number only to write it into the database (which can handle 64 bit int), so for that case this is correct. For long term, I suggest a mechanism, that automatically assigns 64 bit integer, if the number gets too big. Reproduce code: --------------- $fsize = filesize($path); // returns invalid if file is too big, the rest of the program will fail, if I assume, that there will be a number OR $stats = stat($path); // complete record invalid ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=34750&edit=1

« previous php.bugs (#168354) next »