note 115792 added to function.filesize

From: Date: Wed, 24 Sep 2014 10:19:17 +0000
Subject: note 115792 added to function.filesize
Groups: php.notes 
Request: Send a blank email to php-notes+get-200514@lists.php.net to get a copy of this message
Here ist the very fast and reliable way to get size of large files > 2Gb on 32bit and 64bit platforms. <?php /** * Get the size of file, platform- and architecture-independant. * This function supports 32bit and 64bit architectures and works fith large files > 2 GB * The return value type depends on platform/architecture: (float) when PHP_INT_SIZE < 8 or (int) otherwise * @param resource $fp * @return mixed (int|float) File size on success or (bool) FALSE on error */ function my_filesize($fp) { $return = false; if (is_resource($fp)) { if (PHP_INT_SIZE < 8) { // 32bit if (0 === fseek($fp, 0, SEEK_END)) { $return = 0.0; $step = 0x7FFFFFFF; while ($step > 0) { if (0 === fseek($fp, - $step, SEEK_CUR)) { $return += floatval($step); } else { $step >>= 1; } } } } elseif (0 === fseek($fp, 0, SEEK_END)) { // 64bit $return = ftell($fp); } } return $return; } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 82.198.197.2 ---- Manual Page -- http://php.net/manual/en/function.filesize.php Edit -- https://master.php.net/note/edit/115792 Del: integrated -- https://master.php.net/note/delete/115792/integrated Del: useless -- https://master.php.net/note/delete/115792/useless Del: bad code -- https://master.php.net/note/delete/115792/bad+code Del: spam -- https://master.php.net/note/delete/115792/spam Del: non-english -- https://master.php.net/note/delete/115792/non-english Del: in docs -- https://master.php.net/note/delete/115792/in+docs Del: other reasons-- https://master.php.net/note/delete/115792 Reject -- https://master.php.net/note/reject/115792 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200514) next »